Merge branch 'dev' of https://devgit.oriyo.tj/adilovcode/oriyo_next into add-pages
This commit is contained in:
commit
00257ce07b
@ -53,3 +53,15 @@ 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;
|
||||
}>;
|
||||
|
||||
@ -2,16 +2,22 @@ import { isEmpty } from 'lodash';
|
||||
|
||||
import {
|
||||
Discount,
|
||||
History,
|
||||
Image,
|
||||
Job,
|
||||
Partner,
|
||||
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,
|
||||
@ -24,8 +30,22 @@ export const presentJobs = (jobs: Job) =>
|
||||
id: index + 1,
|
||||
name: job._name,
|
||||
tags: job._tags.map((tag) => tag.name),
|
||||
location: !isEmpty(job._localtio) ? job._localtio[0].name : null,
|
||||
type: !isEmpty(job._type) ? job._type[0].name : null,
|
||||
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,
|
||||
}));
|
||||
|
||||
export const presentDiscounts = (discounts: Discount) =>
|
||||
@ -54,7 +74,7 @@ export const presentStations = (stations: Station) =>
|
||||
electricCharge: station._propanCopy || false,
|
||||
miniMarket: station._zaryadnayaStanci || false,
|
||||
toilet: station._miniMarketCop || false,
|
||||
region: !isEmpty(station._region) ? station._region[0].name : null,
|
||||
region: presentSelect(station._region),
|
||||
image: presentImage(station._foto),
|
||||
}));
|
||||
|
||||
|
||||
6
src/app/api-utlities/requests/about-us-page.request.ts
Normal file
6
src/app/api-utlities/requests/about-us-page.request.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { historyRequest, teamRequest } from './common';
|
||||
|
||||
export const aboutUsPageRequest = {
|
||||
...teamRequest,
|
||||
...historyRequest,
|
||||
};
|
||||
@ -76,3 +76,25 @@ 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,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
24
src/app/api/pages/about-us/route.ts
Normal file
24
src/app/api/pages/about-us/route.ts
Normal file
@ -0,0 +1,24 @@
|
||||
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