import React, { useCallback, useState } from 'react' import { Devices } from '../Devices' import { Text } from '../../atoms' import { ProfileInfo } from './ProfileInfo' import { RestaurantInfo } from './RestaurantInfo' import { Button, Container, ContainerColumn } from './styled' interface UserProfileProps { dataForm?: { email: string lastName: string upAddress: any upDateBir: any upPhone: string upZipCode: any username: string } dataStore?: object dataDevice?: any[] deviceId?: any loading?: boolean asEdited?: boolean loadingSubmit?: boolean handleSubmit?: () => void onChange?: () => void useFormatDate?: () => void } export const UserProfile: React.FC = ({ dataForm = {}, dataStore = {}, dataDevice = [], deviceId = null, loading = false, asEdited = false, loadingSubmit = false, handleSubmit = () => { }, onChange = () => { } }) => { const [editingProfile, setEditingProfile] = useState(false) const [editingDataProfile, setEditingDataProfile] = useState(false) const [editingAddress, setEditingAddress] = useState(false) const [currentView, setCurrentView] = useState('Perfil') const handleViewChange = useCallback((tabKey: string) => { setCurrentView(tabKey) }, []) const handleProfileDataEditClick = (): void => { setEditingDataProfile(!editingDataProfile) if (editingDataProfile) { handleSubmit() } } const handleProfileEditClick = (): void => { setEditingProfile(!editingProfile) if (editingProfile) { handleSubmit() } } const handleAddressEditClick = (): void => { setEditingAddress(!editingAddress) if (editingAddress) { handleSubmit() } } const memoizedComponents = { Perfil: ( ), Dispositivos: (
Mis dispositivos
), Restaurante: ( ) } return
{Object.keys(memoizedComponents).map(view => { return ( ) })} {memoizedComponents[currentView]}
}