Compare commits
No commits in common. "00257ce07bd83f685cde161ff7e8919f7c043ba1" and "2dfcdd096e7d501315c4bf9554df14ee1fbb0006" have entirely different histories.
00257ce07b
...
2dfcdd096e
@ -53,15 +53,3 @@ export type TextResponse = Root<{
|
|||||||
_name: string;
|
_name: string;
|
||||||
_znachenie: string | null;
|
_znachenie: string | null;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export type Team = Root<{
|
|
||||||
_foto: Image[];
|
|
||||||
_zvanie: string;
|
|
||||||
_name: string;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
export type History = Root<{
|
|
||||||
_name: string;
|
|
||||||
_god: string;
|
|
||||||
_opisanie: string;
|
|
||||||
}>;
|
|
||||||
|
|||||||
@ -2,22 +2,16 @@ import { isEmpty } from 'lodash';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
Discount,
|
Discount,
|
||||||
History,
|
|
||||||
Image,
|
Image,
|
||||||
Job,
|
Job,
|
||||||
Partner,
|
Partner,
|
||||||
Select,
|
|
||||||
Station,
|
Station,
|
||||||
Team,
|
|
||||||
TextResponse,
|
TextResponse,
|
||||||
} from '../@types';
|
} from '../@types';
|
||||||
|
|
||||||
export const presentImage = (images: Image[]) =>
|
export const presentImage = (images: Image[]) =>
|
||||||
isEmpty(images) ? null : `${process.env.TAYLOR_MEDIA_URL}/${images[0].url}`;
|
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) =>
|
export const presentPartners = (partners: Partner) =>
|
||||||
partners.records.map((record, index) => ({
|
partners.records.map((record, index) => ({
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
@ -30,22 +24,8 @@ export const presentJobs = (jobs: Job) =>
|
|||||||
id: index + 1,
|
id: index + 1,
|
||||||
name: job._name,
|
name: job._name,
|
||||||
tags: job._tags.map((tag) => tag.name),
|
tags: job._tags.map((tag) => tag.name),
|
||||||
location: presentSelect(job._localtio),
|
location: !isEmpty(job._localtio) ? job._localtio[0].name : null,
|
||||||
type: presentSelect(job._type),
|
type: !isEmpty(job._type) ? job._type[0].name : null,
|
||||||
}));
|
|
||||||
|
|
||||||
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,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const presentDiscounts = (discounts: Discount) =>
|
export const presentDiscounts = (discounts: Discount) =>
|
||||||
@ -74,7 +54,7 @@ export const presentStations = (stations: Station) =>
|
|||||||
electricCharge: station._propanCopy || false,
|
electricCharge: station._propanCopy || false,
|
||||||
miniMarket: station._zaryadnayaStanci || false,
|
miniMarket: station._zaryadnayaStanci || false,
|
||||||
toilet: station._miniMarketCop || false,
|
toilet: station._miniMarketCop || false,
|
||||||
region: presentSelect(station._region),
|
region: !isEmpty(station._region) ? station._region[0].name : null,
|
||||||
image: presentImage(station._foto),
|
image: presentImage(station._foto),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
import { historyRequest, teamRequest } from './common';
|
|
||||||
|
|
||||||
export const aboutUsPageRequest = {
|
|
||||||
...teamRequest,
|
|
||||||
...historyRequest,
|
|
||||||
};
|
|
||||||
@ -76,25 +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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
import {
|
|
||||||
presentHistoryItems,
|
|
||||||
presentTeamMembers,
|
|
||||||
} from '@/app/api-utlities/presenters';
|
|
||||||
import { aboutUsPageRequest } from '@/app/api-utlities/requests/about-us-page.request';
|
|
||||||
import { requestTaylor } from '@/app/api-utlities/utilities/taylor.client';
|
|
||||||
|
|
||||||
import { validationErrorHandler } from '../../middlewares/error-handler.middleware';
|
|
||||||
|
|
||||||
const routeHandler = async () => {
|
|
||||||
const response = await requestTaylor(aboutUsPageRequest);
|
|
||||||
|
|
||||||
return new Response(
|
|
||||||
JSON.stringify({
|
|
||||||
team: presentTeamMembers(response.data._komanda),
|
|
||||||
history: presentHistoryItems(response.data._istoriya),
|
|
||||||
}),
|
|
||||||
{
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
},
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GET = validationErrorHandler(routeHandler);
|
|
||||||
Loading…
x
Reference in New Issue
Block a user