dashboard: fix toaster

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-02-12 07:43:33 +01:00
parent 6f2aeffdff
commit 5afc49b7e4
20 changed files with 49 additions and 266 deletions

View File

@@ -24,25 +24,20 @@ export function ListDashboards({ dashboards }: ListDashboardsProps) {
const deletion = api.dashboard.delete.useMutation({
onError: (error, variables) => {
return handleErrorToastOptions({
action: (
<ToastAction
altText="Force delete"
onClick={() => {
deletion.mutate({
forceDelete: true,
id: variables.id,
});
}}
>
Force delete
</ToastAction>
),
action: {
label: 'Force delete',
onClick: () => {
deletion.mutate({
forceDelete: true,
id: variables.id,
});
},
},
})(error);
},
onSuccess() {
router.refresh();
toast({
title: 'Success',
toast('Success', {
description: 'Dashboard deleted.',
});
},

View File

@@ -25,13 +25,12 @@ export default function EditOrganization({
const router = useRouter();
const { register, handleSubmit, formState, reset } = useForm<IForm>({
defaultValues: organization,
defaultValues: organization ?? undefined,
});
const mutation = api.organization.update.useMutation({
onSuccess(res) {
toast({
title: 'Organization updated',
toast('Organization updated', {
description: 'Your organization has been updated.',
});
reset(res);
@@ -57,7 +56,7 @@ export default function EditOrganization({
<InputWithLabel
label="Name"
{...register('name')}
defaultValue={organization.name}
defaultValue={organization?.name}
/>
</WidgetBody>
</Widget>

View File

@@ -27,8 +27,7 @@ export function InviteUser() {
const mutation = api.organization.inviteUser.useMutation({
onSuccess() {
toast({
title: 'User invited!',
toast('User invited!', {
description: 'The user has been invited to the organization.',
});
reset();

View File

@@ -35,8 +35,7 @@ export default function EditProfile({ profile }: EditProfileProps) {
const mutation = api.user.update.useMutation({
onSuccess(res) {
toast({
title: 'Profile updated',
toast('Profile updated', {
description: 'Your profile has been updated.',
});
reset(res);