import { SERVICES } from '../constants/services' import { MANAGER_TOOLS } from '../constants/tools' import { logger } from './logger' const fieldTypeEnum = { TITLE: 'title', DESCRIPTION: 'description', HERO_IMAGE: 'heroImageUrl', ICON: 'iconUrl', } const getDataForServiceType = (type, fieldType) => { const serviceData = [...SERVICES, ...MANAGER_TOOLS].find( (serviceData) => serviceData.type === type ) if (!serviceData || !serviceData[fieldTypeEnum[fieldType]]) { logger.error(new Error(`No data for: ${fieldType} for service with type: ${type}`)) return { type: 'UNKNOWN', title: 'Service', titleFr: 'Service', description: '', descriptionFr: '', heroImageUrl: '', iconUrl: '', } } else { return serviceData[fieldTypeEnum[fieldType]] } } const getLabelForServiceType = (type) => { switch (type) { case 'TRAINER': return 'Personal trainer' case 'TAILOR': return 'Dry cleaner' case 'CLEANING': return 'House cleaning' case 'MASSAGE': return 'Massage' case 'FLOWER': return 'Florist' case 'DOG': return 'Dog walker' case 'TICKET': return 'Ticket' case 'CAR_WASH': return 'Car wash' case 'HANDYMAN': return 'Handyman' } } export default { getDataForServiceType, getLabelForServiceType, }