'use client' import { useState, useCallback } from 'react' import { toggleIndex } from './helpers' import { IconLogout, IconNotification, IconShopping } from '../../../assets/icons' import { Button, Column, Icon, Overline, Row, Text } from '../../atoms' import { ThemeToggle } from '../../molecules' import { PColor, SECColor } from '../../../assets/colors' import { getGlobalStyle } from '../../../helpers' import styles from './styles.module.css' interface OptionsProps { userConsent: NotificationPermission pushNotificationSupported: boolean userSubscription?: PushSubscription | null pushServerSubscriptionId?: string | null countOrders: number theme: 'light' | 'dark' toggleTheme: () => void onClickLogout: () => Promise | void onClickAskUserPermission: () => void onClickSusbribeToPushNotification: () => void onClickSendSubscriptionToPushServer: () => void onClickSendNotification: () => void setIsOpenOrder: (state: boolean) => void } export const Options = ({ userConsent, pushNotificationSupported, userSubscription, pushServerSubscriptionId, countOrders, theme, toggleTheme, onClickLogout, onClickAskUserPermission, onClickSusbribeToPushNotification, onClickSendSubscriptionToPushServer, onClickSendNotification, setIsOpenOrder }: OptionsProps) => { const [openIndex, setOpenIndex] = useState(false) const isConsentGranted = userConsent === 'granted' const handleToggle = useCallback( (index: number) => setOpenIndex(prev => toggleIndex(prev, index)), [] ) return (
setOpenIndex(false)} />
{!isConsentGranted && pushNotificationSupported && ( Habilita las notificaciones )} {isConsentGranted && ( Las notificaciones están activas )} Consentimiento: {userConsent} {pushServerSubscriptionId && ( )}
Configuración
) }