import { ChevronRightRounded } from "@mui/icons-material"; import { Box, List, ListItem, ListItemButton, ListItemText, ListSubheader, } from "@mui/material"; import CircularProgress from "@mui/material/CircularProgress"; import React, { ReactNode, useState } from "react"; import isAsyncFunction from "@/utils/is-async-function"; interface ItemProps { label: ReactNode; extra?: ReactNode; children?: ReactNode; secondary?: ReactNode; onClick?: () => void | Promise; } export const SettingItem: React.FC = (props) => { const { label, extra, children, secondary, onClick } = props; const clickable = !!onClick; const primary = ( {label} {extra ? extra : null} ); const [isLoading, setIsLoading] = useState(false); const handleClick = () => { if (onClick) { if (isAsyncFunction(onClick)) { setIsLoading(true); onClick()!.finally(() => setIsLoading(false)); } else { onClick(); } } }; return clickable ? ( {isLoading ? ( ) : ( )} ) : ( {children} ); }; export const SettingList: React.FC<{ title: string; children: ReactNode; }> = (props) => ( { return { color: palette.text.primary, }; }, ]} disableSticky > {props.title} {props.children} );