-
-
- {t('corporate.companyCard.companyNameLabel')}
-
-
{companyData.companyName}
+ {!data ? (
+ <>Loading>
+ ) : (
+
+
+
+
+ {t('corporate.companyCard.companyNameLabel')}
+
+
+ {data.group_name}
+
+
+
+
+ {t('corporate.companyCard.cardsCountLabel')}
+
+
{data.total_cards}
+
+
+
+ {t('corporate.companyCard.registrationDateLabel')}
+
+
+
+ {new Date(data.created_at).toLocaleDateString(
+ 'en-GB',
+ )}
+
+
-
-
- {t('corporate.companyCard.cardsCountLabel')}
-
-
{companyData.numberOfCards}
-
-
-
- {t('corporate.companyCard.registrationDateLabel')}
-
-
- {companyData.registrationDate}
-
+
+
+
+ {t('corporate.companyCard.fundLabel')}
+
+
+ {data.fund.toLocaleString()} {t('corporate.currency')}
+
+
+
+
+ {t('corporate.companyCard.overdraftLabel')}
+
+
+ {data.overdraft.toLocaleString()}{' '}
+ {t('corporate.currency')}
+
+
-
-
-
- {t('corporate.companyCard.fundLabel')}
-
-
- {companyData.fund.toLocaleString()}{' '}
- {t('corporate.currency')}
-
-
-
-
- {t('corporate.companyCard.overdraftLabel')}
-
-
- {companyData.overdraft.toLocaleString()}{' '}
- {t('corporate.currency')}
-
-
-
-
+ )}
{/* Fund Card */}
-
+
@@ -177,14 +189,18 @@ export function CorporateDashboard() {
-
-
- {companyData.totalFund.toLocaleString()}
-
-
- {t('corporate.fundCard.currency')}
-
-
+ {!data ? (
+ <>Loading>
+ ) : (
+
+
+ {data.fund_total?.toLocaleString()}
+
+
+ {t('corporate.fundCard.currency')}
+
+
+ )}
diff --git a/src/pages-templates/login/index.tsx b/src/pages-templates/login/index.tsx
index ac51ec6..40c4bb1 100644
--- a/src/pages-templates/login/index.tsx
+++ b/src/pages-templates/login/index.tsx
@@ -4,6 +4,7 @@ import { deleteCookie, getCookie } from 'cookies-next';
import { Building2, Fuel, User } from 'lucide-react';
import Link from 'next/link';
import { useRouter, useSearchParams } from 'next/navigation';
+import { Suspense } from 'react';
import { LoginForm } from '@/features/auth/login-form';
@@ -16,13 +17,13 @@ import {
CardHeader,
CardTitle,
} from '@/shared/shadcn-ui/card';
+import Container from '@/shared/shadcn-ui/conteiner';
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from '@/shared/shadcn-ui/tabs';
-import Container from '@/shared/shadcn-ui/conteiner';
const tabs = [
{
@@ -41,16 +42,97 @@ const tabs = [
},
];
-export default function LoginPage() {
+function LoginPageTabs() {
const { t } = useTextController();
const router = useRouter();
const searchParams = useSearchParams();
+
const defaultTab = searchParams.get('tab') || 'bonus';
const handleTabChange = (tabType: string) => {
- router.push(`?tab=${tabType}`, undefined, { shallow: true });
+ router.push(`?tab=${tabType}`, undefined);
};
+ return (
+
+
+ {tabs.map((tab) => {
+ return (
+
+ {t(tab.label)}
+
+ );
+ })}
+
+
+ {tabs.map((tab) => {
+ const tabCookieName = `${tab.type}__token`;
+
+ const authenticationCookie = getCookie(tabCookieName);
+
+ if (authenticationCookie) {
+ return (
+
+
+
+ {t(tab.title)}
+
+
+
+
+
+
+
+
+
+ );
+ }
+
+ return (
+
+
+
+ {t(tab.title)}
+ {t(tab.description)}
+
+
+
+
+
+
+ );
+ })}
+
+ );
+}
+
+export default function LoginPage() {
+ const { t } = useTextController();
+
return (
@@ -67,86 +149,17 @@ export default function LoginPage() {
-
-
- {tabs.map((tab) => {
- return (
-
- {t(tab.label)}
-
- );
- })}
-
-
- {tabs.map((tab) => {
- const tabCookieName = `${tab.type}__token`;
-
- const authenticationCookie = getCookie(tabCookieName);
-
- if (authenticationCookie) {
- return (
-
-
-
- {t(tab.title)}
-
-
-
-
-
-
-
-
-
- );
- }
-
- return (
-
-
-
- {t(tab.title)}
- {t(tab.description)}
-
-
-
-
-
-
- );
- })}
-
+
+
+
{t('auth.loginIssues')}{' '}
-
+
{t('auth.contactLink')}
diff --git a/src/shared/api/taylor-api.ts b/src/shared/api/taylor-api.ts
new file mode 100644
index 0000000..200a98c
--- /dev/null
+++ b/src/shared/api/taylor-api.ts
@@ -0,0 +1,14 @@
+import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query';
+
+const baseQuery = fetchBaseQuery({
+ baseUrl: process.env.TAYLOR_API_ENDPOINT,
+ headers: {
+ Authorization: process.env.TAYLOR_API_TOKEN || '',
+ },
+});
+
+export const taylorAPI = createApi({
+ reducerPath: 'taylorAPI',
+ baseQuery,
+ endpoints: () => ({}),
+});
diff --git a/src/shared/language/api/text-control.api.ts b/src/shared/language/api/text-control.api.ts
index 1fe2b26..dcbce86 100644
--- a/src/shared/language/api/text-control.api.ts
+++ b/src/shared/language/api/text-control.api.ts
@@ -1,12 +1,25 @@
-import { baseAPI } from '@/shared/api/base-api';
+import { jsonToGraphQLQuery } from 'json-to-graphql-query';
+
+import { presentTexts } from '@/app/api-utlities/presenters';
+import { textsRequest } from '@/app/api-utlities/requests/common';
+
+import { taylorAPI } from '@/shared/api/taylor-api';
import { TextItem } from '@/shared/types/text.types';
-export const textControlApi = baseAPI.injectEndpoints({
+export const textControlApi = taylorAPI.injectEndpoints({
endpoints: (builder) => ({
fetchText: builder.query
({
- query: () => '/text',
+ query: () => ({
+ url: '',
+ method: 'POST',
+ body: {
+ query: jsonToGraphQLQuery({ query: textsRequest }),
+ },
+ }),
+
+ transformResponse: (response: any) => {
+ return presentTexts(response.data._kontentSajta);
+ },
}),
}),
});
-
-export const { useFetchTextQuery } = textControlApi;
diff --git a/src/shared/store/index.ts b/src/shared/store/index.ts
index fb9db85..599e8de 100644
--- a/src/shared/store/index.ts
+++ b/src/shared/store/index.ts
@@ -4,13 +4,16 @@ import { createWrapper } from 'next-redux-wrapper';
import { baseAPI } from '@/shared/api/base-api';
+import { taylorAPI } from '../api/taylor-api';
import { rootReducer } from './root-reducer';
export const makeStore = () =>
configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
- getDefaultMiddleware().concat(baseAPI.middleware),
+ getDefaultMiddleware()
+ .concat(baseAPI.middleware)
+ .concat(taylorAPI.middleware),
devTools: process.env.NODE_ENV === 'development',
});
diff --git a/src/shared/store/root-reducer.ts b/src/shared/store/root-reducer.ts
index 1b1a8cd..080aa28 100644
--- a/src/shared/store/root-reducer.ts
+++ b/src/shared/store/root-reducer.ts
@@ -2,6 +2,9 @@ import { combineReducers } from '@reduxjs/toolkit';
import { baseAPI } from '@/shared/api/base-api';
+import { taylorAPI } from '../api/taylor-api';
+
export const rootReducer = combineReducers({
[baseAPI.reducerPath]: baseAPI.reducer,
+ [taylorAPI.reducerPath]: taylorAPI.reducer,
});
diff --git a/src/widgets/about-page/company-timeline.tsx b/src/widgets/about-page/company-timeline.tsx
index 3142061..1dcf68b 100644
--- a/src/widgets/about-page/company-timeline.tsx
+++ b/src/widgets/about-page/company-timeline.tsx
@@ -3,7 +3,7 @@
import { Calendar, ChevronDown, ChevronUp } from 'lucide-react';
import { useState } from 'react';
-import { HistoryItems } from '@/app/api-utlities/@types/about-us';
+import { HistoryItems } from '@/app/api-utlities/@types';
import { useTextController } from '@/shared/language/hooks/use-text-controller';
import { Button } from '@/shared/shadcn-ui/button';
diff --git a/src/widgets/map-section.tsx b/src/widgets/map-section.tsx
index 8bfa798..dc4c187 100644
--- a/src/widgets/map-section.tsx
+++ b/src/widgets/map-section.tsx
@@ -2,9 +2,8 @@
import { MapPin } from 'lucide-react';
-import { Stations } from '@/app/api-utlities/@types/main';
+import { Stations } from '@/app/api-utlities/@types';
-import { GasStationMap } from '@/features/map';
import { Point } from '@/features/map/model';
import { YandexMap } from '@/features/map/ui/yandex-map';
diff --git a/src/widgets/partners-section.tsx b/src/widgets/partners-section.tsx
index dd51fd9..e85119f 100644
--- a/src/widgets/partners-section.tsx
+++ b/src/widgets/partners-section.tsx
@@ -4,7 +4,7 @@ import { Handshake } from 'lucide-react';
import Image from 'next/image';
import Link from 'next/link';
-import { Partners } from '@/app/api-utlities/@types/main';
+import { Partners } from '@/app/api-utlities/@types';
import { useTextController } from '@/shared/language/hooks/use-text-controller';
import { Button } from '@/shared/shadcn-ui/button';
diff --git a/src/widgets/transactions-table.tsx b/src/widgets/transactions-table.tsx
index 787bce3..eae985d 100644
--- a/src/widgets/transactions-table.tsx
+++ b/src/widgets/transactions-table.tsx
@@ -3,7 +3,9 @@
import { format, subMonths } from 'date-fns';
import { ru } from 'date-fns/locale';
import { CalendarIcon } from 'lucide-react';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
+
+import { useFetchBonusTransactionsQuery } from '@/entities/bonus/api/bonus.api';
import { useTextController } from '@/shared/language/hooks/use-text-controller';
import { Button } from '@/shared/shadcn-ui/button';
@@ -23,85 +25,30 @@ import {
TableRow,
} from '@/shared/shadcn-ui/table';
-// Sample customer data
-const customerData = {
- firstName: 'Алишер',
- lastName: 'Рахмонов',
- passportNumber: 'A12345678',
- bonusPoints: 1250,
- cardNumber: '5678-9012-3456-7890',
- expiryDate: '12/2025',
- registrationDate: '15.06.2020',
-};
-
-// Sample transaction data
-const generateTransactions = () => {
- const stations = [
- 'АЗС Душанбе-Центр',
- 'АЗС Душанбе-Запад',
- 'АЗС Душанбе-Восток',
- 'АЗС Худжанд',
- 'АЗС Куляб',
- ];
-
- const products = [
- { name: 'ДТ', price: 8.5 },
- { name: 'АИ-92', price: 9.2 },
- { name: 'АИ-95', price: 10.5 },
- { name: 'Z-100 Power', price: 11.8 },
- { name: 'Пропан', price: 6.3 },
- ];
-
- const transactions = [];
-
- // Generate 50 random transactions over the last 6 months
- for (let i = 0; i < 50; i++) {
- const date = subMonths(new Date(), Math.random() * 6);
- const station = stations[Math.floor(Math.random() * stations.length)];
- const product = products[Math.floor(Math.random() * products.length)];
- const quantity = Math.floor(Math.random() * 40) + 10; // 10-50 liters
- const cost = product.price;
- const total = quantity * cost;
-
- transactions.push({
- id: i + 1,
- date,
- station,
- product: product.name,
- quantity,
- cost,
- total,
- });
- }
-
- // Sort by date (newest first)
- return transactions.sort((a, b) => b.date.getTime() - a.date.getTime());
-};
-
-const transactions = generateTransactions();
-
export const TransactionsTable = () => {
- const [startDate, setStartDate] = useState(
- subMonths(new Date(), 1),
- );
- const [endDate, setEndDate] = useState(new Date());
- const [filteredTransactions, setFilteredTransactions] =
- useState(transactions);
+ const [startDate, setStartDate] = useState(subMonths(new Date(), 1));
+ const [endDate, setEndDate] = useState(new Date());
+
+ const { data, refetch } = useFetchBonusTransactionsQuery({
+ limit: 100,
+ page: 1,
+ start_date: format(startDate, 'yyyy-MM-dd'),
+ end_date: format(endDate, 'yyyy-MM-dd'),
+ });
// Filter transactions by date range
const filterTransactions = () => {
if (!startDate || !endDate) return;
- const filtered = transactions.filter((transaction) => {
- const transactionDate = new Date(transaction.date);
- return transactionDate >= startDate && transactionDate <= endDate;
- });
-
- setFilteredTransactions(filtered);
+ refetch();
};
const { t } = useTextController();
+ useEffect(() => {}, [startDate, endDate]);
+
+ if (!data) return null;
+
return (
@@ -200,22 +147,22 @@ export const TransactionsTable = () => {
- {filteredTransactions.length > 0 ? (
- filteredTransactions.map((transaction) => (
+ {data.transactions.length > 0 ? (
+ data.transactions.map((transaction) => (
- {format(transaction.date, 'dd.MM.yyyy')}
+ {format(new Date(transaction.date_create), 'dd.MM.yyyy')}
{transaction.station}
- {transaction.product}
+ {transaction.product_name}
- {transaction.quantity}
+ {transaction.price_real}
- {transaction.cost.toFixed(2)} {t('corporate.currency')}
+ {transaction.amount} {t('corporate.currency')}
- {transaction.total.toFixed(2)} {t('corporate.currency')}
+ {transaction.sum_real} {t('corporate.currency')}
))