import * as React from 'react'; import { Box, Typography, Paper, CircularProgress, Alert } from '@mui/material'; import { useResource } from '../hooks/useResource'; import GenericForm from './GenericForm'; import { ConfigContext } from '../App'; export default function ProfileView() { const appConfig = React.useContext(ConfigContext); const profileConfig = appConfig?.profile; const resourceConfig = appConfig?.resources.find(r => r.name === profileConfig?.resource); if (!profileConfig || !resourceConfig) { debugger; return Profile configuration not found.; } const { useMe, useUpdate } = useResource(resourceConfig); const { data: profile, isLoading, error } = useMe(); const updateMutation = useUpdate(); const handleSave = async (formData: any) => { try { const id = profile[resourceConfig.primaryKey]; await updateMutation.mutateAsync({ id, data: formData }); } catch (err) { console.error('Profile update failed:', err); } }; if (isLoading) { return ( ); } if (error) { return Failed to load profile data.; } return ( My Profile window.history.back()} loading={updateMutation.isPending} /> ); }