2025-04-29 00:14:02 +05:00

49 lines
1.6 KiB
TypeScript

import { isEmpty } from 'lodash';
import { Discount, Image, Job, Partner, Station } from '../@types';
export const presentImage = (images: Image[]) =>
isEmpty(images) ? null : `${process.env.TAYLOR_MEDIA_URL}/${images[0].url}`;
export const presentPartners = (partners: Partner) =>
partners.records.map((record) => ({
name: record._name,
poster: presentImage(record._image),
}));
export const presentJobs = (jobs: Job) =>
jobs.records.map((job) => ({
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,
}));
export const presentDiscounts = (discounts: Discount) =>
discounts.records.map((discount) => ({
name: discount._name,
description: discount._opisanie,
expiresAt: discount._do,
image: presentImage(discount._foto),
}));
export const presentStations = (stations: Station) =>
stations.records.map((station: any) => ({
name: station._name,
description: station._opisanie,
address: station._adress,
workingHours: station._chasyRaboty?.name || null,
latitude: station._lat,
longitude: station._long,
carWash: station._avtomojka || false,
ai92: station._dtCopy || false,
ai95: station._ai92Copy || false,
z100: station._ai95Copy || false,
propan: station._z100Copy || false,
electricCharge: station._propanCopy || false,
miniMarket: station._zaryadnayaStanci || false,
toilet: station._miniMarketCop || false,
region: !isEmpty(station._region) ? station._region[0].name : null,
image: presentImage(station._foto),
}));