import Alert from "@mui/material/Alert"; import Skeleton from "@mui/material/Skeleton"; import { ApiService } from "services/api/core"; import { UserProfile } from "services/api/types"; import { InputList } from "components/Inputs/InputList"; import { useLang } from "services/lang"; import { FC, useState } from "react"; import LinearProgress from "@mui/material/LinearProgress"; import InputBoolean from "components/Inputs/Base/InputBoolean"; export type UserProfileProps = { api: ApiService; }; export const UserProfileEditor: FC = ({ api }) => { const [saving, setIsSaving] = useState(false); const profile = api.state.userProfile; const lang = useLang(); if (!profile.ready) { return (
); } if (!profile.ok) { return (
{JSON.stringify(profile.error)}
); } const update = (key: K) => (data: D) => { if (profile.ready) { setIsSaving(true); api .setProfile({ ...profile.data, [key]: data, }) .then(() => { setIsSaving(false); }); } }; const updateFlag = ( key: K ) => (data: D) => { if (profile.ready) { setIsSaving(true); api .setProfile({ ...profile.data, flags: { ...profile.data.flags, [key]: data, }, }) .then(() => { setIsSaving(false); }); } }; return (
{saving && }
); };