Compare commits
No commits in common. "2821025a3eaa973bf04cd675444562e59f8434ea" and "f28204416db5a929cf461b0abd355af696440ad6" have entirely different histories.
2821025a3e
...
f28204416d
@ -19,16 +19,13 @@
|
||||
"@radix-ui/react-navigation-menu": "^1.2.10",
|
||||
"@radix-ui/react-popover": "^1.1.11",
|
||||
"@radix-ui/react-select": "^2.2.2",
|
||||
"@radix-ui/react-separator": "^1.1.4",
|
||||
"@radix-ui/react-slot": "^1.2.0",
|
||||
"@radix-ui/react-tabs": "^1.1.8",
|
||||
"@radix-ui/react-toast": "^1.2.11",
|
||||
"@reduxjs/toolkit": "^2.7.0",
|
||||
"aos": "^2.3.4",
|
||||
"axios": "^1.9.0",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cookies-next": "^5.1.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"embla-carousel-autoplay": "^8.6.0",
|
||||
"embla-carousel-react": "^8.6.0",
|
||||
|
||||
120
pnpm-lock.yaml
generated
120
pnpm-lock.yaml
generated
@ -35,9 +35,6 @@ importers:
|
||||
'@radix-ui/react-select':
|
||||
specifier: ^2.2.2
|
||||
version: 2.2.2(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-separator':
|
||||
specifier: ^1.1.4
|
||||
version: 1.1.4(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@radix-ui/react-slot':
|
||||
specifier: ^1.2.0
|
||||
version: 1.2.0(@types/react@19.1.2)(react@19.1.0)
|
||||
@ -53,18 +50,12 @@ importers:
|
||||
aos:
|
||||
specifier: ^2.3.4
|
||||
version: 2.3.4
|
||||
axios:
|
||||
specifier: ^1.9.0
|
||||
version: 1.9.0
|
||||
class-variance-authority:
|
||||
specifier: ^0.7.1
|
||||
version: 0.7.1
|
||||
clsx:
|
||||
specifier: ^2.1.1
|
||||
version: 2.1.1
|
||||
cookies-next:
|
||||
specifier: ^5.1.0
|
||||
version: 5.1.0(next@15.3.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0)
|
||||
date-fns:
|
||||
specifier: ^4.1.0
|
||||
version: 4.1.0
|
||||
@ -827,19 +818,6 @@ packages:
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-separator@1.1.4':
|
||||
resolution: {integrity: sha512-2fTm6PSiUm8YPq9W0E4reYuv01EE3aFSzt8edBiXqPHshF8N9+Kymt/k0/R+F3dkY5lQyB/zPtrP82phskLi7w==}
|
||||
peerDependencies:
|
||||
'@types/react': '*'
|
||||
'@types/react-dom': '*'
|
||||
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||
peerDependenciesMeta:
|
||||
'@types/react':
|
||||
optional: true
|
||||
'@types/react-dom':
|
||||
optional: true
|
||||
|
||||
'@radix-ui/react-slot@1.2.0':
|
||||
resolution: {integrity: sha512-ujc+V6r0HNDviYqIK3rW4ffgYiZ8g5DEHrGJVk4x7kTlLXRDILnKX9vAUYeIsLOoDpDJ0ujpqMkjH4w2ofuo6w==}
|
||||
peerDependencies:
|
||||
@ -1340,9 +1318,6 @@ packages:
|
||||
resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
|
||||
available-typed-arrays@1.0.7:
|
||||
resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -1351,9 +1326,6 @@ packages:
|
||||
resolution: {integrity: sha512-Xm7bpRXnDSX2YE2YFfBk2FnF0ep6tmG7xPh8iHee8MIcrgq762Nkce856dYtJYLkuIoYZvGfTs/PbZhideTcEg==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
axios@1.9.0:
|
||||
resolution: {integrity: sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==}
|
||||
|
||||
axobject-query@4.1.0:
|
||||
resolution: {integrity: sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==}
|
||||
engines: {node: '>= 0.4'}
|
||||
@ -1425,23 +1397,9 @@ packages:
|
||||
resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
|
||||
engines: {node: '>=12.5.0'}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
concat-map@0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
|
||||
cookie@1.0.2:
|
||||
resolution: {integrity: sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
cookies-next@5.1.0:
|
||||
resolution: {integrity: sha512-9Ekne+q8hfziJtnT9c1yDUBqT0eDMGgPrfPl4bpR3xwQHLTd/8gbSf6+IEkP/pjGsDZt1TGbC6emYmFYRbIXwQ==}
|
||||
peerDependencies:
|
||||
next: '>=15.0.0'
|
||||
react: '>= 16.8.0'
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
@ -1495,10 +1453,6 @@ packages:
|
||||
resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
detect-libc@2.0.3:
|
||||
resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==}
|
||||
engines: {node: '>=8'}
|
||||
@ -1769,23 +1723,10 @@ packages:
|
||||
flatted@3.3.3:
|
||||
resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==}
|
||||
|
||||
follow-redirects@1.15.9:
|
||||
resolution: {integrity: sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==}
|
||||
engines: {node: '>=4.0'}
|
||||
peerDependencies:
|
||||
debug: '*'
|
||||
peerDependenciesMeta:
|
||||
debug:
|
||||
optional: true
|
||||
|
||||
for-each@0.3.5:
|
||||
resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
form-data@4.0.2:
|
||||
resolution: {integrity: sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
function-bind@1.1.2:
|
||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||
|
||||
@ -2161,14 +2102,6 @@ packages:
|
||||
resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==}
|
||||
engines: {node: '>=8.6'}
|
||||
|
||||
mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
mime-types@2.1.35:
|
||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
||||
minimatch@10.0.1:
|
||||
resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
@ -2386,9 +2319,6 @@ packages:
|
||||
prop-types@15.8.1:
|
||||
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
|
||||
|
||||
proxy-from-env@1.1.0:
|
||||
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
|
||||
|
||||
punycode@2.3.1:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
@ -3398,15 +3328,6 @@ snapshots:
|
||||
'@types/react': 19.1.2
|
||||
'@types/react-dom': 19.1.2(@types/react@19.1.2)
|
||||
|
||||
'@radix-ui/react-separator@1.1.4(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)':
|
||||
dependencies:
|
||||
'@radix-ui/react-primitive': 2.1.0(@types/react-dom@19.1.2(@types/react@19.1.2))(@types/react@19.1.2)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
react: 19.1.0
|
||||
react-dom: 19.1.0(react@19.1.0)
|
||||
optionalDependencies:
|
||||
'@types/react': 19.1.2
|
||||
'@types/react-dom': 19.1.2(@types/react@19.1.2)
|
||||
|
||||
'@radix-ui/react-slot@1.2.0(@types/react@19.1.2)(react@19.1.0)':
|
||||
dependencies:
|
||||
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.1.2)(react@19.1.0)
|
||||
@ -3890,22 +3811,12 @@ snapshots:
|
||||
|
||||
async-function@1.0.0: {}
|
||||
|
||||
asynckit@0.4.0: {}
|
||||
|
||||
available-typed-arrays@1.0.7:
|
||||
dependencies:
|
||||
possible-typed-array-names: 1.1.0
|
||||
|
||||
axe-core@4.10.3: {}
|
||||
|
||||
axios@1.9.0:
|
||||
dependencies:
|
||||
follow-redirects: 1.15.9
|
||||
form-data: 4.0.2
|
||||
proxy-from-env: 1.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
|
||||
axobject-query@4.1.0: {}
|
||||
|
||||
balanced-match@1.0.2: {}
|
||||
@ -3981,20 +3892,8 @@ snapshots:
|
||||
color-string: 1.9.1
|
||||
optional: true
|
||||
|
||||
combined-stream@1.0.8:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
|
||||
concat-map@0.0.1: {}
|
||||
|
||||
cookie@1.0.2: {}
|
||||
|
||||
cookies-next@5.1.0(next@15.3.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(react@19.1.0):
|
||||
dependencies:
|
||||
cookie: 1.0.2
|
||||
next: 15.3.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
react: 19.1.0
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
@ -4047,8 +3946,6 @@ snapshots:
|
||||
has-property-descriptors: 1.0.2
|
||||
object-keys: 1.1.1
|
||||
|
||||
delayed-stream@1.0.0: {}
|
||||
|
||||
detect-libc@2.0.3: {}
|
||||
|
||||
detect-node-es@1.1.0: {}
|
||||
@ -4474,19 +4371,10 @@ snapshots:
|
||||
|
||||
flatted@3.3.3: {}
|
||||
|
||||
follow-redirects@1.15.9: {}
|
||||
|
||||
for-each@0.3.5:
|
||||
dependencies:
|
||||
is-callable: 1.2.7
|
||||
|
||||
form-data@4.0.2:
|
||||
dependencies:
|
||||
asynckit: 0.4.0
|
||||
combined-stream: 1.0.8
|
||||
es-set-tostringtag: 2.1.0
|
||||
mime-types: 2.1.35
|
||||
|
||||
function-bind@1.1.2: {}
|
||||
|
||||
function.prototype.name@1.1.8:
|
||||
@ -4839,12 +4727,6 @@ snapshots:
|
||||
braces: 3.0.3
|
||||
picomatch: 2.3.1
|
||||
|
||||
mime-db@1.52.0: {}
|
||||
|
||||
mime-types@2.1.35:
|
||||
dependencies:
|
||||
mime-db: 1.52.0
|
||||
|
||||
minimatch@10.0.1:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.1
|
||||
@ -5014,8 +4896,6 @@ snapshots:
|
||||
object-assign: 4.1.1
|
||||
react-is: 16.13.1
|
||||
|
||||
proxy-from-env@1.1.0: {}
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
queue-microtask@1.2.3: {}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
@ -1,17 +1,5 @@
|
||||
import AboutPage from '@/pages-templates/about';
|
||||
import AboutPage from "@/pages-templates/about";
|
||||
|
||||
import { mainPageApi } from '@/features/pages/api/pages.api';
|
||||
|
||||
import { makeStore } from '@/shared/store';
|
||||
|
||||
export default async function About() {
|
||||
const store = makeStore();
|
||||
|
||||
const { data } = await store.dispatch(
|
||||
mainPageApi.endpoints.fetchAboutUsPageContent.initiate(),
|
||||
);
|
||||
|
||||
if (!data) return null;
|
||||
|
||||
return <AboutPage content={data} />;
|
||||
export default function About(){
|
||||
return <AboutPage/>
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
import { HistoryItems, Reviews, Stations, TeamMembers } from '.';
|
||||
|
||||
export type AboutUsPageData = {
|
||||
team: TeamMembers;
|
||||
history: HistoryItems;
|
||||
stations: Stations;
|
||||
reviews: Reviews;
|
||||
};
|
||||
@ -1,13 +1,3 @@
|
||||
import {
|
||||
presentDiscounts,
|
||||
presentHistoryItems,
|
||||
presentJobs,
|
||||
presentPartners,
|
||||
presentReviews,
|
||||
presentStations,
|
||||
presentTeamMembers,
|
||||
} from '../presenters';
|
||||
|
||||
export type Root<T> = { records: T[] };
|
||||
|
||||
export interface Image {
|
||||
@ -63,30 +53,3 @@ export type TextResponse = Root<{
|
||||
_name: string;
|
||||
_znachenie: string | null;
|
||||
}>;
|
||||
|
||||
export type Team = Root<{
|
||||
_foto: Image[];
|
||||
_zvanie: string;
|
||||
_name: string;
|
||||
}>;
|
||||
|
||||
export type History = Root<{
|
||||
_name: string;
|
||||
_god: string;
|
||||
_opisanie: string;
|
||||
}>;
|
||||
|
||||
export type Review = Root<{
|
||||
id: number;
|
||||
_name: string;
|
||||
_otzyv: string;
|
||||
_rejting: number;
|
||||
}>;
|
||||
|
||||
export type TeamMembers = ReturnType<typeof presentTeamMembers>;
|
||||
export type HistoryItems = ReturnType<typeof presentHistoryItems>;
|
||||
export type Stations = ReturnType<typeof presentStations>;
|
||||
export type Partners = ReturnType<typeof presentPartners>;
|
||||
export type Jobs = ReturnType<typeof presentJobs>;
|
||||
export type Discounts = ReturnType<typeof presentDiscounts>;
|
||||
export type Reviews = ReturnType<typeof presentReviews>;
|
||||
|
||||
@ -1,4 +1,14 @@
|
||||
import { Discounts, Jobs, Partners, Stations } from '.';
|
||||
import {
|
||||
presentDiscounts,
|
||||
presentJobs,
|
||||
presentPartners,
|
||||
presentStations,
|
||||
} from '../presenters';
|
||||
|
||||
export type Partners = ReturnType<typeof presentPartners>;
|
||||
export type Jobs = ReturnType<typeof presentJobs>;
|
||||
export type Discounts = ReturnType<typeof presentDiscounts>;
|
||||
export type Stations = ReturnType<typeof presentStations>;
|
||||
|
||||
export type MainPageData = {
|
||||
discounts: Discounts;
|
||||
|
||||
@ -2,23 +2,16 @@ import { isEmpty } from 'lodash';
|
||||
|
||||
import {
|
||||
Discount,
|
||||
History,
|
||||
Image,
|
||||
Job,
|
||||
Partner,
|
||||
Review,
|
||||
Select,
|
||||
Station,
|
||||
Team,
|
||||
TextResponse,
|
||||
} from '../@types';
|
||||
|
||||
export const presentImage = (images: Image[]) =>
|
||||
isEmpty(images) ? null : `${process.env.TAYLOR_MEDIA_URL}/${images[0].url}`;
|
||||
|
||||
export const presentSelect = (selectItems: Select[]) =>
|
||||
!isEmpty(selectItems) ? selectItems[0].name : null;
|
||||
|
||||
export const presentPartners = (partners: Partner) =>
|
||||
partners.records.map((record, index) => ({
|
||||
id: index + 1,
|
||||
@ -31,22 +24,8 @@ export const presentJobs = (jobs: Job) =>
|
||||
id: index + 1,
|
||||
name: job._name,
|
||||
tags: job._tags.map((tag) => tag.name),
|
||||
location: presentSelect(job._localtio),
|
||||
type: presentSelect(job._type),
|
||||
}));
|
||||
|
||||
export const presentTeamMembers = (members: Team) =>
|
||||
members.records.map((member) => ({
|
||||
name: member._name,
|
||||
photo: presentImage(member._foto),
|
||||
profession: member._zvanie,
|
||||
}));
|
||||
|
||||
export const presentHistoryItems = (historyItems: History) =>
|
||||
historyItems.records.map((item) => ({
|
||||
name: item._name,
|
||||
year: item._god,
|
||||
description: item._opisanie,
|
||||
location: !isEmpty(job._localtio) ? job._localtio[0].name : null,
|
||||
type: !isEmpty(job._type) ? job._type[0].name : null,
|
||||
}));
|
||||
|
||||
export const presentDiscounts = (discounts: Discount) =>
|
||||
@ -75,7 +54,7 @@ export const presentStations = (stations: Station) =>
|
||||
electricCharge: station._propanCopy || false,
|
||||
miniMarket: station._zaryadnayaStanci || false,
|
||||
toilet: station._miniMarketCop || false,
|
||||
region: presentSelect(station._region),
|
||||
region: !isEmpty(station._region) ? station._region[0].name : null,
|
||||
image: presentImage(station._foto),
|
||||
}));
|
||||
|
||||
@ -84,11 +63,3 @@ export const presentTexts = (texts: TextResponse) =>
|
||||
key: item._name,
|
||||
value: item._znachenie,
|
||||
}));
|
||||
|
||||
export const presentReviews = (reviews: Review) =>
|
||||
reviews.records.map((review) => ({
|
||||
id: review.id,
|
||||
fullname: review._name,
|
||||
review: review._otzyv,
|
||||
rating: review._rejting,
|
||||
}));
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
import {
|
||||
historyRequest,
|
||||
reviewsRequest,
|
||||
stationsWithImageRequest,
|
||||
teamRequest,
|
||||
} from './common';
|
||||
|
||||
export const aboutUsPageRequest = {
|
||||
...teamRequest,
|
||||
...historyRequest,
|
||||
...stationsWithImageRequest,
|
||||
...reviewsRequest,
|
||||
};
|
||||
@ -1,5 +1,3 @@
|
||||
import { EnumType } from 'json-to-graphql-query';
|
||||
|
||||
export const stationsRequest = {
|
||||
_azs: {
|
||||
records: {
|
||||
@ -29,48 +27,6 @@ export const stationsRequest = {
|
||||
},
|
||||
};
|
||||
|
||||
export const stationsWithImageRequest = {
|
||||
_azs: {
|
||||
__args: {
|
||||
filtersSet: {
|
||||
conjunction: new EnumType('and'),
|
||||
filtersSet: [
|
||||
{
|
||||
field: new EnumType('_foto'),
|
||||
operator: 'isNotEmpty',
|
||||
value: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
records: {
|
||||
_name: true,
|
||||
_opisanie: true,
|
||||
_adress: true,
|
||||
_chasyRaboty: {
|
||||
name: true,
|
||||
},
|
||||
_lat: true,
|
||||
_long: true,
|
||||
_avtomojka: true,
|
||||
_dtCopy: true, // ai92
|
||||
_ai92Copy: true, // ai95
|
||||
_ai95Copy: true, // z100
|
||||
_z100Copy: true, // propan
|
||||
_propanCopy: true, // electricCharge
|
||||
_zaryadnayaStanci: true, // miniMarket
|
||||
_miniMarketCop: true, // toilet
|
||||
_region: {
|
||||
name: true,
|
||||
},
|
||||
_foto: {
|
||||
url: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const partnersRequest = {
|
||||
_partners: {
|
||||
records: {
|
||||
@ -120,36 +76,3 @@ export const textsRequest = {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const teamRequest = {
|
||||
_komanda: {
|
||||
records: {
|
||||
_foto: {
|
||||
url: true,
|
||||
},
|
||||
_zvanie: true,
|
||||
_name: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const historyRequest = {
|
||||
_istoriya: {
|
||||
records: {
|
||||
_name: true,
|
||||
_god: true,
|
||||
_opisanie: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const reviewsRequest = {
|
||||
_otzyvy: {
|
||||
records: {
|
||||
id: true,
|
||||
_name: true,
|
||||
_otzyv: true,
|
||||
_rejting: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import { Axios } from 'axios';
|
||||
|
||||
const oriyoClient = new Axios({
|
||||
baseURL: process.env.ORIOYO_API_ENDPOINT || '',
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
export default oriyoClient;
|
||||
@ -1,39 +1,54 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { z } from 'zod';
|
||||
|
||||
import oriyoClient from '@/app/api-utlities/utilities/oriyo.client';
|
||||
import { LoginData } from '@/entities/auth/model/types';
|
||||
|
||||
import { loginFormSchema } from '@/entities/auth/model/validation/login-form.schema';
|
||||
export const GET = async (req: NextRequest) => {
|
||||
if (req.method !== 'GET') {
|
||||
return NextResponse.json(
|
||||
{ error: 'Method is not supported' },
|
||||
{ status: 405 },
|
||||
);
|
||||
}
|
||||
|
||||
import { validationErrorHandler } from '../../middlewares/error-handler.middleware';
|
||||
const { searchParams } = req.nextUrl;
|
||||
|
||||
const routeHandler = async (req: NextRequest) => {
|
||||
const body = await req.json();
|
||||
const phoneNumber = searchParams.get('phoneNumber');
|
||||
const cardNumber = searchParams.get('cardNumber');
|
||||
const type = searchParams.get('type');
|
||||
|
||||
const validatedBody = loginFormSchema
|
||||
.merge(z.object({ type: z.enum(['bonus', 'corporate']) }))
|
||||
.parse(body);
|
||||
if (!phoneNumber || !cardNumber || !type) {
|
||||
return NextResponse.json({ error: 'Bad request' }, { status: 400 });
|
||||
}
|
||||
|
||||
try {
|
||||
const oriyoResponse = await oriyoClient.get('/client/login', {
|
||||
params: {
|
||||
type: validatedBody.type,
|
||||
phone: validatedBody.phoneNumber,
|
||||
uid: validatedBody.cardNumber,
|
||||
const loginRes = await fetch(
|
||||
`https://test.oriyo.tj/api/client/login?type=${type}&phone=${phoneNumber}&uid=${cardNumber}`,
|
||||
{
|
||||
method: 'GET',
|
||||
},
|
||||
});
|
||||
);
|
||||
|
||||
const parsedResponse = JSON.parse(oriyoResponse.data);
|
||||
if (!loginRes.ok) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Error during login' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
if (!parsedResponse.token) {
|
||||
return NextResponse.json({ error: 'Credentials error' }, { status: 401 });
|
||||
const data = (await loginRes.json()) as LoginData;
|
||||
|
||||
const token = data.token;
|
||||
if (!token) {
|
||||
return NextResponse.json({ error: 'No auth token' }, { status: 401 });
|
||||
}
|
||||
|
||||
const response = NextResponse.json({ success: true });
|
||||
|
||||
response.cookies.set(`${validatedBody.type}__token`, oriyoResponse.data, {
|
||||
response.cookies.set('token', token, {
|
||||
httpOnly: true,
|
||||
path: '/',
|
||||
maxAge: 2 * 60 * 60,
|
||||
secure: process.env.NODE_ENV === 'production',
|
||||
});
|
||||
|
||||
return response;
|
||||
@ -42,5 +57,3 @@ const routeHandler = async (req: NextRequest) => {
|
||||
return NextResponse.json({ error: 'Server error' }, { status: 500 });
|
||||
}
|
||||
};
|
||||
|
||||
export const POST = validationErrorHandler(routeHandler);
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import oriyoClient from '@/app/api-utlities/utilities/oriyo.client';
|
||||
|
||||
import { validationErrorHandler } from '../../middlewares/error-handler.middleware';
|
||||
|
||||
const routeHandler = async (req: NextRequest) => {
|
||||
const bonusTokenData = req.cookies.get('bonus__token');
|
||||
|
||||
if (!bonusTokenData) {
|
||||
return NextResponse.json(
|
||||
{ error: 'User does not have access' },
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
|
||||
const { card_id, token } = JSON.parse(bonusTokenData.value);
|
||||
|
||||
const oriyoResponse = await oriyoClient.get('/client/info', {
|
||||
params: {
|
||||
card_id,
|
||||
token,
|
||||
},
|
||||
});
|
||||
|
||||
return new Response(oriyoResponse.data, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
};
|
||||
|
||||
export const GET = validationErrorHandler(routeHandler);
|
||||
@ -1,63 +0,0 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { z } from 'zod';
|
||||
|
||||
import oriyoClient from '@/app/api-utlities/utilities/oriyo.client';
|
||||
|
||||
import { validationErrorHandler } from '../../middlewares/error-handler.middleware';
|
||||
|
||||
const validatedSchema = z.object({
|
||||
start_date: z.string().optional(),
|
||||
end_date: z.string().optional(),
|
||||
limit: z.coerce.number(),
|
||||
page: z.coerce.number(),
|
||||
});
|
||||
|
||||
const routeHandler = async (req: NextRequest) => {
|
||||
const bonusTokenData = req.cookies.get('bonus__token');
|
||||
|
||||
if (!bonusTokenData) {
|
||||
return NextResponse.json(
|
||||
{ error: 'User does not have access' },
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
|
||||
const params = Array.from(req.nextUrl.searchParams.entries()).reduce(
|
||||
(pr, cr) => {
|
||||
pr[cr[0]] = cr[1];
|
||||
|
||||
return pr;
|
||||
},
|
||||
{} as Record<string, string>,
|
||||
);
|
||||
|
||||
const validatedRequest = validatedSchema.parse(params);
|
||||
|
||||
const { card_id, token } = JSON.parse(bonusTokenData.value);
|
||||
|
||||
const oriyoResponse = await oriyoClient.get('/client/transactions', {
|
||||
params: {
|
||||
card_id,
|
||||
token,
|
||||
limit: validatedRequest.limit,
|
||||
page: validatedRequest.page,
|
||||
type: 'bonus',
|
||||
sort: 'id',
|
||||
direction: 'desc',
|
||||
start_date: validatedRequest.start_date,
|
||||
end_date: validatedRequest.end_date,
|
||||
},
|
||||
});
|
||||
|
||||
const parsedResponse = JSON.parse(oriyoResponse.data);
|
||||
|
||||
if (parsedResponse.error) {
|
||||
return NextResponse.json({ message: 'Fetch error' }, { status: 400 });
|
||||
}
|
||||
|
||||
return new Response(oriyoResponse.data, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
};
|
||||
|
||||
export const GET = validationErrorHandler(routeHandler);
|
||||
@ -1,23 +0,0 @@
|
||||
import { omit } from 'lodash';
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { validationErrorHandler } from '../../middlewares/error-handler.middleware';
|
||||
|
||||
const routeHandler = async (req: NextRequest) => {
|
||||
const bonusTokenData = req.cookies.get('corporate__token');
|
||||
|
||||
if (!bonusTokenData) {
|
||||
return NextResponse.json(
|
||||
{ error: 'User does not have access' },
|
||||
{ status: 401 },
|
||||
);
|
||||
}
|
||||
|
||||
const parsedData = JSON.parse(bonusTokenData.value);
|
||||
|
||||
return new Response(JSON.stringify(omit(parsedData, 'token')), {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
};
|
||||
|
||||
export const GET = validationErrorHandler(routeHandler);
|
||||
@ -1,19 +0,0 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { ZodError } from 'zod';
|
||||
|
||||
export const validationErrorHandler =
|
||||
(handler: Function) =>
|
||||
async (req: NextRequest, ...args: any[]) => {
|
||||
try {
|
||||
return await handler(req, ...args);
|
||||
} catch (error) {
|
||||
if (error instanceof ZodError)
|
||||
return NextResponse.json({ message: error.format() }, { status: 400 });
|
||||
|
||||
console.error(error);
|
||||
return NextResponse.json(
|
||||
{ message: 'Server died for some reason' },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
};
|
||||
24
src/app/api/pages/main/route.ts
Normal file
24
src/app/api/pages/main/route.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import {
|
||||
presentDiscounts,
|
||||
presentJobs,
|
||||
presentPartners,
|
||||
presentStations,
|
||||
} from '@/app/api-utlities/presenters';
|
||||
import { mainPageRequest } from '@/app/api-utlities/requests/main-page.request';
|
||||
import { requestTaylor } from '@/app/api-utlities/utilities/taylor.client';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const response = await requestTaylor(mainPageRequest);
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
partners: presentPartners(response.data._partners),
|
||||
jobs: presentJobs(response.data._vacancies),
|
||||
discounts: presentDiscounts(response.data._akcii),
|
||||
stations: presentStations(response.data._azs),
|
||||
}),
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
);
|
||||
}
|
||||
14
src/app/api/text/route.ts
Normal file
14
src/app/api/text/route.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { presentTexts } from '@/app/api-utlities/presenters';
|
||||
import { textsRequest } from '@/app/api-utlities/requests/common';
|
||||
import { requestTaylor } from '@/app/api-utlities/utilities/taylor.client';
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const response = await requestTaylor(textsRequest);
|
||||
|
||||
return new Response(
|
||||
JSON.stringify(presentTexts(response.data._kontentSajta)),
|
||||
{
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -37,7 +37,7 @@ export default async function RootLayout({
|
||||
className='scroll-smooth'
|
||||
style={{ scrollBehavior: 'smooth' }}
|
||||
>
|
||||
<body className={`${inter.className} min-w-2xs antialiased`}>
|
||||
<body className={`${inter.className} antialiased`}>
|
||||
<Providers textItems={response.data as TextItem[]}>
|
||||
<Header />
|
||||
{children}
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
import { mainPageApi } from '@/features/pages/api/pages.api';
|
||||
|
||||
import { makeStore } from '@/shared/store';
|
||||
|
||||
import { AboutSection } from '@/widgets/about-section';
|
||||
import { CharitySection } from '@/widgets/charity-section';
|
||||
import { CtaSection } from '@/widgets/cta-section';
|
||||
@ -12,24 +8,23 @@ import { PromotionsSection } from '@/widgets/promotions-section';
|
||||
import { StatsSection } from '@/widgets/stats-section';
|
||||
import { VacanciesSection } from '@/widgets/vacancies-section';
|
||||
|
||||
import { MainPageData } from './api-utlities/@types/main';
|
||||
|
||||
export default async function Home() {
|
||||
const store = makeStore();
|
||||
|
||||
const { data, isLoading, error } = await store.dispatch(
|
||||
mainPageApi.endpoints.fetchMainPageContent.initiate(),
|
||||
);
|
||||
|
||||
if (isLoading || !data) return null;
|
||||
const mainPageData = (await fetch(
|
||||
`${process.env.NEXT_PUBLIC_BASE_URL}/api/pages/main`,
|
||||
{ method: 'GET' },
|
||||
).then((res) => res.json())) as MainPageData;
|
||||
|
||||
return (
|
||||
<main>
|
||||
<HeroSection />
|
||||
<StatsSection />
|
||||
<MapSection stations={data.stations} />
|
||||
<MapSection stations={mainPageData.stations} />
|
||||
<AboutSection />
|
||||
<PromotionsSection discounts={data.discounts} />
|
||||
<VacanciesSection jobs={data.jobs} />
|
||||
<PartnersSection partners={data.partners} />
|
||||
<PromotionsSection discounts={mainPageData.discounts} />
|
||||
<VacanciesSection jobs={mainPageData.jobs} />
|
||||
<PartnersSection partners={mainPageData.partners} />
|
||||
<CharitySection />
|
||||
<CtaSection />
|
||||
</main>
|
||||
|
||||
@ -1,23 +1,24 @@
|
||||
import { baseAPI } from '@/shared/api/base-api';
|
||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
||||
|
||||
import { LoginParams, LoginResponse } from '../model/contracts/login.contract';
|
||||
|
||||
export const authenticationApi = baseAPI.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
login: builder.query<LoginResponse, LoginParams>({
|
||||
export const loginAPI = createApi({
|
||||
baseQuery: fetchBaseQuery({ baseUrl: '/api' }),
|
||||
endpoints: (build) => ({
|
||||
login: build.query<LoginResponse, LoginParams>({
|
||||
query: (data) => {
|
||||
return {
|
||||
method: 'POST',
|
||||
body: {
|
||||
const params = new URLSearchParams({
|
||||
type: data.type,
|
||||
phoneNumber: data.phoneNumber,
|
||||
cardNumber: data.cardNumber,
|
||||
},
|
||||
url: '/auth/login',
|
||||
}).toString();
|
||||
|
||||
return {
|
||||
url: `/auth/login?${params}`,
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useLazyLoginQuery } = authenticationApi;
|
||||
export const { useLazyLoginQuery } = loginAPI;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { LoginFormData } from '@/entities/auth/model/validation/login-form.schema';
|
||||
import { LoginFormData } from '@/features/auth/login-form/model/login-form.schema';
|
||||
|
||||
export interface LoginResponse {
|
||||
success: boolean;
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
import { baseAPI } from '@/shared/api/base-api';
|
||||
|
||||
import {
|
||||
ClientInfo,
|
||||
TransactionRequest,
|
||||
TransactionResponse,
|
||||
} from '../model/types/bonus-client-info.type';
|
||||
|
||||
export const bonusApi = baseAPI.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
fetchMyBonusInfo: builder.query<ClientInfo, any>({
|
||||
query: () => {
|
||||
return {
|
||||
url: '/bonus/info',
|
||||
};
|
||||
},
|
||||
}),
|
||||
fetchBonusTransactions: builder.query<
|
||||
TransactionResponse,
|
||||
TransactionRequest
|
||||
>({
|
||||
query: (request) => {
|
||||
return {
|
||||
url: '/bonus/transactions',
|
||||
params: request,
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useFetchMyBonusInfoQuery, useFetchBonusTransactionsQuery } =
|
||||
bonusApi;
|
||||
@ -1,34 +0,0 @@
|
||||
export interface ClientInfo {
|
||||
card_id: number;
|
||||
fullname: string;
|
||||
cardno: string;
|
||||
reg_date: string;
|
||||
end_date: string;
|
||||
bonuses: string;
|
||||
}
|
||||
|
||||
export interface TransactionResponse {
|
||||
transactions: Transaction[];
|
||||
card_id: string;
|
||||
current_page: number;
|
||||
limit: number;
|
||||
total_records: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
id: number;
|
||||
date_create: string;
|
||||
station: string;
|
||||
product_name: string;
|
||||
amount: string;
|
||||
price_real: string;
|
||||
sum_real: string;
|
||||
}
|
||||
|
||||
export interface TransactionRequest {
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
page: number;
|
||||
limit: number;
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
import { baseAPI } from '@/shared/api/base-api';
|
||||
|
||||
import { CorporateInfoResponse } from '../model/types/corporate-client-info.type';
|
||||
|
||||
export const corporateApi = baseAPI.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
fetchMyCorporateInfo: builder.query<CorporateInfoResponse, any>({
|
||||
query: () => {
|
||||
return {
|
||||
url: '/corporate/info',
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useFetchMyCorporateInfoQuery } = corporateApi;
|
||||
@ -1,9 +0,0 @@
|
||||
export interface CorporateInfoResponse {
|
||||
created_at: string;
|
||||
fund: string;
|
||||
fund_total: string;
|
||||
group_id: number;
|
||||
group_name: string;
|
||||
overdraft: string;
|
||||
total_cards: number;
|
||||
}
|
||||
@ -19,10 +19,7 @@ import {
|
||||
} from '@/shared/shadcn-ui/form';
|
||||
import { Input } from '@/shared/shadcn-ui/input';
|
||||
|
||||
import {
|
||||
LoginFormData,
|
||||
loginFormSchema,
|
||||
} from '../../../../entities/auth/model/validation/login-form.schema';
|
||||
import { LoginFormData, loginFormSchema } from '../model/login-form.schema';
|
||||
|
||||
interface LoginFormProps {
|
||||
type: 'bonus' | 'corporate';
|
||||
@ -43,12 +40,16 @@ export const LoginForm = ({ type }: LoginFormProps) => {
|
||||
});
|
||||
|
||||
const onSubmit = async (data: LoginFormData) => {
|
||||
try {
|
||||
await login({ ...data, type }).unwrap();
|
||||
|
||||
toast.success('Logged in successfully!');
|
||||
router.push(
|
||||
type === 'bonus' ? '/customer-dashboard' : '/corporate-dashboard',
|
||||
);
|
||||
} catch (error) {
|
||||
toast.error('An error occured during login');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@ -8,14 +8,13 @@ import {
|
||||
List,
|
||||
MapPin,
|
||||
} from 'lucide-react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { Stations } from '@/app/api-utlities/@types';
|
||||
import { Stations } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Badge } from '@/shared/shadcn-ui/badge';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import { Separator } from '@/shared/shadcn-ui/separator';
|
||||
import {
|
||||
Tabs,
|
||||
TabsContent,
|
||||
@ -23,69 +22,311 @@ import {
|
||||
TabsTrigger,
|
||||
} from '@/shared/shadcn-ui/tabs';
|
||||
|
||||
import { Point } from '../model';
|
||||
import { YandexMap } from './yandex-map';
|
||||
// Sample data for gas stations
|
||||
const stations = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'АЗС Душанбе-Центр',
|
||||
address: 'ул. Рудаки 150, Душанбе',
|
||||
city: 'Душанбе',
|
||||
coordinates: { x: 0.2, y: 0.3 },
|
||||
services: ['ДТ', 'АИ-92', 'АИ-95', 'Z-100 Power', 'Минимаркет', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'АЗС Худжанд',
|
||||
address: 'ул. Ленина 45, Худжанд',
|
||||
city: 'Худжанд',
|
||||
coordinates: { x: 0.5, y: 0.2 },
|
||||
services: [
|
||||
'ДТ',
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Пропан',
|
||||
'Минимаркет',
|
||||
'Автомойка',
|
||||
'Туалет',
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'АЗС Куляб',
|
||||
address: 'ул. Сомони 78, Куляб',
|
||||
city: 'Куляб',
|
||||
coordinates: { x: 0.7, y: 0.4 },
|
||||
services: ['ДТ', 'АИ-92', 'Пропан', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'АЗС Бохтар',
|
||||
address: 'ул. Айни 23, Бохтар',
|
||||
city: 'Бохтар',
|
||||
coordinates: { x: 0.3, y: 0.6 },
|
||||
services: [
|
||||
'ДТ',
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Z-100 Power',
|
||||
'Минимаркет',
|
||||
'Зарядная станция',
|
||||
'Туалет',
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'АЗС Хорог',
|
||||
address: 'ул. Горная 12, Хорог',
|
||||
city: 'Хорог',
|
||||
coordinates: { x: 0.6, y: 0.7 },
|
||||
services: ['ДТ', 'АИ-92', 'Автомойка', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'АЗС Истаравшан',
|
||||
address: 'ул. Исмоили Сомони 34, Истаравшан',
|
||||
city: 'Истаравшан',
|
||||
coordinates: { x: 0.8, y: 0.8 },
|
||||
services: ['ДТ', 'АИ-92', 'АИ-95', 'Минимаркет', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
name: 'АЗС Пенджикент',
|
||||
address: 'ул. Рудаки 56, Пенджикент',
|
||||
city: 'Пенджикент',
|
||||
coordinates: { x: 0.1, y: 0.9 },
|
||||
services: ['ДТ', 'АИ-92', 'АИ-95', 'Пропан', 'Минимаркет', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
name: 'АЗС Душанбе-Запад',
|
||||
address: 'ул. Джами 23, Душанбе',
|
||||
city: 'Душанбе',
|
||||
coordinates: { x: 0.25, y: 0.35 },
|
||||
services: [
|
||||
'ДТ',
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Z-100 Power',
|
||||
'Пропан',
|
||||
'Минимаркет',
|
||||
'Автомойка',
|
||||
'Туалет',
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'АЗС Душанбе-Восток',
|
||||
address: 'ул. Айни 78, Душанбе',
|
||||
city: 'Душанбе',
|
||||
coordinates: { x: 0.15, y: 0.25 },
|
||||
services: [
|
||||
'ДТ',
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Зарядная станция',
|
||||
'Минимаркет',
|
||||
'Туалет',
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
name: 'АЗС Гиссар',
|
||||
address: 'ул. Центральная 12, Гиссар',
|
||||
city: 'Гиссар',
|
||||
coordinates: { x: 0.4, y: 0.4 },
|
||||
services: ['ДТ', 'АИ-92', 'Пропан', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
name: 'АЗС Вахдат',
|
||||
address: 'ул. Сомони 45, Вахдат',
|
||||
city: 'Вахдат',
|
||||
coordinates: { x: 0.55, y: 0.45 },
|
||||
services: ['ДТ', 'АИ-92', 'АИ-95', 'Минимаркет', 'Туалет'],
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
name: 'АЗС Турсунзаде',
|
||||
address: 'ул. Ленина 34, Турсунзаде',
|
||||
city: 'Турсунзаде',
|
||||
coordinates: { x: 0.65, y: 0.55 },
|
||||
services: ['ДТ', 'АИ-92', 'АИ-95', 'Z-100 Power', 'Автомойка', 'Туалет'],
|
||||
},
|
||||
];
|
||||
|
||||
// All available filters
|
||||
const allFilters = [
|
||||
'ДТ',
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Z-100 Power',
|
||||
'Пропан',
|
||||
'Зарядная станция',
|
||||
'Минимаркет',
|
||||
'Автомойка',
|
||||
'Туалет',
|
||||
];
|
||||
|
||||
// Extract unique cities from stations
|
||||
const allCities = [...new Set(stations.map((station) => station.city))].sort();
|
||||
|
||||
// Пропсы для компонента GasStationMap
|
||||
interface GasStationMapProps {
|
||||
stations: Stations;
|
||||
}
|
||||
|
||||
// Пропсы для панели фильтров
|
||||
interface FilterPanelProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
activeFilters: string[];
|
||||
activeCities: string[];
|
||||
allCities: string[];
|
||||
allFilters: string[];
|
||||
activeFilterTab: string;
|
||||
toggleFilter: (filter: string) => void;
|
||||
toggleCity: (city: string) => void;
|
||||
selectAllCities: () => void;
|
||||
setActiveFilterTab: (tab: string) => void;
|
||||
resetFilters: () => void;
|
||||
resetCities: () => void;
|
||||
t: (key: string) => string;
|
||||
}
|
||||
export default function GasStationMap({
|
||||
stations: _stations,
|
||||
}: GasStationMapProps) {
|
||||
const { t } = useTextController();
|
||||
const mapRef = useRef<HTMLDivElement>(null);
|
||||
const [activeFilters, setActiveFilters] = useState<string[]>([]);
|
||||
const [activeCities, setActiveCities] = useState<string[]>([]);
|
||||
const [filteredStations, setFilteredStations] = useState(stations);
|
||||
const [selectedStation, setSelectedStation] = useState<number | null>(null);
|
||||
const [isFilterOpen, setIsFilterOpen] = useState(false);
|
||||
const [isStationListOpen, setIsStationListOpen] = useState(false);
|
||||
const [activeFilterTab, setActiveFilterTab] = useState('cities');
|
||||
|
||||
// Пропсы для панели списка станций
|
||||
interface StationListPanelProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
stations: Stations;
|
||||
selectedStation: number | null;
|
||||
activeFilters: string[];
|
||||
activeCities: string[];
|
||||
setSelectedStation: (id: number | null) => void;
|
||||
t: (key: string) => string;
|
||||
filterToFieldMap: { [key: string]: keyof Stations[number] };
|
||||
allFilters: string[];
|
||||
resetFilters: () => void;
|
||||
resetCities: () => void;
|
||||
}
|
||||
// Toggle service filter
|
||||
const toggleFilter = (filter: string) => {
|
||||
if (activeFilters.includes(filter)) {
|
||||
setActiveFilters(activeFilters.filter((f) => f !== filter));
|
||||
} else {
|
||||
setActiveFilters([...activeFilters, filter]);
|
||||
}
|
||||
};
|
||||
|
||||
// Toggle city filter
|
||||
const toggleCity = (city: string) => {
|
||||
if (activeCities.includes(city)) {
|
||||
setActiveCities(activeCities.filter((c) => c !== city));
|
||||
} else {
|
||||
setActiveCities([...activeCities, city]);
|
||||
}
|
||||
};
|
||||
|
||||
// Select all cities
|
||||
const selectAllCities = () => {
|
||||
if (activeCities.length === allCities.length) {
|
||||
setActiveCities([]);
|
||||
} else {
|
||||
setActiveCities([...allCities]);
|
||||
}
|
||||
};
|
||||
|
||||
// Filter stations based on active filters and cities
|
||||
useEffect(() => {
|
||||
let filtered = stations;
|
||||
|
||||
// Filter by services
|
||||
if (activeFilters.length > 0) {
|
||||
filtered = filtered.filter((station) =>
|
||||
activeFilters.every((filter) => station.services.includes(filter)),
|
||||
);
|
||||
}
|
||||
|
||||
// Filter by cities
|
||||
if (activeCities.length > 0) {
|
||||
filtered = filtered.filter((station) =>
|
||||
activeCities.includes(station.city),
|
||||
);
|
||||
}
|
||||
|
||||
setFilteredStations(filtered);
|
||||
}, [activeFilters, activeCities]);
|
||||
|
||||
useEffect(() => {
|
||||
// This is a placeholder for a real map implementation
|
||||
// In a real application, you would use a mapping library like Mapbox, Google Maps, or Leaflet
|
||||
if (mapRef.current) {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = mapRef.current.clientWidth;
|
||||
canvas.height = mapRef.current.clientHeight;
|
||||
mapRef.current.appendChild(canvas);
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx) {
|
||||
// Draw a simple map placeholder
|
||||
ctx.fillStyle = '#f3f4f6';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Draw some roads
|
||||
ctx.strokeStyle = '#d1d5db';
|
||||
ctx.lineWidth = 5;
|
||||
|
||||
// Horizontal roads
|
||||
for (let i = 1; i < 5; i++) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, canvas.height * (i / 5));
|
||||
ctx.lineTo(canvas.width, canvas.height * (i / 5));
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Vertical roads
|
||||
for (let i = 1; i < 8; i++) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(canvas.width * (i / 8), 0);
|
||||
ctx.lineTo(canvas.width * (i / 8), canvas.height);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
// Draw gas station markers
|
||||
filteredStations.forEach((station) => {
|
||||
const isSelected = selectedStation === station.id;
|
||||
// Draw marker
|
||||
ctx.fillStyle = isSelected ? '#3b82f6' : '#ef4444';
|
||||
ctx.beginPath();
|
||||
ctx.arc(
|
||||
station.coordinates.x * canvas.width,
|
||||
station.coordinates.y * canvas.height,
|
||||
isSelected ? 12 : 10,
|
||||
0,
|
||||
2 * Math.PI,
|
||||
);
|
||||
ctx.fill();
|
||||
|
||||
// Draw white border
|
||||
ctx.strokeStyle = 'white';
|
||||
ctx.lineWidth = 2;
|
||||
ctx.beginPath();
|
||||
ctx.arc(
|
||||
station.coordinates.x * canvas.width,
|
||||
station.coordinates.y * canvas.height,
|
||||
isSelected ? 12 : 10,
|
||||
0,
|
||||
2 * Math.PI,
|
||||
);
|
||||
ctx.stroke();
|
||||
});
|
||||
|
||||
// Add city names
|
||||
ctx.fillStyle = '#1f2937';
|
||||
ctx.font = 'bold 16px Arial';
|
||||
ctx.fillText('Душанбе', canvas.width * 0.45, canvas.height * 0.15);
|
||||
ctx.fillText('Худжанд', canvas.width * 0.2, canvas.height * 0.25);
|
||||
ctx.fillText('Куляб', canvas.width * 0.7, canvas.height * 0.35);
|
||||
ctx.fillText('Бохтар', canvas.width * 0.3, canvas.height * 0.55);
|
||||
ctx.fillText('Хорог', canvas.width * 0.6, canvas.height * 0.65);
|
||||
ctx.fillText('Истаравшан', canvas.width * 0.8, canvas.height * 0.75);
|
||||
ctx.fillText('Пенджикент', canvas.width * 0.1, canvas.height * 0.85);
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (mapRef.current) {
|
||||
while (mapRef.current.firstChild) {
|
||||
mapRef.current.removeChild(mapRef.current.firstChild);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [filteredStations, selectedStation]);
|
||||
|
||||
// Компонент панели фильтров
|
||||
function FilterPanel({
|
||||
isOpen,
|
||||
onClose,
|
||||
activeFilters,
|
||||
activeCities,
|
||||
allCities,
|
||||
allFilters,
|
||||
activeFilterTab,
|
||||
toggleFilter,
|
||||
toggleCity,
|
||||
selectAllCities,
|
||||
setActiveFilterTab,
|
||||
resetFilters,
|
||||
resetCities,
|
||||
t,
|
||||
}: FilterPanelProps) {
|
||||
return (
|
||||
<div className='relative h-full w-full'>
|
||||
{/* Filter panel - slides from left */}
|
||||
<div
|
||||
className={`absolute top-0 bottom-0 left-0 z-20 transform bg-white shadow-lg transition-transform duration-300 ${
|
||||
isOpen ? 'translate-x-0' : '-translate-x-full'
|
||||
isFilterOpen ? 'translate-x-0' : '-translate-x-full'
|
||||
}`}
|
||||
style={{ width: '300px' }}
|
||||
>
|
||||
@ -94,7 +335,11 @@ function FilterPanel({
|
||||
<Filter className='h-5 w-5 text-red-600' />
|
||||
<span className='font-medium'>{t('map.filters')}</span>
|
||||
</div>
|
||||
<Button variant='ghost' size='sm' onClick={onClose}>
|
||||
<Button
|
||||
variant='ghost'
|
||||
size='sm'
|
||||
onClick={() => setIsFilterOpen(false)}
|
||||
>
|
||||
<ChevronLeft className='h-5 w-5' />
|
||||
</Button>
|
||||
</div>
|
||||
@ -110,10 +355,7 @@ function FilterPanel({
|
||||
<TabsTrigger value='services'>{t('map.services')}</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
<TabsContent
|
||||
value='cities'
|
||||
className='mt-0 max-h-[300px] overflow-y-auto py-2 pr-1'
|
||||
>
|
||||
<TabsContent value='cities' className='mt-0'>
|
||||
<Button
|
||||
variant='outline'
|
||||
size='sm'
|
||||
@ -130,13 +372,11 @@ function FilterPanel({
|
||||
{allCities.map((city) => (
|
||||
<Button
|
||||
key={city}
|
||||
variant={activeCities.includes(city) ? 'default' : 'outline'}
|
||||
variant={
|
||||
activeCities.includes(city) ? 'default' : 'outline'
|
||||
}
|
||||
size='sm'
|
||||
className={`justify-between ${
|
||||
activeCities.includes(city)
|
||||
? 'bg-red-600 hover:bg-red-700'
|
||||
: ''
|
||||
}`}
|
||||
className={`justify-between ${activeCities.includes(city) ? 'bg-red-600 hover:bg-red-700' : ''}`}
|
||||
onClick={() => toggleCity(city)}
|
||||
>
|
||||
<span>{city}</span>
|
||||
@ -146,6 +386,16 @@ function FilterPanel({
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{activeCities.length > 0 && (
|
||||
<Button
|
||||
variant='link'
|
||||
className='mt-4 p-0 text-red-600'
|
||||
onClick={() => setActiveCities([])}
|
||||
>
|
||||
{t('common.buttons.resetFilters')}
|
||||
</Button>
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value='services' className='mt-0'>
|
||||
@ -168,76 +418,47 @@ function FilterPanel({
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</TabsContent>
|
||||
|
||||
<Separator className='mt-2' />
|
||||
|
||||
{/* Кнопка сброса фильтров */}
|
||||
{activeFilterTab === 'cities'
|
||||
? activeCities.length > 0 && (
|
||||
<Button
|
||||
variant='link'
|
||||
className='p-0 text-red-600'
|
||||
onClick={resetCities}
|
||||
>
|
||||
{t('common.buttons.resetFilters')}
|
||||
</Button>
|
||||
)
|
||||
: activeFilters.length > 0 && (
|
||||
{activeFilters.length > 0 && (
|
||||
<Button
|
||||
variant='link'
|
||||
className='mt-4 p-0 text-red-600'
|
||||
onClick={resetFilters}
|
||||
onClick={() => setActiveFilters([])}
|
||||
>
|
||||
{t('common.buttons.resetFilters')}
|
||||
</Button>
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Компонент панели списка станций
|
||||
function StationListPanel({
|
||||
isOpen,
|
||||
onClose,
|
||||
stations,
|
||||
selectedStation,
|
||||
activeFilters,
|
||||
activeCities,
|
||||
setSelectedStation,
|
||||
t,
|
||||
filterToFieldMap,
|
||||
allFilters,
|
||||
resetCities,
|
||||
resetFilters,
|
||||
}: StationListPanelProps) {
|
||||
return (
|
||||
{/* Station list panel - slides from right */}
|
||||
<div
|
||||
className={`absolute top-0 right-0 bottom-0 z-20 transform bg-white shadow-lg transition-transform duration-300 ${
|
||||
isOpen ? 'translate-x-0' : 'translate-x-full'
|
||||
isStationListOpen ? 'translate-x-0' : 'translate-x-full'
|
||||
}`}
|
||||
style={{ width: '350px' }}
|
||||
>
|
||||
<div className='flex items-center justify-between border-b border-gray-200 p-4'>
|
||||
<Button variant='ghost' size='sm' onClick={onClose}>
|
||||
<Button
|
||||
variant='ghost'
|
||||
size='sm'
|
||||
onClick={() => setIsStationListOpen(false)}
|
||||
>
|
||||
<ChevronRight className='h-5 w-5' />
|
||||
</Button>
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='font-medium'>{t('map.stationsList')}</span>
|
||||
<Badge>{stations.length}</Badge>
|
||||
<Badge>{filteredStations.length}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div className='overflow-y-auto' style={{ height: 'calc(100% - 60px)' }}>
|
||||
{stations.length > 0 ? (
|
||||
<div
|
||||
className='overflow-y-auto'
|
||||
style={{ height: 'calc(100% - 60px)' }}
|
||||
>
|
||||
{filteredStations.length > 0 ? (
|
||||
<div className='p-2'>
|
||||
{stations.map((station) => {
|
||||
const services = allFilters.filter(
|
||||
(filter) => station[filterToFieldMap[filter]],
|
||||
);
|
||||
|
||||
return (
|
||||
{filteredStations.map((station) => (
|
||||
<div
|
||||
key={station.id}
|
||||
className={`mb-2 cursor-pointer rounded-lg border p-3 transition-colors ${
|
||||
@ -254,23 +475,11 @@ function StationListPanel({
|
||||
<p className='mb-2 text-sm text-gray-500'>
|
||||
{station.address}
|
||||
</p>
|
||||
{station.workingHours && (
|
||||
<p className='mb-2 text-sm text-gray-500'>
|
||||
{t('map.workingHours')}: {station.workingHours}
|
||||
</p>
|
||||
)}
|
||||
{station.description && (
|
||||
<p className='mb-2 text-sm text-gray-500'>
|
||||
{station.description}
|
||||
</p>
|
||||
)}
|
||||
<div className='flex flex-wrap gap-1'>
|
||||
{station.region && (
|
||||
<Badge className='mb-1 border-blue-200 bg-blue-100 text-blue-800'>
|
||||
{station.region}
|
||||
{station.city}
|
||||
</Badge>
|
||||
)}
|
||||
{services.map((service) => (
|
||||
{station.services.map((service) => (
|
||||
<Badge
|
||||
key={service}
|
||||
variant='outline'
|
||||
@ -284,16 +493,8 @@ function StationListPanel({
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
{station.image && (
|
||||
<img
|
||||
src={station.image}
|
||||
alt={station.name}
|
||||
className='mt-2 h-20 w-full rounded object-cover'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className='p-4 text-center text-gray-500'>
|
||||
@ -303,7 +504,7 @@ function StationListPanel({
|
||||
<Button
|
||||
variant='link'
|
||||
className='text-red-600'
|
||||
onClick={resetFilters}
|
||||
onClick={() => setActiveFilters([])}
|
||||
>
|
||||
{t('common.buttons.resetFilters')}
|
||||
</Button>
|
||||
@ -312,7 +513,7 @@ function StationListPanel({
|
||||
<Button
|
||||
variant='link'
|
||||
className='text-red-600'
|
||||
onClick={resetCities}
|
||||
onClick={() => setActiveCities([])}
|
||||
>
|
||||
{t('map.allCities')}
|
||||
</Button>
|
||||
@ -322,160 +523,10 @@ function StationListPanel({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Главный компонент
|
||||
export default function GasStationMap({ stations }: GasStationMapProps) {
|
||||
const { t } = useTextController();
|
||||
const [activeFilters, setActiveFilters] = useState<string[]>([]);
|
||||
const [activeCities, setActiveCities] = useState<string[]>([]);
|
||||
const [selectedStation, setSelectedStation] = useState<number | null>(null);
|
||||
const [isFilterOpen, setIsFilterOpen] = useState(false);
|
||||
const [isStationListOpen, setIsStationListOpen] = useState(false);
|
||||
const [activeFilterTab, setActiveFilterTab] = useState('cities');
|
||||
|
||||
// Все доступные фильтры
|
||||
const allFilters = [
|
||||
// 'ДТ', -> нет значения в интерфейсе - TODO: поправить
|
||||
'АИ-92',
|
||||
'АИ-95',
|
||||
'Z-100 Power',
|
||||
'Пропан',
|
||||
'Зарядная станция',
|
||||
'Минимаркет',
|
||||
'Автомойка',
|
||||
'Туалет',
|
||||
];
|
||||
|
||||
// Маппинг фильтров на поля Station
|
||||
const filterToFieldMap: { [key: string]: keyof Stations[number] } = {
|
||||
'АИ-92': 'ai92',
|
||||
'АИ-95': 'ai95',
|
||||
'Z-100 Power': 'z100',
|
||||
Пропан: 'propan',
|
||||
'Зарядная станция': 'electricCharge',
|
||||
Минимаркет: 'miniMarket',
|
||||
Автомойка: 'carWash',
|
||||
Туалет: 'toilet',
|
||||
};
|
||||
|
||||
// Мемоизация списка уникальных регионов
|
||||
const allCities = useMemo(() => {
|
||||
return [
|
||||
...new Set(
|
||||
stations
|
||||
.map((station) => station.region)
|
||||
.filter((region): region is string => region !== null),
|
||||
),
|
||||
].sort();
|
||||
}, [stations]);
|
||||
|
||||
// Мемоизация фильтрованных станций
|
||||
const filteredStations = useMemo(() => {
|
||||
let filtered = stations;
|
||||
|
||||
// Фильтрация по регионам (ИЛИ)
|
||||
if (activeCities.length > 0) {
|
||||
filtered = filtered.filter(
|
||||
(station) => station.region && activeCities.includes(station.region),
|
||||
);
|
||||
}
|
||||
|
||||
// Фильтрация по услугам (И)
|
||||
if (activeFilters.length > 0) {
|
||||
filtered = filtered.filter((station) =>
|
||||
activeFilters.every((filter) => {
|
||||
const field = filterToFieldMap[filter];
|
||||
return Boolean(station[field]) === true;
|
||||
}),
|
||||
);
|
||||
}
|
||||
return filtered;
|
||||
}, [activeFilters, activeCities, stations]);
|
||||
|
||||
// Мемоизация точек для карты
|
||||
const points = useMemo(
|
||||
(): Point[] =>
|
||||
filteredStations.map((st) => ({
|
||||
id: st.id,
|
||||
coordinates: [st.latitude, st.longitude],
|
||||
})),
|
||||
[filteredStations],
|
||||
);
|
||||
|
||||
// Переключение фильтра услуг
|
||||
const toggleFilter = (filter: string) => {
|
||||
setActiveFilters((prev) =>
|
||||
prev.includes(filter)
|
||||
? prev.filter((f) => f !== filter)
|
||||
: [...prev, filter],
|
||||
);
|
||||
};
|
||||
|
||||
// Переключение фильтра региона
|
||||
const toggleCity = (city: string) => {
|
||||
setActiveCities((prev) =>
|
||||
prev.includes(city) ? prev.filter((c) => c !== city) : [...prev, city],
|
||||
);
|
||||
};
|
||||
|
||||
// Выбор всех регионов
|
||||
const selectAllCities = () => {
|
||||
setActiveCities(
|
||||
activeCities.length === allCities.length ? [] : [...allCities],
|
||||
);
|
||||
};
|
||||
|
||||
// Сброс фильтров услуг
|
||||
const resetFilters = () => {
|
||||
setActiveFilters([]);
|
||||
};
|
||||
|
||||
// Сброс фильтров регионов
|
||||
const resetCities = () => {
|
||||
setActiveCities([]);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='relative h-full w-full'>
|
||||
{/* Filter panel */}
|
||||
<FilterPanel
|
||||
isOpen={isFilterOpen}
|
||||
onClose={() => setIsFilterOpen(false)}
|
||||
activeFilters={activeFilters}
|
||||
activeCities={activeCities}
|
||||
allCities={allCities}
|
||||
allFilters={allFilters}
|
||||
activeFilterTab={activeFilterTab}
|
||||
toggleFilter={toggleFilter}
|
||||
toggleCity={toggleCity}
|
||||
selectAllCities={selectAllCities}
|
||||
setActiveFilterTab={setActiveFilterTab}
|
||||
resetFilters={resetFilters}
|
||||
resetCities={resetCities}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
{/* Station list panel */}
|
||||
<StationListPanel
|
||||
isOpen={isStationListOpen}
|
||||
onClose={() => setIsStationListOpen(false)}
|
||||
stations={filteredStations}
|
||||
selectedStation={selectedStation}
|
||||
activeFilters={activeFilters}
|
||||
activeCities={activeCities}
|
||||
setSelectedStation={setSelectedStation}
|
||||
t={t}
|
||||
filterToFieldMap={filterToFieldMap}
|
||||
allFilters={allFilters}
|
||||
resetFilters={resetFilters}
|
||||
resetCities={resetCities}
|
||||
/>
|
||||
|
||||
{/* Map */}
|
||||
<div className='h-full w-full'>
|
||||
<YandexMap points={points} />
|
||||
<div ref={mapRef} className='h-full w-full'></div>
|
||||
</div>
|
||||
|
||||
{/* Control buttons */}
|
||||
@ -517,7 +568,7 @@ export default function GasStationMap({ stations }: GasStationMapProps) {
|
||||
<span>{t('map.ourStations')}</span>
|
||||
</div>
|
||||
<p className='mt-1 text-xs text-gray-500'>
|
||||
{t('map.totalStations')}: {filteredStations.length}
|
||||
{t('map.totalStations')}: {stations.length}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { Map, Placemark, YMaps } from '@pbe/react-yandex-maps';
|
||||
import React from 'react';
|
||||
|
||||
import { Point } from '../model';
|
||||
|
||||
@ -9,43 +8,29 @@ type YandexMapProps = {
|
||||
points: Point[];
|
||||
};
|
||||
|
||||
const mapCenter = [55.751574, 37.573856];
|
||||
|
||||
export const YandexMap = ({ points }: YandexMapProps) => {
|
||||
return (
|
||||
<YMaps
|
||||
query={{
|
||||
apikey: process.env.NEXT_PUBLIC_YANDEX_MAP_API_KEY,
|
||||
lang: 'ru_RU',
|
||||
// load: 'geoObject.addon.balloon',
|
||||
}}
|
||||
>
|
||||
<Map
|
||||
defaultState={{
|
||||
center: points[0].coordinates || mapCenter,
|
||||
center: points[0].coordinates || [55.751574, 37.573856], // центр карты,
|
||||
zoom: 11,
|
||||
behaviors: ['drag', 'multiTouch', 'dblClickZoom', 'scrollZoom'],
|
||||
}}
|
||||
className='rounded-md shadow-lg'
|
||||
options={{
|
||||
copyrightUaVisible: false,
|
||||
copyrightProvidersVisible: false,
|
||||
copyrightLogoVisible: false,
|
||||
suppressMapOpenBlock: true,
|
||||
suppressObsoleteBrowserNotifier: true,
|
||||
}}
|
||||
className='h-full max-h-[500px] w-full overflow-hidden rounded-md shadow-lg'
|
||||
width={'100%'}
|
||||
height={'500px'}
|
||||
>
|
||||
{points.map((point) => (
|
||||
<Placemark
|
||||
key={point.id}
|
||||
geometry={point.coordinates}
|
||||
options={{
|
||||
iconLayout: 'default#image',
|
||||
iconImageHref: '/map/oriyo-marker.png',
|
||||
iconImageSize: [64, 64],
|
||||
iconImageOffset: [-24, -36],
|
||||
}}
|
||||
/>
|
||||
<Placemark key={point.id} geometry={point.coordinates} />
|
||||
))}
|
||||
</Map>
|
||||
</YMaps>
|
||||
|
||||
@ -1,59 +0,0 @@
|
||||
import { jsonToGraphQLQuery } from 'json-to-graphql-query';
|
||||
|
||||
import { AboutUsPageData } from '@/app/api-utlities/@types/about-us';
|
||||
import { MainPageData } from '@/app/api-utlities/@types/main';
|
||||
import {
|
||||
presentDiscounts,
|
||||
presentHistoryItems,
|
||||
presentJobs,
|
||||
presentPartners,
|
||||
presentReviews,
|
||||
presentStations,
|
||||
presentTeamMembers,
|
||||
} from '@/app/api-utlities/presenters';
|
||||
import { aboutUsPageRequest } from '@/app/api-utlities/requests/about-us-page.request';
|
||||
import { mainPageRequest } from '@/app/api-utlities/requests/main-page.request';
|
||||
|
||||
import { taylorAPI } from '@/shared/api/taylor-api';
|
||||
|
||||
export const mainPageApi = taylorAPI.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
fetchMainPageContent: builder.query<MainPageData, void>({
|
||||
query: () => ({
|
||||
url: '',
|
||||
method: 'POST',
|
||||
body: {
|
||||
query: jsonToGraphQLQuery({ query: mainPageRequest }),
|
||||
},
|
||||
}),
|
||||
|
||||
transformResponse: (response: any) => {
|
||||
return {
|
||||
partners: presentPartners(response.data._partners),
|
||||
jobs: presentJobs(response.data._vacancies),
|
||||
discounts: presentDiscounts(response.data._akcii),
|
||||
stations: presentStations(response.data._azs),
|
||||
};
|
||||
},
|
||||
}),
|
||||
|
||||
fetchAboutUsPageContent: builder.mutation<AboutUsPageData, void>({
|
||||
query: () => ({
|
||||
url: '',
|
||||
method: 'POST',
|
||||
body: {
|
||||
query: jsonToGraphQLQuery({ query: aboutUsPageRequest }),
|
||||
},
|
||||
}),
|
||||
|
||||
transformResponse: (response: any) => {
|
||||
return {
|
||||
team: presentTeamMembers(response.data._komanda),
|
||||
history: presentHistoryItems(response.data._istoriya),
|
||||
stations: presentStations(response.data._azs),
|
||||
reviews: presentReviews(response.data._otzyvy),
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
@ -4,8 +4,6 @@ import { subMonths } from 'date-fns';
|
||||
import { Building2, LogOut, Wallet } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { useFetchMyCorporateInfoQuery } from '@/entities/corporate/api/corporate.api';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
@ -98,10 +96,8 @@ export function CorporateDashboard() {
|
||||
|
||||
const { t } = useTextController();
|
||||
|
||||
const { data, isLoading } = useFetchMyCorporateInfoQuery({});
|
||||
|
||||
return (
|
||||
<div className='flex min-h-screen flex-col px-2.5'>
|
||||
<div className='flex min-h-screen flex-col'>
|
||||
<main className='flex-1 py-10'>
|
||||
<div className='container mx-auto max-w-6xl'>
|
||||
<div className='mb-8 flex items-center justify-between'>
|
||||
@ -114,11 +110,7 @@ export function CorporateDashboard() {
|
||||
|
||||
<div className='mb-10 grid gap-3 md:grid-cols-3 md:gap-6'>
|
||||
{/* Company Card */}
|
||||
<Card
|
||||
data-aos='zoom-in'
|
||||
data-aos-mirror='true'
|
||||
className='md:col-span-2'
|
||||
>
|
||||
<Card className='md:col-span-2'>
|
||||
<CardHeader className='pb-2'>
|
||||
<CardTitle className='flex items-center gap-2'>
|
||||
<Building2 className='h-5 w-5 text-red-600' />
|
||||
@ -126,34 +118,26 @@ export function CorporateDashboard() {
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!data ? (
|
||||
<>Loading</>
|
||||
) : (
|
||||
<div className='grid gap-6 md:grid-cols-2'>
|
||||
<div>
|
||||
<div className='mb-4 space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('corporate.companyCard.companyNameLabel')}
|
||||
</p>
|
||||
<p className='truncate font-medium'>
|
||||
{data.group_name}
|
||||
</p>
|
||||
<p className='font-medium'>{companyData.companyName}</p>
|
||||
</div>
|
||||
<div className='mb-4 space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('corporate.companyCard.cardsCountLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>{data.total_cards}</p>
|
||||
<p className='font-medium'>{companyData.numberOfCards}</p>
|
||||
</div>
|
||||
<div className='space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('corporate.companyCard.registrationDateLabel')}
|
||||
</p>
|
||||
|
||||
<p className='font-medium'>
|
||||
{new Date(data.created_at).toLocaleDateString(
|
||||
'en-GB',
|
||||
)}
|
||||
{companyData.registrationDate}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -163,7 +147,8 @@ export function CorporateDashboard() {
|
||||
{t('corporate.companyCard.fundLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>
|
||||
{data.fund.toLocaleString()} {t('corporate.currency')}
|
||||
{companyData.fund.toLocaleString()}{' '}
|
||||
{t('corporate.currency')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='mb-4 space-y-1'>
|
||||
@ -171,22 +156,17 @@ export function CorporateDashboard() {
|
||||
{t('corporate.companyCard.overdraftLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>
|
||||
{data.overdraft.toLocaleString()}{' '}
|
||||
{companyData.overdraft.toLocaleString()}{' '}
|
||||
{t('corporate.currency')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Fund Card */}
|
||||
<Card
|
||||
data-aos='zoom-in'
|
||||
data-aos-mirror='true'
|
||||
className='bg-gradient-to-br from-red-600 to-red-800 text-white'
|
||||
>
|
||||
<Card className='bg-gradient-to-br from-red-600 to-red-800 text-white'>
|
||||
<CardHeader>
|
||||
<CardTitle className='flex items-center gap-2'>
|
||||
<Wallet className='h-5 w-5' />
|
||||
@ -197,18 +177,14 @@ export function CorporateDashboard() {
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!data ? (
|
||||
<>Loading</>
|
||||
) : (
|
||||
<div className='text-center'>
|
||||
<p className='mb-2 text-4xl font-bold'>
|
||||
{data.fund_total?.toLocaleString()}
|
||||
{companyData.totalFund.toLocaleString()}
|
||||
</p>
|
||||
<p className='text-white/80'>
|
||||
{t('corporate.fundCard.currency')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
import { ArrowUpRight, Clock, CreditCard, LogOut, User } from 'lucide-react';
|
||||
|
||||
import { useFetchMyBonusInfoQuery } from '@/entities/bonus/api/bonus.api';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
@ -16,13 +14,22 @@ import {
|
||||
|
||||
import { TransactionsTable } from '@/widgets/transactions-table';
|
||||
|
||||
// Sample customer data
|
||||
const customerData = {
|
||||
firstName: 'Алишер',
|
||||
lastName: 'Рахмонов',
|
||||
passportNumber: 'A12345678',
|
||||
bonusPoints: 1250,
|
||||
cardNumber: '5678-9012-3456-7890',
|
||||
expiryDate: '12/2025',
|
||||
registrationDate: '15.06.2020',
|
||||
};
|
||||
|
||||
export function CustomerDashboard() {
|
||||
const { t } = useTextController();
|
||||
|
||||
const { data, isLoading } = useFetchMyBonusInfoQuery({});
|
||||
|
||||
return (
|
||||
<div className='flex min-h-screen flex-col px-2.5'>
|
||||
<div className='flex min-h-screen flex-col'>
|
||||
<main className='flex-1 py-10'>
|
||||
<div className='container mx-auto max-w-6xl'>
|
||||
<div className='mb-8 flex items-center justify-between'>
|
||||
@ -34,12 +41,8 @@ export function CustomerDashboard() {
|
||||
</div>
|
||||
|
||||
<div className='mb-10 grid gap-3 md:grid-cols-3 md:gap-6'>
|
||||
<Card data-aos="zoom-in" data-aos-mirror="true" className='bg-gradient-to-br from-red-600 to-red-800 text-white'>
|
||||
{!data || isLoading ? (
|
||||
// TODO: Bunyod please add loader here
|
||||
<>Loader here</>
|
||||
) : (
|
||||
<>
|
||||
{/* Bonus Card */}
|
||||
<Card className='bg-gradient-to-br from-red-600 to-red-800 text-white'>
|
||||
<CardHeader>
|
||||
<CardTitle className='flex items-center gap-2'>
|
||||
<CreditCard className='h-5 w-5' />
|
||||
@ -51,7 +54,9 @@ export function CustomerDashboard() {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className='text-center'>
|
||||
<p className='mb-2 text-4xl font-bold'>{data.bonuses}</p>
|
||||
<p className='mb-2 text-4xl font-bold'>
|
||||
{customerData.bonusPoints}
|
||||
</p>
|
||||
<p className='text-white/80'>
|
||||
{t('customer.bonusCard.points')}
|
||||
</p>
|
||||
@ -59,21 +64,14 @@ export function CustomerDashboard() {
|
||||
<div className='mt-6 flex items-center justify-between'>
|
||||
<div className='flex items-center gap-1 text-sm text-white/80'>
|
||||
<Clock className='h-4 w-4' />
|
||||
<span>
|
||||
{t('customer.bonusCard.validUntil')}{' '}
|
||||
{new Date(data.end_date).toLocaleDateString('en-GB')}
|
||||
</span>
|
||||
<span>{t('customer.bonusCard.validUntil')}</span>
|
||||
</div>
|
||||
<ArrowUpRight className='h-5 w-5 text-white/60' />
|
||||
</div>
|
||||
</CardContent>
|
||||
</>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{/* Bonus Card */}
|
||||
{/* Customer Card */}
|
||||
<Card data-aos="zoom-in" data-aos-mirror="true" className='md:col-span-2'>
|
||||
<Card className='md:col-span-2'>
|
||||
<CardHeader className='pb-2'>
|
||||
<CardTitle className='flex items-center gap-2'>
|
||||
<User className='h-5 w-5 text-red-600' />
|
||||
@ -81,24 +79,22 @@ export function CustomerDashboard() {
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{!data || isLoading ? (
|
||||
// TODO: Bunyod please add loader here
|
||||
<>Loader here</>
|
||||
) : (
|
||||
<div className='grid gap-6 md:grid-cols-2'>
|
||||
<div>
|
||||
<div className='mb-4 space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('customer.infoCard.regDateLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>{data.fullname}</p>
|
||||
<p className='font-medium'>
|
||||
{customerData.firstName} {customerData.lastName}
|
||||
</p>
|
||||
</div>
|
||||
<div className='space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('customer.infoCard.regDateLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>
|
||||
{new Date(data.reg_date).toLocaleDateString('en-GB')}
|
||||
{customerData.registrationDate}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@ -107,11 +103,16 @@ export function CustomerDashboard() {
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('customer.infoCard.cardNumberLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>{data.cardno}</p>
|
||||
<p className='font-medium'>{customerData.cardNumber}</p>
|
||||
</div>
|
||||
<div className='mb-4 space-y-1'>
|
||||
<p className='text-sm text-gray-500'>
|
||||
{t('customer.infoCard.expiryDateLabel')}
|
||||
</p>
|
||||
<p className='font-medium'>{customerData.expiryDate}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
@ -3,13 +3,12 @@
|
||||
import { Fuel, History, MapPin, Star, Target, Users } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
|
||||
import { AboutUsPageData } from '@/app/api-utlities/@types/about-us';
|
||||
// import { useTranslation } from 'next-i18next';
|
||||
|
||||
import AnimatedCounter from '@/shared/components/animated-counter';
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import { Card, CardContent } from '@/shared/shadcn-ui/card';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
import { CompanyTimeline } from '@/widgets/about-page/company-timeline';
|
||||
import { StationGallery } from '@/widgets/about-page/station-gallery';
|
||||
@ -20,11 +19,7 @@ export const metadata = {
|
||||
description: 'about.metadata.description',
|
||||
};
|
||||
|
||||
export interface AboutPageProps {
|
||||
content: AboutUsPageData;
|
||||
}
|
||||
|
||||
export default function AboutPage({ content }: AboutPageProps) {
|
||||
export default function AboutPage() {
|
||||
const { t } = useTextController();
|
||||
|
||||
return (
|
||||
@ -41,12 +36,8 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
className='object-cover'
|
||||
priority
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center bg-gradient-to-r from-black/70 to-black/30 px-2'>
|
||||
<div
|
||||
data-aos='fade-down'
|
||||
data-aos-duration='1000'
|
||||
className='container mx-auto'
|
||||
>
|
||||
<div className='absolute inset-0 flex items-center bg-gradient-to-r from-black/70 to-black/30'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='max-w-2xl space-y-4 text-white'>
|
||||
<h1 className='text-4xl font-bold tracking-tight sm:text-5xl md:text-6xl'>
|
||||
{t('about.hero.title')}
|
||||
@ -61,11 +52,10 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</section>
|
||||
|
||||
{/* Company Overview */}
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='grid items-center gap-12 md:grid-cols-2'>
|
||||
<div data-aos='fade-right'>
|
||||
<div>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<Fuel className='h-6 w-6 text-red-600' />
|
||||
</div>
|
||||
@ -82,7 +72,7 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
{t('about.overview.description3')}
|
||||
</p>
|
||||
|
||||
<div className='mb-6 grid grid-cols-1 gap-4 md:grid-cols-2'>
|
||||
<div className='mb-6 grid grid-cols-2 gap-4'>
|
||||
{[0, 1, 2, 3].map((index) => (
|
||||
<div key={index} className='flex items-start'>
|
||||
<div className='mt-1 flex h-6 w-6 flex-shrink-0 items-center justify-center rounded-full bg-red-600'>
|
||||
@ -100,10 +90,7 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
data-aos='zoom-out-right'
|
||||
className='relative h-[500px] overflow-hidden rounded-xl shadow-xl'
|
||||
>
|
||||
<div className='relative h-[500px] overflow-hidden rounded-xl shadow-xl'>
|
||||
<Image
|
||||
src='/placeholder.svg?height=500&width=600&text=Главный+офис'
|
||||
alt={t('about.overview.imageAlt')}
|
||||
@ -114,7 +101,6 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* Stats Section */}
|
||||
<section className='bg-red-600 py-16 text-white'>
|
||||
@ -127,7 +113,7 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
{t('about.stats.subtitle')}
|
||||
</p>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-8 text-center sm:grid-cols-2 md:grid-cols-4'>
|
||||
<div className='grid grid-cols-2 gap-8 text-center md:grid-cols-4'>
|
||||
{[0, 1, 2, 3].map((index) => (
|
||||
<div key={index} className='space-y-2'>
|
||||
<h3 className='text-4xl font-bold'>
|
||||
@ -153,7 +139,6 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
{/* Our History */}
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<Container>
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<History className='h-6 w-6 text-red-600' />
|
||||
@ -165,16 +150,12 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
{t('about.history.subtitle')}
|
||||
</p>
|
||||
</div>
|
||||
</Container>
|
||||
|
||||
<Container>
|
||||
<CompanyTimeline timeline={content.history} />
|
||||
</Container>
|
||||
<CompanyTimeline />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Our Stations */}
|
||||
<Container>
|
||||
<section className='bg-gray-50 py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
@ -189,7 +170,7 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<StationGallery stations={content.stations} />
|
||||
<StationGallery />
|
||||
|
||||
<div className='mt-12 text-center'>
|
||||
<p className='mx-auto mb-6 max-w-2xl text-gray-600'>
|
||||
@ -202,10 +183,8 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* Our Values */}
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
@ -220,11 +199,7 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
data-aos='flip-up'
|
||||
data-aos-duration='600'
|
||||
className='grid gap-8 md:grid-cols-3'
|
||||
>
|
||||
<div className='grid gap-8 md:grid-cols-3'>
|
||||
{[0, 1, 2].map((index) => (
|
||||
<Card
|
||||
key={index}
|
||||
@ -246,10 +221,8 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* Our Team */}
|
||||
<Container>
|
||||
<section className='bg-gray-50 py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
@ -264,39 +237,35 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
data-aos='flip-down'
|
||||
data-aos-duration='600'
|
||||
className='grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-4'
|
||||
>
|
||||
{content.team.map((member, index) => (
|
||||
<div className='grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-4'>
|
||||
{[0, 1, 2, 3].map((index) => (
|
||||
<div
|
||||
key={index}
|
||||
className='overflow-hidden rounded-lg bg-white shadow-md transition-transform hover:scale-105'
|
||||
>
|
||||
<div className='relative h-64 w-full'>
|
||||
{member.photo && (
|
||||
<Image
|
||||
src={member.photo}
|
||||
src={`/placeholder.svg?height=300&width=300&text=${t(`about.team.members.${index}.name`)}`}
|
||||
alt={t(`about.team.members.${index}.name`)}
|
||||
fill
|
||||
className='object-cover'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className='p-4 text-center'>
|
||||
<h3 className='text-lg font-bold'>{member.name}</h3>
|
||||
<p className='text-gray-600'>{member.profession}</p>
|
||||
<h3 className='text-lg font-bold'>
|
||||
{t(`about.team.members.${index}.name`)}
|
||||
</h3>
|
||||
<p className='text-gray-600'>
|
||||
{t(`about.team.members.${index}.position`)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* Testimonials */}
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
@ -311,11 +280,8 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div
|
||||
data-aos='zoom-out-right'
|
||||
className='grid gap-8 md:grid-cols-3'
|
||||
>
|
||||
{content.reviews.map((review, index) => (
|
||||
<div className='grid gap-8 md:grid-cols-3'>
|
||||
{[0, 1, 2].map((index) => (
|
||||
<Card
|
||||
key={index}
|
||||
className='overflow-hidden transition-all hover:shadow-lg'
|
||||
@ -327,21 +293,22 @@ export default function AboutPage({ content }: AboutPageProps) {
|
||||
.map((_, i) => (
|
||||
<Star
|
||||
key={i}
|
||||
className={`h-5 w-5 ${i < Number(review.rating) ? 'fill-yellow-400 text-yellow-400' : 'text-gray-300'}`}
|
||||
className={`h-5 w-5 ${i < Number(t(`about.testimonials.items.${index}.rating`)) ? 'fill-yellow-400 text-yellow-400' : 'text-gray-300'}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<p className='mb-4 text-gray-600 italic'>
|
||||
"{review.review}"
|
||||
"{t(`about.testimonials.items.${index}.text`)}"
|
||||
</p>
|
||||
<p className='font-semibold'>
|
||||
{t(`about.testimonials.items.${index}.name`)}
|
||||
</p>
|
||||
<p className='font-semibold'>{review.fullname}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
<CtaSection />
|
||||
</main>
|
||||
|
||||
@ -21,7 +21,6 @@ import {
|
||||
} from '@/shared/shadcn-ui/card';
|
||||
|
||||
import { CtaSection } from '@/widgets/cta-section';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Благотворительность | GasNetwork - Сеть заправок в Таджикистане',
|
||||
@ -47,27 +46,24 @@ export function CharityPage() {
|
||||
priority
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center bg-gradient-to-r from-black/70 to-black/30'>
|
||||
<Container>
|
||||
<div data-aos='fade-down' data-aos-duration='800' className='container mx-auto'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='max-w-2xl space-y-6 text-white'>
|
||||
<div className='inline-flex items-center justify-center rounded-full bg-red-600/20 p-2'>
|
||||
<Heart className='size-6 text-red-500' />
|
||||
</div>
|
||||
<h1 className='text-3xl font-bold tracking-tight sm:text-5xl md:text-6xl'>
|
||||
<h1 className='text-4xl font-bold tracking-tight sm:text-5xl md:text-6xl'>
|
||||
{t('charity.hero.title')}
|
||||
</h1>
|
||||
<p className='text-lg sm:text-xl text-gray-200'>
|
||||
<p className='text-xl text-gray-200'>
|
||||
{t('charity.hero.subtitle')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Mission Section */}
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='grid items-center gap-12 md:grid-cols-2'>
|
||||
@ -112,7 +108,6 @@ export function CharityPage() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* Key Figures */}
|
||||
<section className='bg-red-600 py-16 text-white'>
|
||||
@ -141,7 +136,6 @@ export function CharityPage() {
|
||||
</section>
|
||||
|
||||
{/* Upcoming Events */}
|
||||
<Container>
|
||||
<section className='bg-gray-50 py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 text-center'>
|
||||
@ -185,8 +179,7 @@ export function CharityPage() {
|
||||
'/placeholder.svg?height=200&width=300&text=Школьные+принадлежности',
|
||||
},
|
||||
].map((event, index) => (
|
||||
<Card key={index} className='overflow-hidden flex flex-col justify-between'>
|
||||
<div>
|
||||
<Card key={index} className='overflow-hidden'>
|
||||
<div className='relative h-48 w-full'>
|
||||
<Image
|
||||
src={event.image || '/placeholder.svg'}
|
||||
@ -196,7 +189,7 @@ export function CharityPage() {
|
||||
/>
|
||||
</div>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-xl lg:text-2xl'>{event.title}</CardTitle>
|
||||
<CardTitle>{event.title}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-4'>
|
||||
<p className='text-gray-600'>{event.description}</p>
|
||||
@ -209,7 +202,6 @@ export function CharityPage() {
|
||||
{event.location}
|
||||
</div>
|
||||
</CardContent>
|
||||
</div>
|
||||
<CardFooter>
|
||||
<Button className='w-full bg-red-600 hover:bg-red-700'>
|
||||
{t(`charity.events.button`)}
|
||||
@ -220,10 +212,8 @@ export function CharityPage() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
{/* How to Help */}
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 text-center'>
|
||||
@ -280,7 +270,6 @@ export function CharityPage() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
<CtaSection />
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@ -6,7 +6,6 @@ import Image from 'next/image';
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import { Card, CardContent } from '@/shared/shadcn-ui/card';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
export function CertificatesPage() {
|
||||
const { t } = useTextController();
|
||||
@ -65,7 +64,7 @@ export function CertificatesPage() {
|
||||
];
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<>
|
||||
<main className='container mx-auto py-10'>
|
||||
<div className='mb-10 text-center'>
|
||||
<h1 className='mb-4 text-4xl font-bold'>{t('certificates.title')}</h1>
|
||||
@ -77,7 +76,6 @@ export function CertificatesPage() {
|
||||
<div className='grid gap-8 md:grid-cols-2 lg:grid-cols-3'>
|
||||
{certificates.map((certificate) => (
|
||||
<Card
|
||||
data-aos='zoom-in'
|
||||
key={certificate.id}
|
||||
className='overflow-hidden transition-all duration-300 hover:shadow-lg'
|
||||
>
|
||||
@ -124,6 +122,6 @@ export function CertificatesPage() {
|
||||
))}
|
||||
</div>
|
||||
</main>
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { BenefitsSection } from '@/widgets/clients/ui/benefits-section';
|
||||
import { ServicesOverviewSection } from '@/widgets/clients/ui/services-overview-section';
|
||||
import { CtaSection } from '@/widgets/cta-section';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Клиентам | GasNetwork - Сеть заправок в Таджикистане',
|
||||
@ -33,8 +32,7 @@ export function ClientsPage() {
|
||||
priority
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center bg-gradient-to-r from-black/70 to-black/30'>
|
||||
<Container>
|
||||
<div data-aos='fade-down' data-aos-duration="1000" className='container mx-auto'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='max-w-2xl space-y-4 text-white'>
|
||||
<h1 className='text-4xl font-bold tracking-tight sm:text-5xl md:text-6xl'>
|
||||
{t('clients.title')}
|
||||
@ -44,7 +42,6 @@ export function ClientsPage() {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -7,7 +7,6 @@ import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Card, CardContent } from '@/shared/shadcn-ui/card';
|
||||
|
||||
import { CtaSection } from '@/widgets/cta-section';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
export const metadata = {
|
||||
title: 'Программа лояльности | GasNetwork - Сеть заправок в Таджикистане',
|
||||
@ -33,8 +32,7 @@ export function LoyaltyPage() {
|
||||
priority
|
||||
/>
|
||||
<div className='absolute inset-0 flex items-center bg-gradient-to-r from-black/70 to-black/30'>
|
||||
<Container>
|
||||
<div data-aos='fade-down' data-aos-duration="800" className='container mx-auto'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='max-w-2xl space-y-4 text-white'>
|
||||
<h1 className='text-4xl font-bold tracking-tight sm:text-5xl md:text-6xl'>
|
||||
{t('clients.loyalty.title')}
|
||||
@ -44,17 +42,15 @@ export function LoyaltyPage() {
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<Container>
|
||||
{/* Program Overview */}
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='grid items-center gap-12 md:grid-cols-2'>
|
||||
<div data-aos='fade-right'>
|
||||
<div>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<Percent className='h-6 w-6 text-red-600' />
|
||||
</div>
|
||||
@ -110,7 +106,7 @@ export function LoyaltyPage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div data-aos='fade-up' className='relative h-[400px] overflow-hidden rounded-xl shadow-xl'>
|
||||
<div className='relative h-[400px] overflow-hidden rounded-xl shadow-xl'>
|
||||
<Image
|
||||
src='/placeholder.svg?height=400&width=600&text=Программа+лояльности'
|
||||
alt='Программа лояльности'
|
||||
@ -134,7 +130,7 @@ export function LoyaltyPage() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div data-aos='zoom-in-right' className='grid gap-8 md:grid-cols-4'>
|
||||
<div className='grid gap-8 md:grid-cols-4'>
|
||||
<div className='text-center'>
|
||||
<div className='mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-600 text-2xl font-bold text-white'>
|
||||
1
|
||||
@ -195,7 +191,7 @@ export function LoyaltyPage() {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div data-aos='flip-down' className='grid gap-8 md:grid-cols-3'>
|
||||
<div className='grid gap-8 md:grid-cols-3'>
|
||||
<Card className='overflow-hidden border-t-4 border-t-gray-400 transition-all hover:shadow-lg'>
|
||||
<CardContent className='p-6'>
|
||||
<h3 className='mb-4 text-center text-2xl font-bold'>
|
||||
@ -249,7 +245,7 @@ export function LoyaltyPage() {
|
||||
<li className='flex items-center'>
|
||||
<Check className='mr-2 h-5 w-5 text-green-500' />
|
||||
<span>
|
||||
{t('clients.loyalty.works.levels.card-2.bonus-1')}
|
||||
{t('clients.loyalty.works.levels.card-1.bonus-1')}
|
||||
</span>
|
||||
</li>
|
||||
<li className='flex items-center'>
|
||||
@ -261,13 +257,13 @@ export function LoyaltyPage() {
|
||||
<li className='flex items-center'>
|
||||
<Check className='mr-2 h-5 w-5 text-green-500' />
|
||||
<span>
|
||||
{t('clients.loyalty.works.levels.card-2.bonus-3')}
|
||||
{t('clients.loyalty.works.levels.card-3.bonus-3')}
|
||||
</span>
|
||||
</li>
|
||||
<li className='flex items-center'>
|
||||
<Check className='mr-2 h-5 w-5 text-green-500' />
|
||||
<span>
|
||||
{t('clients.loyalty.works.levels.card-2.bonus-4')}
|
||||
{t('clients.loyalty.works.levels.card-4.bonus-4')}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
@ -324,7 +320,6 @@ export function LoyaltyPage() {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
|
||||
<CtaSection />
|
||||
</main>
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
'use client';
|
||||
|
||||
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';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
@ -17,7 +13,6 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/shared/shadcn-ui/card';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
import {
|
||||
Tabs,
|
||||
TabsContent,
|
||||
@ -42,24 +37,25 @@ const tabs = [
|
||||
},
|
||||
];
|
||||
|
||||
function LoginPageTabs() {
|
||||
export default function LoginPage() {
|
||||
const { t } = useTextController();
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const defaultTab = searchParams.get('tab') || 'bonus';
|
||||
|
||||
const handleTabChange = (tabType: string) => {
|
||||
router.push(`?tab=${tabType}`, undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<Tabs
|
||||
defaultValue={defaultTab}
|
||||
value={defaultTab}
|
||||
onValueChange={handleTabChange}
|
||||
className='w-full'
|
||||
>
|
||||
<div className='flex min-h-screen flex-col items-center justify-center'>
|
||||
<main className='flex-1'>
|
||||
<div className='container max-w-6xl py-16'>
|
||||
<div className='mb-12 flex flex-col items-center text-center'>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<Fuel className='h-6 w-6 text-red-600' />
|
||||
</div>
|
||||
<h1 className='mb-4 text-3xl font-bold tracking-tight sm:text-4xl'>
|
||||
{t('auth.title')}
|
||||
</h1>
|
||||
<p className='max-w-2xl text-gray-600'>{t('auth.description')}</p>
|
||||
</div>
|
||||
|
||||
<div className='mx-auto max-w-lg'>
|
||||
<Tabs defaultValue='bonus' className='w-full'>
|
||||
<TabsList className='mb-8 flex h-fit w-full flex-col sm:flex-row'>
|
||||
{tabs.map((tab) => {
|
||||
return (
|
||||
@ -75,43 +71,6 @@ function LoginPageTabs() {
|
||||
</TabsList>
|
||||
|
||||
{tabs.map((tab) => {
|
||||
const tabCookieName = `${tab.type}__token`;
|
||||
|
||||
const authenticationCookie = getCookie(tabCookieName);
|
||||
|
||||
if (authenticationCookie) {
|
||||
return (
|
||||
<TabsContent key={tab.label} value={tab.type}>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>{t(tab.title)}</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='flex justify-center gap-2 space-y-4'>
|
||||
<Link
|
||||
href={
|
||||
tab.type === 'bonus'
|
||||
? '/customer-dashboard'
|
||||
: '/corporate-dashboard'
|
||||
}
|
||||
>
|
||||
<Button className='flex items-center'>Открыть</Button>
|
||||
</Link>
|
||||
<Button
|
||||
variant='outline'
|
||||
className='flex items-center gap-2'
|
||||
onClick={() => {
|
||||
deleteCookie(tabCookieName);
|
||||
window.location.reload();
|
||||
}}
|
||||
>
|
||||
Выйти
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<TabsContent key={tab.label} value={tab.type}>
|
||||
<Card>
|
||||
@ -127,39 +86,11 @@ function LoginPageTabs() {
|
||||
);
|
||||
})}
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
|
||||
export default function LoginPage() {
|
||||
const { t } = useTextController();
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<div className='flex min-h-screen flex-col items-center justify-center'>
|
||||
<main className='flex-1'>
|
||||
<div className='container max-w-6xl py-16'>
|
||||
<div className='mb-12 flex flex-col items-center text-center'>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<Fuel className='h-6 w-6 text-red-600' />
|
||||
</div>
|
||||
<h1 className='mb-4 text-3xl font-bold tracking-tight sm:text-4xl'>
|
||||
{t('auth.title')}
|
||||
</h1>
|
||||
<p className='max-w-2xl text-gray-600'>{t('auth.description')}</p>
|
||||
</div>
|
||||
|
||||
<div data-aos='zoom-in' className='mx-auto max-w-lg'>
|
||||
<Suspense>
|
||||
<LoginPageTabs />
|
||||
</Suspense>
|
||||
|
||||
<div className='mt-8 text-center text-sm text-gray-500'>
|
||||
<p>
|
||||
{t('auth.loginIssues')}{' '}
|
||||
<Link
|
||||
href='/contact'
|
||||
className='text-red-600 hover:underline'
|
||||
>
|
||||
<Link href='/contact' className='text-red-600 hover:underline'>
|
||||
{t('auth.contactLink')}
|
||||
</Link>
|
||||
</p>
|
||||
@ -168,6 +99,5 @@ export default function LoginPage() {
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
const baseQuery = fetchBaseQuery({
|
||||
baseUrl: process.env.NEXT_PUBLIC_API_URL,
|
||||
@ -16,25 +15,7 @@ export const TAGS = {
|
||||
|
||||
export const baseAPI = createApi({
|
||||
reducerPath: 'baseAPI',
|
||||
baseQuery: async (args, api, extraOptions) => {
|
||||
const result = await baseQuery(args, api, extraOptions);
|
||||
|
||||
if (result.error) {
|
||||
switch (result.error.status) {
|
||||
case 401:
|
||||
toast.error('Login credentials error');
|
||||
break;
|
||||
|
||||
case 500:
|
||||
toast.error('Server error, please try later');
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
baseQuery,
|
||||
tagTypes: Object.values(TAGS),
|
||||
endpoints: () => ({}),
|
||||
});
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
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: () => ({}),
|
||||
});
|
||||
@ -5,7 +5,7 @@ import Image from 'next/image';
|
||||
import Link from 'next/link';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { Discounts } from '@/app/api-utlities/@types';
|
||||
import { Discounts } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
|
||||
@ -1,25 +1,12 @@
|
||||
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 { baseAPI } from '@/shared/api/base-api';
|
||||
import { TextItem } from '@/shared/types/text.types';
|
||||
|
||||
export const textControlApi = taylorAPI.injectEndpoints({
|
||||
export const textControlApi = baseAPI.injectEndpoints({
|
||||
endpoints: (builder) => ({
|
||||
fetchText: builder.query<TextItem[], void>({
|
||||
query: () => ({
|
||||
url: '',
|
||||
method: 'POST',
|
||||
body: {
|
||||
query: jsonToGraphQLQuery({ query: textsRequest }),
|
||||
},
|
||||
}),
|
||||
|
||||
transformResponse: (response: any) => {
|
||||
return presentTexts(response.data._kontentSajta);
|
||||
},
|
||||
query: () => '/text',
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const { useFetchTextQuery } = textControlApi;
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
"use client"
|
||||
|
||||
interface ContainerProps {
|
||||
children: React.ReactNode
|
||||
}
|
||||
export default function Container({children}: ContainerProps) {
|
||||
return (
|
||||
<div className="container mx-auto px-2.5 py-1">{children}</div>
|
||||
)
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from '@/shared/lib/utils';
|
||||
|
||||
const Separator = React.forwardRef<
|
||||
React.ComponentRef<typeof SeparatorPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
||||
>(
|
||||
(
|
||||
{ className, orientation = 'horizontal', decorative = true, ...props },
|
||||
ref,
|
||||
) => (
|
||||
<SeparatorPrimitive.Root
|
||||
ref={ref}
|
||||
decorative={decorative}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
'bg-border shrink-0',
|
||||
orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
),
|
||||
);
|
||||
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
||||
|
||||
export { Separator };
|
||||
@ -4,16 +4,13 @@ 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)
|
||||
.concat(taylorAPI.middleware),
|
||||
getDefaultMiddleware().concat(baseAPI.middleware),
|
||||
devTools: process.env.NODE_ENV === 'development',
|
||||
});
|
||||
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { combineReducers } from '@reduxjs/toolkit';
|
||||
|
||||
import { loginAPI } from '@/entities/auth/api/login.api';
|
||||
|
||||
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,
|
||||
[loginAPI.reducerPath]: loginAPI.reducer,
|
||||
});
|
||||
|
||||
@ -3,19 +3,64 @@
|
||||
import { Calendar, ChevronDown, ChevronUp } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { HistoryItems } from '@/app/api-utlities/@types';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import { Card, CardContent } from '@/shared/shadcn-ui/card';
|
||||
|
||||
export interface CompanyTimelineProps {
|
||||
timeline: HistoryItems;
|
||||
}
|
||||
const timelineEvents = [
|
||||
{
|
||||
year: '2008',
|
||||
title: 'Основание компании',
|
||||
description:
|
||||
'GasNetwork была основана с открытием первых трех заправочных станций в Душанбе. С самого начала компания поставила перед собой цель предоставлять качественное топливо и отличный сервис.',
|
||||
},
|
||||
{
|
||||
year: '2010',
|
||||
title: 'Расширение сети',
|
||||
description:
|
||||
'Открытие еще пяти заправочных станций в различных регионах Таджикистана. Начало формирования единого стандарта обслуживания на всех станциях сети.',
|
||||
},
|
||||
{
|
||||
year: '2012',
|
||||
title: 'Внедрение программы лояльности',
|
||||
description:
|
||||
'Запуск первой в Таджикистане программы лояльности для клиентов сети заправок. Введение карт постоянного клиента с накопительной системой бонусов.',
|
||||
},
|
||||
{
|
||||
year: '2014',
|
||||
title: 'Модернизация оборудования',
|
||||
description:
|
||||
'Масштабная программа по обновлению оборудования на всех заправочных станциях сети. Внедрение современных технологий для повышения качества обслуживания.',
|
||||
},
|
||||
{
|
||||
year: '2016',
|
||||
title: 'Открытие 15-й заправки',
|
||||
description:
|
||||
'Значительное расширение сети с открытием юбилейной 15-й заправочной станции. GasNetwork становится одной из крупнейших сетей заправок в Таджикистане.',
|
||||
},
|
||||
{
|
||||
year: '2018',
|
||||
title: 'Запуск мобильного приложения',
|
||||
description:
|
||||
'Разработка и запуск мобильного приложения для клиентов сети. Возможность отслеживать бонусы, находить ближайшие заправки и получать специальные предложения.',
|
||||
},
|
||||
{
|
||||
year: '2020',
|
||||
title: 'Создание благотворительного фонда',
|
||||
description:
|
||||
'Основание благотворительного фонда GasNetwork для поддержки социальных проектов в Таджикистане. Начало активной социальной деятельности компании.',
|
||||
},
|
||||
{
|
||||
year: '2023',
|
||||
title: 'Современное развитие',
|
||||
description:
|
||||
'Сегодня GasNetwork - это 25+ современных заправочных станций по всему Таджикистану, более 150 сотрудников и тысячи довольных клиентов ежедневно.',
|
||||
},
|
||||
];
|
||||
|
||||
export function CompanyTimeline({ timeline }: CompanyTimelineProps) {
|
||||
export function CompanyTimeline() {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
const displayEvents = expanded ? timeline : timeline.slice(0, 4);
|
||||
const displayEvents = expanded ? timelineEvents : timelineEvents.slice(0, 4);
|
||||
|
||||
const { t } = useTextController();
|
||||
|
||||
@ -35,7 +80,7 @@ export function CompanyTimeline({ timeline }: CompanyTimelineProps) {
|
||||
<Calendar className='size-5 text-red-600' />
|
||||
</div>
|
||||
<h3 className='text-xl font-bold'>{event.year}</h3>
|
||||
<h4 className='mb-2 text-lg font-semibold'>{event.name}</h4>
|
||||
<h4 className='mb-2 text-lg font-semibold'>{event.title}</h4>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@ -63,7 +108,7 @@ export function CompanyTimeline({ timeline }: CompanyTimelineProps) {
|
||||
))}
|
||||
</div>
|
||||
|
||||
{timeline.length > 4 && (
|
||||
{timelineEvents.length > 4 && (
|
||||
<div className='mt-8 text-center'>
|
||||
<Button
|
||||
variant='outline'
|
||||
|
||||
@ -4,8 +4,6 @@ import { ChevronLeft, ChevronRight, Maximize } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { Stations } from '@/app/api-utlities/@types';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
import {
|
||||
@ -17,15 +15,55 @@ import {
|
||||
DialogTrigger,
|
||||
} from '@/shared/shadcn-ui/dialog';
|
||||
|
||||
export interface StationGalleryProps {
|
||||
stations: Stations;
|
||||
interface Station {
|
||||
id: number;
|
||||
name: string;
|
||||
image: string;
|
||||
location: string;
|
||||
}
|
||||
|
||||
export function StationGallery({ stations }: StationGalleryProps) {
|
||||
const stations: Array<Station> = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'АЗС Душанбе-Центр',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Душанбе-Центр',
|
||||
location: 'ул. Рудаки 150, Душанбе',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'АЗС Худжанд',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Худжанд',
|
||||
location: 'ул. Ленина 45, Худжанд',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'АЗС Куляб',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Куляб',
|
||||
location: 'ул. Сомони 78, Куляб',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'АЗС Бохтар',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Бохтар',
|
||||
location: 'ул. Айни 23, Бохтар',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'АЗС Хорог',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Хорог',
|
||||
location: 'ул. Горная 12, Хорог',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
name: 'АЗС Истаравшан',
|
||||
image: '/placeholder.svg?height=400&width=600&text=АЗС+Истаравшан',
|
||||
location: 'ул. Исмоили Сомони 34, Истаравшан',
|
||||
},
|
||||
];
|
||||
|
||||
export function StationGallery() {
|
||||
const [currentImage, setCurrentImage] = useState(0);
|
||||
const [selectedStation, setSelectedStation] = useState<Stations[0] | null>(
|
||||
null,
|
||||
);
|
||||
const [selectedStation, setSelectedStation] = useState<Station | null>(null);
|
||||
|
||||
const nextImage = () => {
|
||||
setCurrentImage((prev) => (prev === stations.length - 1 ? 0 : prev + 1));
|
||||
@ -38,7 +76,7 @@ export function StationGallery({ stations }: StationGalleryProps) {
|
||||
const { t } = useTextController();
|
||||
|
||||
return (
|
||||
<div className='space-y-8 px-2'>
|
||||
<div className='space-y-8'>
|
||||
<div className='relative h-[400px] overflow-hidden rounded-xl shadow-xl md:h-[500px]'>
|
||||
<Image
|
||||
src={stations[currentImage].image || '/placeholder.svg'}
|
||||
@ -48,7 +86,7 @@ export function StationGallery({ stations }: StationGalleryProps) {
|
||||
/>
|
||||
<div className='absolute inset-0 flex flex-col justify-end bg-gradient-to-t from-black/70 to-transparent p-6 text-white'>
|
||||
<h3 className='text-2xl font-bold'>{stations[currentImage].name}</h3>
|
||||
<p className='text-white/80'>{stations[currentImage].address}</p>
|
||||
<p className='text-white/80'>{stations[currentImage].location}</p>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
@ -87,7 +125,7 @@ export function StationGallery({ stations }: StationGalleryProps) {
|
||||
<DialogHeader>
|
||||
<DialogTitle>{stations[currentImage].name}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{stations[currentImage].address}
|
||||
{stations[currentImage].location}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className='relative h-[60vh] w-full'>
|
||||
|
||||
@ -4,7 +4,6 @@ import { Percent } from 'lucide-react';
|
||||
import Image from 'next/image';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
interface Benefit {
|
||||
title: string;
|
||||
@ -34,11 +33,10 @@ export const BenefitsSection = () => {
|
||||
const { t } = useTextController();
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<section className='bg-gray-50 py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='grid items-center gap-12 md:grid-cols-2'>
|
||||
<div data-aos='fade-right' data-aos-duration='4000' className='order-2 md:order-1'>
|
||||
<div className='order-2 md:order-1'>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<Percent className='h-6 w-6 text-red-600' />
|
||||
</div>
|
||||
@ -65,7 +63,7 @@ export const BenefitsSection = () => {
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div data-aos='fade-up' className='relative order-1 h-[400px] overflow-hidden rounded-xl shadow-xl md:order-2'>
|
||||
<div className='relative order-1 h-[400px] overflow-hidden rounded-xl shadow-xl md:order-2'>
|
||||
<Image
|
||||
src='/placeholder.svg?height=400&width=600&text=Преимущества+для+клиентов'
|
||||
alt='Преимущества для клиентов'
|
||||
@ -76,6 +74,5 @@ export const BenefitsSection = () => {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@ -11,7 +11,6 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/shared/shadcn-ui/card';
|
||||
import Container from '@/shared/shadcn-ui/conteiner';
|
||||
|
||||
interface ServiceOverview {
|
||||
title: string;
|
||||
@ -50,7 +49,6 @@ export const ServicesOverviewSection = () => {
|
||||
const { t } = useTextController();
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<section className='py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<div className='mb-12 text-center'>
|
||||
@ -62,7 +60,7 @@ export const ServicesOverviewSection = () => {
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div data-aos='flip-up' data-aos-duration='600' className='grid gap-3 md:grid-cols-2 md:gap-6 lg:grid-cols-3'>
|
||||
<div className='grid gap-3 md:grid-cols-2 md:gap-6 lg:grid-cols-3'>
|
||||
{servicesOverview.map(({ description, Icon, contentText, title }) => {
|
||||
return (
|
||||
<Card
|
||||
@ -85,6 +83,5 @@ export const ServicesOverviewSection = () => {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
@ -11,8 +11,7 @@ export const Footer = () => {
|
||||
return (
|
||||
<footer className='bg-gray-900 px-4 py-12 text-white'>
|
||||
<div className='containe mx-autor'>
|
||||
<div className='grid grid-cols-1 gap-8 md:gap-4 md:grid-cols-3'>
|
||||
<div className='flex md:justify-center md:items-center'>
|
||||
<div className='grid grid-cols-1 gap-8 md:grid-cols-3'>
|
||||
<div>
|
||||
<div className='mb-4 flex items-center gap-2'>
|
||||
<Fuel className='h-6 w-6 text-red-500' />
|
||||
@ -60,8 +59,6 @@ export const Footer = () => {
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex md:justify-center md:items-center'>
|
||||
<div>
|
||||
<h3 className='mb-4 text-lg font-semibold'>
|
||||
{t('common.footer.contacts')}
|
||||
@ -81,8 +78,6 @@ export const Footer = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex md:justify-center md:items-center'>
|
||||
<div>
|
||||
<h3 className='mb-4 text-lg font-semibold'>
|
||||
{t('common.footer.navigation')}
|
||||
@ -125,7 +120,6 @@ export const Footer = () => {
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='mt-8 border-t border-gray-800 pt-8 text-center text-gray-400'>
|
||||
<p>
|
||||
© {new Date().getFullYear()} {t('common.name')}.{' '}
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
|
||||
import { MapPin } from 'lucide-react';
|
||||
|
||||
import { Stations } from '@/app/api-utlities/@types';
|
||||
import { Stations } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import { GasStationMap } from '@/features/map';
|
||||
import { Point } from '@/features/map/model';
|
||||
import { YandexMap } from '@/features/map/ui/yandex-map';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
|
||||
@ -15,9 +17,15 @@ interface MapSectionProps {
|
||||
export const MapSection = ({ stations }: MapSectionProps) => {
|
||||
const { t } = useTextController();
|
||||
|
||||
const points = stations.map((st) => ({
|
||||
id: st.id,
|
||||
coordinates: [st.latitude, st.longitude],
|
||||
})) as Point[];
|
||||
|
||||
return (
|
||||
<section id='stations' className='bg-gray-50 px-2 py-8 sm:py-16'>
|
||||
<div className='container mx-auto'>
|
||||
<YandexMap points={points} />
|
||||
<div className='mb-12 flex flex-col items-center justify-center text-center'>
|
||||
<div className='mb-4 inline-flex items-center justify-center rounded-full bg-red-100 p-2'>
|
||||
<MapPin className='h-6 w-6 text-red-600' />
|
||||
@ -33,7 +41,7 @@ export const MapSection = ({ stations }: MapSectionProps) => {
|
||||
className='h-[500px] overflow-hidden rounded-xl border shadow-lg'
|
||||
data-aos='fade-up'
|
||||
>
|
||||
<GasStationMap stations={stations} />
|
||||
{/* <GasStationMap stations={stations} /> */}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -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';
|
||||
import { Partners } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import { Gift } from 'lucide-react';
|
||||
|
||||
import { Discounts } from '@/app/api-utlities/@types';
|
||||
import { Discounts } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import PromotionSlider from '@/shared/components/promotion-slider';
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
|
||||
@ -3,9 +3,7 @@
|
||||
import { format, subMonths } from 'date-fns';
|
||||
import { ru } from 'date-fns/locale';
|
||||
import { CalendarIcon } from 'lucide-react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useFetchBonusTransactionsQuery } from '@/entities/bonus/api/bonus.api';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { Button } from '@/shared/shadcn-ui/button';
|
||||
@ -25,30 +23,85 @@ import {
|
||||
TableRow,
|
||||
} from '@/shared/shadcn-ui/table';
|
||||
|
||||
export const TransactionsTable = () => {
|
||||
const [startDate, setStartDate] = useState<Date>(subMonths(new Date(), 1));
|
||||
const [endDate, setEndDate] = useState<Date>(new Date());
|
||||
// Sample customer data
|
||||
const customerData = {
|
||||
firstName: 'Алишер',
|
||||
lastName: 'Рахмонов',
|
||||
passportNumber: 'A12345678',
|
||||
bonusPoints: 1250,
|
||||
cardNumber: '5678-9012-3456-7890',
|
||||
expiryDate: '12/2025',
|
||||
registrationDate: '15.06.2020',
|
||||
};
|
||||
|
||||
const { data, refetch } = useFetchBonusTransactionsQuery({
|
||||
limit: 100,
|
||||
page: 1,
|
||||
start_date: format(startDate, 'yyyy-MM-dd'),
|
||||
end_date: format(endDate, 'yyyy-MM-dd'),
|
||||
// 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<Date | undefined>(
|
||||
subMonths(new Date(), 1),
|
||||
);
|
||||
const [endDate, setEndDate] = useState<Date | undefined>(new Date());
|
||||
const [filteredTransactions, setFilteredTransactions] =
|
||||
useState(transactions);
|
||||
|
||||
// Filter transactions by date range
|
||||
const filterTransactions = () => {
|
||||
if (!startDate || !endDate) return;
|
||||
|
||||
refetch();
|
||||
const filtered = transactions.filter((transaction) => {
|
||||
const transactionDate = new Date(transaction.date);
|
||||
return transactionDate >= startDate && transactionDate <= endDate;
|
||||
});
|
||||
|
||||
setFilteredTransactions(filtered);
|
||||
};
|
||||
|
||||
const { t } = useTextController();
|
||||
|
||||
useEffect(() => {}, [startDate, endDate]);
|
||||
|
||||
if (!data) return null;
|
||||
|
||||
return (
|
||||
<div className='space-y-6'>
|
||||
<div className='flex flex-col items-start justify-between gap-4 md:flex-row md:items-center'>
|
||||
@ -147,22 +200,22 @@ export const TransactionsTable = () => {
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{data.transactions.length > 0 ? (
|
||||
data.transactions.map((transaction) => (
|
||||
{filteredTransactions.length > 0 ? (
|
||||
filteredTransactions.map((transaction) => (
|
||||
<TableRow key={transaction.id}>
|
||||
<TableCell>
|
||||
{format(new Date(transaction.date_create), 'dd.MM.yyyy')}
|
||||
{format(transaction.date, 'dd.MM.yyyy')}
|
||||
</TableCell>
|
||||
<TableCell>{transaction.station}</TableCell>
|
||||
<TableCell>{transaction.product_name}</TableCell>
|
||||
<TableCell>{transaction.product}</TableCell>
|
||||
<TableCell className='text-right'>
|
||||
{transaction.price_real}
|
||||
{transaction.quantity}
|
||||
</TableCell>
|
||||
<TableCell className='text-right'>
|
||||
{transaction.amount} {t('corporate.currency')}
|
||||
{transaction.cost.toFixed(2)} {t('corporate.currency')}
|
||||
</TableCell>
|
||||
<TableCell className='text-right font-medium'>
|
||||
{transaction.sum_real} {t('corporate.currency')}
|
||||
{transaction.total.toFixed(2)} {t('corporate.currency')}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import { Briefcase } from 'lucide-react';
|
||||
|
||||
import { Jobs } from '@/app/api-utlities/@types';
|
||||
import { Jobs } from '@/app/api-utlities/@types/main';
|
||||
|
||||
import { useTextController } from '@/shared/language/hooks/use-text-controller';
|
||||
import { cn } from '@/shared/lib/utils';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user