424 lines
9.8 KiB
TypeScript
424 lines
9.8 KiB
TypeScript
import * as path from 'path';
|
||
|
||
import { Request, Response } from 'express';
|
||
import { v4 as uuid } from 'uuid';
|
||
|
||
import { PAGE_LINK } from '../../../constants';
|
||
import { ImageType } from '../image/controller';
|
||
|
||
const imageRootDir = 'static/images/stories/';
|
||
const galleryRootDir = 'static/images/gallery/';
|
||
|
||
const faqImage = path.join(imageRootDir, 'birthday/faq.png');
|
||
const faqMobileImage = path.join(imageRootDir, 'birthday/faq_mobile.png');
|
||
const feedbackImage = path.join(imageRootDir, 'birthday/feedback.png');
|
||
const feedbackMobileImage = path.join(imageRootDir, 'birthday/feedback_mobile.png');
|
||
const photoImage = path.join(imageRootDir, 'birthday/photo.png');
|
||
const photoMobileImage = path.join(imageRootDir, 'birthday/photo_mobile.png');
|
||
|
||
const example = path.join(imageRootDir, 'example.png');
|
||
const example2 = path.join(imageRootDir, 'example2.jpg');
|
||
|
||
const gallery1Image = path.join(galleryRootDir, '/1.png');
|
||
const gallery2Image = path.join(galleryRootDir, '/2.png');
|
||
const gallery3Image = path.join(galleryRootDir, '/3.png');
|
||
const gallery4Image = path.join(galleryRootDir, '/4.png');
|
||
const gallery5Image = path.join(galleryRootDir, '/5.png');
|
||
|
||
type FeedbackType = {
|
||
author: string;
|
||
from: string;
|
||
id: string;
|
||
rate: 1 | 2 | 3 | 4 | 5;
|
||
text: string;
|
||
};
|
||
|
||
export type StoryFeedbackModalType = {
|
||
feedbacks: FeedbackType[];
|
||
};
|
||
export type StoryGalleryModalType = {
|
||
gallery: ImageType[];
|
||
};
|
||
export type StoryInfoModalType = {};
|
||
export type StoryQuestPlotModalType = {
|
||
background: {
|
||
color: string;
|
||
images: ImageType[];
|
||
};
|
||
mobileText: string;
|
||
text: string;
|
||
title: string;
|
||
};
|
||
|
||
export type StoryModalContent = StoryFeedbackModalType | StoryGalleryModalType | StoryInfoModalType | StoryQuestPlotModalType;
|
||
export type StoryModalType = 'faq' | 'feedback' | 'gallery' | 'info' | 'questPlot';
|
||
export type StoryImageType = {
|
||
alt: string;
|
||
height?: number;
|
||
src: string;
|
||
width?: number;
|
||
};
|
||
|
||
export type StoryType = {
|
||
border?: {
|
||
inner?: {
|
||
color: string;
|
||
};
|
||
outer?: {
|
||
color: string;
|
||
};
|
||
};
|
||
id: string;
|
||
img: StoryImageType;
|
||
imgMobile?: StoryImageType;
|
||
modal: {
|
||
content?: StoryModalContent;
|
||
type: StoryModalType;
|
||
};
|
||
title?: string;
|
||
};
|
||
|
||
const feedbacks = [
|
||
{
|
||
author: 'Ульяна Троценко',
|
||
from: 'vk.com',
|
||
id: uuid(),
|
||
rate: 5,
|
||
text: 'Квест очень понравился. надо подумать головой , и кажется что когда квест\n'
|
||
+ 'на логику будет не страшно . Как бы не так , если с актёром было страшновато .\n'
|
||
+ '( правда наша команда очень сильно тупила) но было очень захватывающе\n'
|
||
+ 'и интересно. Так что квест очень интересный 😍🔥',
|
||
},
|
||
{
|
||
author: 'Никита Морозов',
|
||
from: 'vk.com',
|
||
id: uuid(),
|
||
rate: 4,
|
||
text: 'Побывал на квесте, очень круто! Хочу побывать на других! Посмотреть\n'
|
||
+ 'на сколько они сложные и интересные)',
|
||
},
|
||
{
|
||
author: 'irina eshenko',
|
||
from: 'yandex.ru',
|
||
id: uuid(),
|
||
rate: 3,
|
||
text: 'Детям очень понравилось на следующий день после посещения пошли\n'
|
||
+ 'снова на другой. Ребята актеры отличные. Советую',
|
||
},
|
||
];
|
||
const gallery: ImageType[] = [
|
||
{
|
||
src: gallery1Image,
|
||
},
|
||
{
|
||
src: gallery2Image,
|
||
},
|
||
{
|
||
src: gallery3Image,
|
||
},
|
||
{
|
||
src: gallery4Image,
|
||
},
|
||
{
|
||
src: gallery5Image,
|
||
},
|
||
];
|
||
|
||
const birthdayPageStories: StoryType[] = [
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqMobileImage,
|
||
},
|
||
modal: {
|
||
type: 'faq',
|
||
},
|
||
title: 'Ответы\\n на вопросы',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
feedbacks,
|
||
},
|
||
type: 'feedback',
|
||
},
|
||
title: 'Отзывы\\n наших клиентов',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
gallery,
|
||
},
|
||
type: 'gallery',
|
||
},
|
||
title: 'Фотографии\n и видео',
|
||
},
|
||
];
|
||
const graduationPageStories: StoryType[] = [
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqMobileImage,
|
||
},
|
||
modal: {
|
||
type: 'faq',
|
||
},
|
||
title: 'Ответы\\n на вопросы',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
feedbacks,
|
||
},
|
||
type: 'feedback',
|
||
},
|
||
title: 'Отзывы\\n наших клиентов',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
gallery,
|
||
},
|
||
type: 'gallery',
|
||
},
|
||
title: 'Фотографии\n и видео',
|
||
},
|
||
];
|
||
const outdoorsPageStories: StoryType[] = [
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Ответы на вопросы',
|
||
src: faqMobileImage,
|
||
},
|
||
modal: {
|
||
type: 'faq',
|
||
},
|
||
title: 'Ответы\\n на вопросы',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Отзывы наших клиентов',
|
||
src: feedbackMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
feedbacks,
|
||
},
|
||
type: 'feedback',
|
||
},
|
||
title: 'Отзывы\\n наших клиентов',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoImage,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Фотографии и видео',
|
||
src: photoMobileImage,
|
||
},
|
||
modal: {
|
||
content: {
|
||
gallery,
|
||
},
|
||
type: 'gallery',
|
||
},
|
||
title: 'Фотографии\n и видео',
|
||
},
|
||
];
|
||
|
||
const homePageStories: StoryType[] = [
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Рекомендации по квестам',
|
||
src: example,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Рекомендации по квестам',
|
||
src: example,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'Рекомендации\\n по квестам',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'День Рождения в Arkids парке',
|
||
src: example2,
|
||
},
|
||
imgMobile: {
|
||
alt: 'День Рождения в Arkids парке',
|
||
src: example2,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'День Рождения\\n в Arkids парке',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'Новые программы\\n для праздника',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Рекомендации по квестам',
|
||
src: example,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Рекомендации по квестам',
|
||
src: example,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'Рекомендации\\n по квестам',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'День Рождения в Arkids парке',
|
||
src: example2,
|
||
},
|
||
imgMobile: {
|
||
alt: 'День Рождения в Arkids парке',
|
||
src: example2,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'День Рождения\\n в Arkids парке',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'Новые программы\\n для праздника',
|
||
},
|
||
{
|
||
id: uuid(),
|
||
img: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
imgMobile: {
|
||
alt: 'Новые программы для праздника',
|
||
src: example,
|
||
},
|
||
modal: {
|
||
type: 'info',
|
||
},
|
||
title: 'Новые программы\\n для праздника',
|
||
},
|
||
];
|
||
|
||
export const getStories = (req: Request, res: Response) => {
|
||
// @ts-ignore
|
||
const { page } = req.body;
|
||
|
||
switch (page) {
|
||
case PAGE_LINK.BIRTHDAY: {
|
||
return res.status(200).json(birthdayPageStories);
|
||
}
|
||
|
||
case PAGE_LINK.GRADUATION: {
|
||
return res.status(200).json(graduationPageStories);
|
||
}
|
||
|
||
case PAGE_LINK.OUTDOORS: {
|
||
return res.status(200).json(outdoorsPageStories);
|
||
}
|
||
|
||
case PAGE_LINK.HOME: {
|
||
return res.status(200).json(homePageStories);
|
||
}
|
||
|
||
case PAGE_LINK.FAQ: {
|
||
return res.status(200).json([]);
|
||
}
|
||
|
||
default:
|
||
return res.status(404);
|
||
}
|
||
};
|