import PropTypes from 'prop-types' import { InputFile } from './styled' import Image from 'next/image' import React from 'react' import { getGlobalStyle } from '../../../utils' import { Skeleton } from '../../molecules/Skeleton' import { Text } from '../../atoms/Text' import { Button, Column, Icon, Tag } from '../../atoms' import styles from './styles.module.css' export interface IStoreInterface { Image: string | undefined | null storeName: string | undefined | null idStore: string | undefined | null scheduleOpenAll: string | undefined | null scheduleOpen: string | undefined | null scheduleClose: string | undefined | null scheduleCloseAll: string | undefined | null scheduleDay: number | undefined | null scheduleId: number | undefined | null scheduleStatus: number | undefined | null scheduleStatusAll: number | undefined | null storeId: number | undefined | null banner: string | undefined | null storeStatus: number | undefined | null } interface IBannerStore { altLogo?: string bnImageFileName?: any fileInputRef?: any fileInputRefLogo?: any handleInputChangeLogo?: () => void handleUpdateBanner?: () => void isEdit?: boolean isTablet: boolean isEmtySchedules?: boolean isLoading?: boolean isMobile?: boolean onTargetClick?: (event: React.MouseEvent) => void onTargetClickLogo?: (event: React.MouseEvent) => void HandleDeleteBanner?: () => void handleDeleteLogo: () => void handleClose?: () => void open?: any openNow?: boolean path?: string | undefined | null src?: string | undefined | null srcLogo?: string | undefined | null store: IStoreInterface } export const BannerStore: React.FC = ({ altLogo = '', fileInputRef, fileInputRefLogo, isEdit = false, isEmtySchedules = true, isLoading = false, isMobile = false, isTablet = false, open, openNow = true, src = process.env.DEFAULTBANNER, srcLogo = process.env.DEFAULTLOGO, store = { Image: process.env.DEFAULTLOGO, storeName: '', banner: process.env.DEFAULTBANNER, cateStore: { cName: '' } }, handleInputChangeLogo = () => { }, onTargetClickLogo = (event) => { return event }, handleClose = () => { }, handleUpdateBanner = () => { }, HandleDeleteBanner = () => { }, handleDeleteLogo = () => { }, onTargetClick = () => { } }) => { const actions = [ { onClick: () => { return HandleDeleteBanner() }, icon: 'IconDelete', actionName: 'Eliminar banner', color: getGlobalStyle('--color-icons-primary'), size: 20, top: isTablet ? 85 : undefined, delay: undefined }, { onClick: onTargetClick, icon: 'IconEdit', actionName: 'Editar', color: getGlobalStyle('--color-icons-primary'), size: 20, top: isTablet ? 10 : 60, delay: '.1s' }, { onClick: onTargetClick, icon: 'IconFileUpload', actionName: 'Subir', color: getGlobalStyle('--color-icons-primary'), size: 20, top: isTablet ? 50 : 100, delay: '.2s' } ] const storeName = store?.storeName !== '' ? store?.storeName : '' const bannerTitle = isEmtySchedules ? `${store?.cateStore?.cName ?? ''} - ${storeName}` : `${store?.cateStore?.cName ?? ''} - ${open}` return (
{isEdit && <> } {isLoading ? :
{bannerTitle}
} {isEdit &&
{actions.map((action, index) => { const { top, delay } = action return ( ) })}
}
{altLogo { return isEdit ? onTargetClickLogo(e) : {} }} src={`${srcLogo}`} width={70} />
{String(store?.storeName)}
) } BannerStore.propTypes = { altLogo: PropTypes.string, bnImageFileName: PropTypes.any, fileInputRef: PropTypes.any, fileInputRefLogo: PropTypes.any, handleInputChangeLogo: PropTypes.func, handleUpdateBanner: PropTypes.func, isEdit: PropTypes.bool, isEmtySchedules: PropTypes.bool, isLoading: PropTypes.bool, isMobile: PropTypes.bool, onTargetClick: PropTypes.func, onTargetClickLogo: PropTypes.func, HandleDeleteBanner: PropTypes.func, handleClose: PropTypes.func, open: PropTypes.any, openNow: PropTypes.bool, path: PropTypes.string, src: PropTypes.string, srcLogo: PropTypes.string }