diff --git a/apps/metamigo-frontend/components/signal/bots/SignalBotShow.tsx b/apps/metamigo-frontend/components/signal/bots/SignalBotShow.tsx index 9772c95..e6687b3 100644 --- a/apps/metamigo-frontend/components/signal/bots/SignalBotShow.tsx +++ b/apps/metamigo-frontend/components/signal/bots/SignalBotShow.tsx @@ -138,7 +138,7 @@ const handleRequestCode = async ({ verifyMode, id, onSuccess, - onFailure, + onError, captchaCode = undefined, }: any) => { if (verifyMode === MODE.SMS) console.log("REQUESTING sms"); @@ -160,7 +160,7 @@ const handleRequestCode = async ({ if (response && response.ok) { onSuccess(); } else { - onFailure(response.status || 400); + onError(response.status || 400); } } catch (error: any) { console.error("Failed to request verification code:", error); @@ -171,7 +171,7 @@ const VerificationCodeRequest = ({ verifyMode, data, onSuccess, - onFailure, + onError, }: any) => { React.useEffect(() => { (async () => { @@ -179,10 +179,10 @@ const VerificationCodeRequest = ({ verifyMode, id: data.id, onSuccess, - onFailure, + onError, }); })(); - }, [data.id, onFailure, onSuccess, verifyMode]); + }, [data.id, onError, onSuccess, verifyMode]); return ( <> @@ -204,7 +204,7 @@ const VerificationCaptcha = ({ verifyMode, data, onSuccess, - onFailure, + onError, handleClose, }: any) => { const [code, setCode] = React.useState(undefined); @@ -216,7 +216,7 @@ const VerificationCaptcha = ({ verifyMode, id: data.id, onSuccess, - onFailure, + onError, captchaCode: code, }); setSubmitting(false); @@ -367,7 +367,7 @@ const VerificationCodeDialog = (props: any) => { props.handleClose(); }; - const onFailure = (code: number) => { + const onError = (code: number) => { if (code === 402 || code === 500) { setStage("captcha"); } else { @@ -385,7 +385,7 @@ const VerificationCodeDialog = (props: any) => { )} @@ -400,7 +400,7 @@ const VerificationCodeDialog = (props: any) => { diff --git a/apps/metamigo-frontend/components/users/UserCreate.tsx b/apps/metamigo-frontend/components/users/UserCreate.tsx index e6c26a3..1d8e38d 100644 --- a/apps/metamigo-frontend/components/users/UserCreate.tsx +++ b/apps/metamigo-frontend/components/users/UserCreate.tsx @@ -9,10 +9,10 @@ import { import { useSession } from "next-auth/react"; import { UserRoleInput } from "./shared"; -const UserCreate: FC = (props: any) => { +const UserCreate: FC = () => { const { data: session } = useSession(); return ( - + diff --git a/apps/metamigo-frontend/components/users/UserEdit.tsx b/apps/metamigo-frontend/components/users/UserEdit.tsx index 060f11e..d52e8ab 100644 --- a/apps/metamigo-frontend/components/users/UserEdit.tsx +++ b/apps/metamigo-frontend/components/users/UserEdit.tsx @@ -8,8 +8,8 @@ import { Toolbar, SaveButton, DeleteButton, - EditProps, useRedirect, + useRecordContext, } from "react-admin"; import { useSession } from "next-auth/react"; import { UserRoleInput } from "./shared"; @@ -23,16 +23,20 @@ const useStyles = makeStyles((_theme: any) => ({ })); const UserEditToolbar = (props: any) => { - const classes = useStyles(props); + const classes = useStyles(); const redirect = useRedirect(); + const record = useRecordContext(); + const {session} = props; + + const shouldDisableDelete = !session || !session.user || session.user.id === record.id; return ( - + redirect("/users") }} /> - + ); }; @@ -43,11 +47,11 @@ const UserTitle = ({ record }: { record?: any }) => { return User {title}; }; -const UserEdit = (props: EditProps) => { +const UserEdit = () => { const { data: session } = useSession(); return ( - } {...props}> + }> }> diff --git a/apps/metamigo-frontend/components/users/UserList.tsx b/apps/metamigo-frontend/components/users/UserList.tsx index af2faf0..10d7cca 100644 --- a/apps/metamigo-frontend/components/users/UserList.tsx +++ b/apps/metamigo-frontend/components/users/UserList.tsx @@ -9,8 +9,8 @@ import { ListProps, } from "react-admin"; -const UserList = (props: ListProps) => ( - +const UserList = () => ( + diff --git a/apps/metamigo-frontend/components/users/shared.tsx b/apps/metamigo-frontend/components/users/shared.tsx index da09bb3..dabf6bd 100644 --- a/apps/metamigo-frontend/components/users/shared.tsx +++ b/apps/metamigo-frontend/components/users/shared.tsx @@ -1,14 +1,17 @@ -import { SelectInput } from "react-admin"; +import { SelectInput, useRecordContext } from "react-admin"; -export const UserRoleInput = (props: any) => ( - -); +export const UserRoleInput = (props: any) => { + const record = useRecordContext(); + return ( + + ); +}; diff --git a/apps/metamigo-frontend/components/whatsapp/bots/WhatsappBotShow.tsx b/apps/metamigo-frontend/components/whatsapp/bots/WhatsappBotShow.tsx index fdd0e93..5ab18da 100644 --- a/apps/metamigo-frontend/components/whatsapp/bots/WhatsappBotShow.tsx +++ b/apps/metamigo-frontend/components/whatsapp/bots/WhatsappBotShow.tsx @@ -117,7 +117,7 @@ const Sidebar = ({ record }: any) => { const WhatsappBotShow = (props: ShowProps) => { const refresh = useRefresh(); - const { data } = useGetOne("whatsappBots", props.id as any); + const { data } = useGetOne("whatsappBots", {id: props.id}); const { data: registerData, error: registerError } = useSWR( data && !data?.isVerified