741 lines
20 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 photo2Image = path.join(imageRootDir, 'outdoors/photo.png');
const photoMobileImage = path.join(imageRootDir, 'birthday/photo_mobile.png');
const photo2MobileImage = path.join(imageRootDir, 'outdoors/photo_mobile.png');
const example = path.join(imageRootDir, 'example.png');
const example2 = path.join(imageRootDir, 'example2.png');
const example3 = path.join(imageRootDir, 'example3.png');
const example4 = path.join(imageRootDir, 'example4.png');
const example5 = path.join(imageRootDir, 'example5.png');
const exampleMobile = path.join(imageRootDir, 'exampleMobile.png');
const example2Mobile = path.join(imageRootDir, 'example2Mobile.png');
const example3Mobile = path.join(imageRootDir, 'example3Mobile.png');
const example4Mobile = path.join(imageRootDir, 'example4Mobile.png');
const example5Mobile = path.join(imageRootDir, 'example5Mobile.png');
const HomePageVulpesImg = path.join(imageRootDir, 'vulpes/homepage.png');
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');
const faqStoryImage = path.join(imageRootDir, '/faq/img.png');
type FeedbackType = {
author: string;
from: string;
id: string;
rate: number;
text: string;
};
export type StoryFaqModalType = {
button: {
link: string;
text: string;
};
image: ImageType;
text: string;
};
export type StoryFeedbackModalType = {
feedbacks: FeedbackType[];
};
export type StoryGalleryModalType = {
gallery: ImageType[];
};
export type StoryInfoModalType = {
button: {
link: string;
text: string;
};
image: ImageType;
text: string;
title: string;
};
export type StoryQuestPlotModalType = {
background: {
color: string;
images: ImageType[];
};
mobileText: string;
text: string;
title: string;
};
export type StoryCardCardContentType = {
border?: {
inner?: {
color: string;
};
outer?: {
color: string;
};
};
image: ImageType;
size?: {
height?: number;
mobileHeight?: number;
mobileWidth?: number;
width?: number;
};
title: string;
};
export type StoryVulpesContentType = {
image: ImageType;
size?: {
height?: number;
mobileHeight?: number;
mobileWidth?: number;
width?: number;
};
};
export type StoryCardContent = StoryCardCardContentType | StoryVulpesContentType;
export type StoryModalContent = StoryFaqModalType |
StoryFeedbackModalType |
StoryGalleryModalType |
StoryInfoModalType |
StoryQuestPlotModalType;
export type StoryModalType = 'faq' | 'feedback' | 'gallery' | 'info' | 'questPlot';
export type StoryContentType = 'card' | 'vulpes';
export type StoryType = {
card: {
content: StoryCardContent;
type: StoryContentType;
};
id: string;
modal?: {
content?: StoryModalContent;
type: StoryModalType;
};
};
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[] = [
{
card: {
content: {
image: {
alt: 'Ответы на вопросы',
mobileSrc: faqMobileImage,
src: faqImage,
},
size: { height: 240, width: 380 },
title: 'Ответы\\n на вопросы',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
},
type: 'faq',
},
},
{
card: {
content: {
image: {
alt: 'Отзывы наших клиентов',
mobileSrc: feedbackMobileImage,
src: feedbackImage,
},
size: { height: 240, width: 380 },
title: 'Отзывы\\n наших клиентов',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
feedbacks,
},
type: 'feedback',
},
},
{
card: {
content: {
image: {
alt: 'Фотографии и видео',
mobileSrc: photoMobileImage,
src: photoImage,
},
size: { height: 240, width: 380 },
title: 'Фотографии\n и видео',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
gallery,
},
type: 'gallery',
},
},
];
const graduationPageStories: StoryType[] = [
{
card: {
content: {
image: {
alt: 'Ответы на вопросы',
mobileSrc: faqMobileImage,
src: faqImage,
},
size: { height: 240, width: 380 },
title: 'Ответы\\n на вопросы',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
},
type: 'faq',
},
},
{
card: {
content: {
image: {
alt: 'Отзывы наших клиентов',
mobileSrc: feedbackMobileImage,
src: feedbackImage,
},
size: { height: 240, width: 380 },
title: 'Отзывы\\n наших клиентов',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
feedbacks,
},
type: 'feedback',
},
},
{
card: {
content: {
image: {
alt: 'Фотографии и видео',
mobileSrc: photo2MobileImage,
src: photo2Image,
},
size: { height: 240, width: 380 },
title: 'Фотографии\n и видео',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
gallery,
},
type: 'gallery',
},
},
];
const outdoorsPageStories: StoryType[] = [
{
card: {
content: {
image: {
alt: 'Ответы на вопросы',
mobileSrc: faqMobileImage,
src: faqImage,
},
size: { height: 240, width: 380 },
title: 'Ответы\\n на вопросы',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
},
type: 'faq',
},
},
{
card: {
content: {
image: {
alt: 'Отзывы наших клиентов',
mobileSrc: feedbackMobileImage,
src: feedbackImage,
},
size: { height: 240, width: 380 },
title: 'Отзывы\\n наших клиентов',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
feedbacks,
},
type: 'feedback',
},
},
{
card: {
content: {
image: {
alt: 'Фотографии и видео',
mobileSrc: photo2MobileImage,
src: photo2Image,
},
size: { height: 240, width: 380 },
title: 'Фотографии\n и видео',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
gallery,
},
type: 'gallery',
},
},
];
const homePageStories: StoryType[] = [
{
card: {
content: {
image: {
alt: 'Рекомендации по квестам',
mobileSrc: exampleMobile,
src: example,
},
title: 'Рекомендации\\n по квестам',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'fenek',
height: 218,
mobileHeight: 133,
mobileWidth: 110,
src: HomePageVulpesImg,
width: 180,
},
title: '',
},
type: 'vulpes',
},
id: uuid(),
},
{
card: {
content: {
image: {
alt: 'День Рождения в Аркидс парке',
mobileSrc: example2Mobile,
src: example2,
},
title: 'День Рождения\\n в Аркидс парке',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'Новые программы для праздника',
mobileSrc: example3Mobile,
src: example3,
},
title: 'Новые программы\\n для праздника',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'Рекомендации по квестам',
mobileSrc: example4Mobile,
src: example4,
},
title: 'Рекомендации\\n по квестам',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'День Рождения в Аркидс парке',
mobileSrc: example3Mobile,
src: example5,
},
title: 'День Рождения\\n в Аркидс парке',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'Новые программы для праздника',
mobileSrc: exampleMobile,
src: example,
},
title: 'Новые программы\\n для праздника',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
{
card: {
content: {
image: {
alt: 'Новые программы для праздника',
mobileSrc: example2Mobile,
src: example2,
},
title: 'Новые программы\\n для праздника',
},
type: 'card',
},
id: uuid(),
modal: {
content: {
button: {
link: PAGE_LINK.HOME,
text: 'И кнопка ещё будет',
},
image: {
alt: 'example',
src: faqStoryImage,
},
text: 'А здесь будет текст, но пока оставлю здесь'
+ 'текст-рыбу, сорри'
+ '\\n\\n'
+ 'Lorem ipsum dolor sit amet, consectetur\\n'
+ 'adipiscing elit, sed do eiusmod tempor incididunt'
+ 'ut labore et dolore magna aliqua'
+ '\\n\\n'
+ 'Ut enim ad minim veniam, quis nostrud exercitation'
+ 'ullamco laboris nisi ut aliquip ex ea commodo'
+ 'consequat',
title: 'Это будет заголовок истории',
},
type: 'info',
},
},
];
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);
}
};