import path from 'path'; import { Request, Response } from 'express'; import { ImageSection, PAGE_LINK } from '../../../constants'; export type ImagePosition = { bottom?: number | string; left?: number | string; right?: number | string; top?: number | string; }; export type ImageType = { alt?: string; height?: number; mobileHeight?: number; mobilePosition?: ImagePosition; mobileSrc?: string; mobileWidth?: number; position?: ImagePosition; src: string; width?: number; }; const imageRootDir = 'static/images/title/'; const faqMobileImage = path.join(imageRootDir, 'faq/mobile.png'); const faqDesktopImage = path.join(imageRootDir, 'faq/desktop.png'); const contactsMobileImage = path.join(imageRootDir, 'contacts/mobile.png'); const contactsDesktopImage = path.join(imageRootDir, 'contacts/desktop.png'); const aboutMobileImage = path.join(imageRootDir, 'about/mobile.png'); const aboutDesktopImage = path.join(imageRootDir, 'about/desktop.png'); const masterClassesMobileImage = path.join(imageRootDir, 'master-classes/mobile.png'); const masterClassesDesktopImage = path.join(imageRootDir, 'master-classes/desktop.png'); const showProgramsMobileImage = path.join(imageRootDir, 'show-programs/mobile.png'); const showProgramsDesktopImage = path.join(imageRootDir, 'show-programs/desktop.png'); const priceMobileImage = path.join(imageRootDir, 'price/mobile.png'); const priceDesktopImage = path.join(imageRootDir, 'price/desktop.png'); const themedCombosMobileImage = path.join(imageRootDir, 'themed-combos/mobile.png'); const themedCombosDesktopImage = path.join(imageRootDir, 'themed-combos/desktop.png'); const themedCombosBannerMobileImage = path.join('static/images/themed-combos/', 'banner/mobile.png'); const themedCombosBannerDesktopImage = path.join('static/images/themed-combos/', 'banner/desktop.png'); export const getTitleImage = (req: Request, res: Response) => { // @ts-ignore const { body } = req; const { page, section } = body; switch (page) { case PAGE_LINK.FAQ: { return res.status(200).json({ alt: 'faq', height: 575, mobileHeight: 704, mobilePosition: { left: -20, top: -174, }, mobileSrc: faqMobileImage, mobileWidth: 385, position: { left: 126, top: -162, }, src: faqDesktopImage, width: 1153, }); } case PAGE_LINK.CONTACTS: { return res.status(200).json({ alt: 'contacts', height: 584, mobileHeight: 700, mobilePosition: { left: -20, top: -175, }, mobileSrc: contactsMobileImage, mobileWidth: 390, position: { left: 75, top: -160, }, src: contactsDesktopImage, width: 1158, }); } case PAGE_LINK.ABOUT: { return res.status(200).json({ alt: 'about', height: 584, mobileHeight: 700, mobilePosition: { left: -20, top: -175, }, mobileSrc: aboutMobileImage, mobileWidth: 390, position: { left: 170, top: -155, }, src: aboutDesktopImage, width: 1158, }); } case PAGE_LINK.PRICE: { return res.status(200).json({ alt: 'price', height: 571, mobileHeight: 694, mobilePosition: { left: 0, top: -175, }, mobileSrc: priceMobileImage, mobileWidth: 390, position: { left: 170, top: -155, }, src: priceDesktopImage, width: 1067, }); } case PAGE_LINK.MASTER_CLASSES: { return res.status(200).json({ alt: 'master-classes', mobileSrc: masterClassesMobileImage, src: masterClassesDesktopImage, }); } case PAGE_LINK.SHOW_PROGRAMS: { return res.status(200).json({ alt: 'show-programs', mobileSrc: showProgramsMobileImage, src: showProgramsDesktopImage, }); } case PAGE_LINK.THEMED_COMBOS: { switch (section) { case ImageSection.TITLE: return res.status(200).json({ alt: 'themed-combos', mobileSrc: themedCombosMobileImage, src: themedCombosDesktopImage, }); case ImageSection.BANNER: return res.status(200).json({ alt: 'themed-combos', height: 326, mobileHeight: 193, mobilePosition: { right: -11, top: -44, }, mobileSrc: themedCombosBannerMobileImage, mobileWidth: 249, position: { right: -20, top: -70, }, src: themedCombosBannerDesktopImage, width: 642, }); default: return res.status(404); } } default: return res.status(404); } };