-
Notifications
You must be signed in to change notification settings - Fork 607
fix: toasts-not-dismissings #2304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
646f6f9
4cfef40
ef559f1
0013f32
87ee808
db0384e
239e616
99145de
4a8933a
4c7fdb2
6433270
0bc677f
0333cb1
1e58f71
c9ec637
697d265
8b3c9cc
fa3d0a3
93c5333
b5a9efb
fc38e9b
46e5766
91ca5e9
b231220
3a10eb8
e06427c
918332d
c8d9410
317760a
4381b08
64a93ce
6628aae
2abc528
6e72da9
8de4ab2
2b866ab
3e25824
82159fd
38037ee
65203ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |||||||||||||||||||||||||||||||||
| import { Checkbox } from "@/components/ui/checkbox"; | ||||||||||||||||||||||||||||||||||
| import { toast } from "@/components/ui/toaster"; | ||||||||||||||||||||||||||||||||||
| import { trpc } from "@/lib/trpc/client"; | ||||||||||||||||||||||||||||||||||
| import { Loader2 } from "lucide-react"; | ||||||||||||||||||||||||||||||||||
| import { CircleCheck, Loader2 } from "lucide-react"; | ||||||||||||||||||||||||||||||||||
| import { useRouter } from "next/navigation"; | ||||||||||||||||||||||||||||||||||
| import { useState } from "react"; | ||||||||||||||||||||||||||||||||||
| type Props = { | ||||||||||||||||||||||||||||||||||
|
|
@@ -17,53 +17,71 @@ export const RoleToggle: React.FC<Props> = ({ roleId, keyId, checked }) => { | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const [optimisticChecked, setOptimisticChecked] = useState(checked); | ||||||||||||||||||||||||||||||||||
| const connect = trpc.rbac.connectRoleToKey.useMutation({ | ||||||||||||||||||||||||||||||||||
| onMutate: () => { | ||||||||||||||||||||||||||||||||||
| setOptimisticChecked(true); | ||||||||||||||||||||||||||||||||||
| toast.loading("Adding Role"); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||||||||||||||||
| toast.success("Role added", { | ||||||||||||||||||||||||||||||||||
| description: "Changes may take up to 60 seconds to take effect.", | ||||||||||||||||||||||||||||||||||
| cancel: { | ||||||||||||||||||||||||||||||||||
| label: "Undo", | ||||||||||||||||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||||||||||||||||
| disconnect.mutate({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onError(err) { | ||||||||||||||||||||||||||||||||||
| console.error(err); | ||||||||||||||||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onSettled: () => { | ||||||||||||||||||||||||||||||||||
| router.refresh(); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| const disconnect = trpc.rbac.disconnectRoleFromKey.useMutation({ | ||||||||||||||||||||||||||||||||||
| onMutate: () => { | ||||||||||||||||||||||||||||||||||
| setOptimisticChecked(false); | ||||||||||||||||||||||||||||||||||
| toast.loading("Removing role"); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||||||||||||||||
| toast.success("Role removed", { | ||||||||||||||||||||||||||||||||||
| description: "Changes may take up to 60 seconds to take effect.", | ||||||||||||||||||||||||||||||||||
| cancel: { | ||||||||||||||||||||||||||||||||||
| label: "Undo", | ||||||||||||||||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||||||||||||||||
| connect.mutate({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onError(err) { | ||||||||||||||||||||||||||||||||||
| console.error(err); | ||||||||||||||||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| onSettled: () => { | ||||||||||||||||||||||||||||||||||
| router.refresh(); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleConnect = async ({ roleId, keyId }: { roleId: string; keyId: string }) => { | ||||||||||||||||||||||||||||||||||
| setOptimisticChecked(true); | ||||||||||||||||||||||||||||||||||
| toast.promise(connect.mutateAsync({ roleId, keyId }), { | ||||||||||||||||||||||||||||||||||
| loading: "Adding Role ...", | ||||||||||||||||||||||||||||||||||
| success: () => ( | ||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||
| <CircleCheck className="w-4 h-4 text-gray-300" /> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| <div className="max-w-[250px]"> | ||||||||||||||||||||||||||||||||||
| <h2 className="font-semibold">Role added</h2> | ||||||||||||||||||||||||||||||||||
| <p>Changes may take up to 60 seconds to take effect.</p> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||
| onClick={() => disconnect.mutate({ roleId, keyId })} | ||||||||||||||||||||||||||||||||||
| className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors" | ||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't hardcode colors please |
||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit The Apply this diff to fix the issue: <button
+ type="button"
onClick={() => disconnect.mutate({ roleId, keyId })}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
| Undo | ||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+49
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update state when 'Undo' is clicked to maintain UI consistency When the 'Undo' button is clicked, the Apply this diff to update the state: <button
type="button"
- onClick={() => disconnect.mutate({ roleId, keyId })}
+ onClick={() => {
+ disconnect.mutate({ roleId, keyId });
+ setOptimisticChecked(false);
+ }}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| error: (error) => `${error.message || "An error occurred while adding the Role ."}`, | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct error message formatting Remove the extra space before the period and use consistent capitalization in the error message. Apply this diff to fix the error message: - error: (error) => `${error.message || "An error occurred while adding the Role ."}`,
+ error: (error) => `${error.message || "An error occurred while adding the role."}`,📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleDisconnect = async ({ roleId, keyId }: { roleId: string; keyId: string }) => { | ||||||||||||||||||||||||||||||||||
| setOptimisticChecked(false); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| toast.promise(disconnect.mutateAsync({ roleId, keyId }), { | ||||||||||||||||||||||||||||||||||
| loading: "Removing Role...", | ||||||||||||||||||||||||||||||||||
| success: () => ( | ||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||||||||||||||||
| <CircleCheck className="w-4 h-4 text-gray-300" /> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| <div className="max-w-[250px]"> | ||||||||||||||||||||||||||||||||||
| <h2 className="font-semibold">Role removed</h2> | ||||||||||||||||||||||||||||||||||
| <p>Changes may take up to 60 seconds to take effect.</p> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||
| onClick={() => connect.mutate({ roleId, keyId })} | ||||||||||||||||||||||||||||||||||
| className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors" | ||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit Similarly, the Apply this diff to fix the issue: <button
+ type="button"
onClick={() => connect.mutate({ roleId, keyId })}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
| Undo | ||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update state when 'Undo' is clicked to maintain UI consistency In this instance, clicking the 'Undo' button does not update the Apply this diff to update the state: <button
type="button"
- onClick={() => connect.mutate({ roleId, keyId })}
+ onClick={() => {
+ connect.mutate({ roleId, keyId });
+ setOptimisticChecked(true);
+ }}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||
| error: (error) => `${error.message || "An error occurred while removing the Role."}`, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (connect.isLoading || disconnect.isLoading) { | ||||||||||||||||||||||||||||||||||
| return <Loader2 className="w-4 h-4 animate-spin" />; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -72,9 +90,9 @@ export const RoleToggle: React.FC<Props> = ({ roleId, keyId, checked }) => { | |||||||||||||||||||||||||||||||||
| checked={optimisticChecked} | ||||||||||||||||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||||||||||||||||
| if (optimisticChecked) { | ||||||||||||||||||||||||||||||||||
| disconnect.mutate({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| handleDisconnect({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||
| connect.mutate({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| handleConnect({ roleId, keyId }); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,9 +3,10 @@ | |||||||||||||||||||
| import { Checkbox } from "@/components/ui/checkbox"; | ||||||||||||||||||||
| import { toast } from "@/components/ui/toaster"; | ||||||||||||||||||||
| import { trpc } from "@/lib/trpc/client"; | ||||||||||||||||||||
| import { Loader2 } from "lucide-react"; | ||||||||||||||||||||
| import { CircleCheck, Loader2 } from "lucide-react"; | ||||||||||||||||||||
| import { useRouter } from "next/navigation"; | ||||||||||||||||||||
| import { useState } from "react"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| type Props = { | ||||||||||||||||||||
| permissionId: string; | ||||||||||||||||||||
| roleId: string; | ||||||||||||||||||||
|
|
@@ -16,54 +17,73 @@ export const PermissionToggle: React.FC<Props> = ({ roleId, permissionId, checke | |||||||||||||||||||
| const router = useRouter(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const [optimisticChecked, setOptimisticChecked] = useState(checked); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const connect = trpc.rbac.connectPermissionToRole.useMutation({ | ||||||||||||||||||||
| onMutate: () => { | ||||||||||||||||||||
| setOptimisticChecked(true); | ||||||||||||||||||||
| toast.loading("Adding Permission"); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||
| toast.success("Permission added", { | ||||||||||||||||||||
| description: "Changes may take up to 60 seconds to take effect.", | ||||||||||||||||||||
| cancel: { | ||||||||||||||||||||
| label: "Undo", | ||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||
| disconnect.mutate({ roleId, permissionId }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onError(err) { | ||||||||||||||||||||
| console.error(err); | ||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onSettled: () => { | ||||||||||||||||||||
| router.refresh(); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const disconnect = trpc.rbac.disconnectPermissionFromRole.useMutation({ | ||||||||||||||||||||
| onMutate: () => { | ||||||||||||||||||||
| setOptimisticChecked(false); | ||||||||||||||||||||
| toast.loading("Removing Permission"); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onSuccess: () => { | ||||||||||||||||||||
| toast.success("Permission removed", { | ||||||||||||||||||||
| description: "Changes may take up to 60 seconds to take effect.", | ||||||||||||||||||||
| cancel: { | ||||||||||||||||||||
| label: "Undo", | ||||||||||||||||||||
| onClick: () => { | ||||||||||||||||||||
| connect.mutate({ roleId, permissionId }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onError(err) { | ||||||||||||||||||||
| console.error(err); | ||||||||||||||||||||
| toast.error(err.message); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| onSettled: () => { | ||||||||||||||||||||
| router.refresh(); | ||||||||||||||||||||
| }, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const handleConnect = async (roleId: string, permissionId: string) => { | ||||||||||||||||||||
| setOptimisticChecked(true); | ||||||||||||||||||||
| toast.promise(connect.mutateAsync({ roleId, permissionId }), { | ||||||||||||||||||||
|
Comment on lines
+33
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revert optimistic UI update if the mutation fails In Consider reverting Apply this change: const handleConnect = async (roleId: string, permissionId: string) => {
setOptimisticChecked(true);
toast.promise(connect.mutateAsync({ roleId, permissionId }), {
loading: "Adding Permission ...",
success: () => (
// success handling
),
error: (error) => {
+ setOptimisticChecked(false);
`${error.message || "An error occurred while adding the permission."}`
},
});
};Similarly, in const handleDisconnect = async (roleId: string, permissionId: string) => {
setOptimisticChecked(false);
toast.promise(disconnect.mutateAsync({ roleId, permissionId }), {
loading: "Removing Permission ...",
success: () => (
// success handling
),
error: (error) => {
+ setOptimisticChecked(true);
`${error.message || "An error occurred while removing the permission."}`
},
});
};Also applies to: 57-58
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense I think
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chronark, glad the suggestion makes sense! Let me know if you have any questions or need further assistance. (_/) |
||||||||||||||||||||
| loading: "Adding Permission ...", | ||||||||||||||||||||
| success: () => ( | ||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||
| <CircleCheck className="w-4 h-4 text-gray-300" /> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <div className="max-w-[250px]"> | ||||||||||||||||||||
| <h2 className="font-semibold">Permission added</h2> | ||||||||||||||||||||
| <p>Changes may take up to 60 seconds to take effect.</p> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <div> | ||||||||||||||||||||
| <button | ||||||||||||||||||||
| onClick={() => disconnect.mutate({ roleId, permissionId })} | ||||||||||||||||||||
| className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors" | ||||||||||||||||||||
| > | ||||||||||||||||||||
|
Comment on lines
+47
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit The Apply this diff to fix the issue: <button
+ type="button"
onClick={() => disconnect.mutate({ roleId, permissionId })}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||
| Undo | ||||||||||||||||||||
| </button> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| ), | ||||||||||||||||||||
| error: (error) => `${error.message || "An error occurred while adding the permission."}`, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const handleDisconnect = async (roleId: string, permissionId: string) => { | ||||||||||||||||||||
| setOptimisticChecked(false); | ||||||||||||||||||||
| toast.promise(disconnect.mutateAsync({ roleId, permissionId }), { | ||||||||||||||||||||
| loading: "Removing Permission ...", | ||||||||||||||||||||
| success: () => ( | ||||||||||||||||||||
| <div className="flex items-center gap-2"> | ||||||||||||||||||||
| <CircleCheck className="w-4 h-4 text-gray-300" /> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <div className="max-w-[250px]"> | ||||||||||||||||||||
| <h2 className="font-semibold">Permission removed</h2> | ||||||||||||||||||||
| <p>Changes may take up to 60 seconds to take effect.</p> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <div> | ||||||||||||||||||||
| <button | ||||||||||||||||||||
| onClick={() => connect.mutate({ roleId, permissionId })} | ||||||||||||||||||||
| className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors" | ||||||||||||||||||||
| > | ||||||||||||||||||||
|
Comment on lines
+74
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit Similar to the previous instance, ensure the Apply this diff to fix the issue: <button
+ type="button"
onClick={() => connect.mutate({ roleId, permissionId })}
className="bg-[#2c2c2c] text-white px-[4px] py-[2px] rounded hover:bg-[#3c3c3c] transition-colors"
>📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome
|
||||||||||||||||||||
| Undo | ||||||||||||||||||||
| </button> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| ), | ||||||||||||||||||||
| error: (error) => `${error.message || "An error occurred while removing the permission."}`, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (connect.isLoading || disconnect.isLoading) { | ||||||||||||||||||||
| return <Loader2 className="w-4 h-4 animate-spin" />; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -72,9 +92,9 @@ export const PermissionToggle: React.FC<Props> = ({ roleId, permissionId, checke | |||||||||||||||||||
| checked={optimisticChecked} | ||||||||||||||||||||
| onClick={() => { | ||||||||||||||||||||
| if (optimisticChecked) { | ||||||||||||||||||||
| disconnect.mutate({ roleId, permissionId }); | ||||||||||||||||||||
| handleDisconnect(roleId, permissionId); | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| connect.mutate({ roleId, permissionId }); | ||||||||||||||||||||
| handleConnect(roleId, permissionId); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }} | ||||||||||||||||||||
| /> | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we doing custom components here?
the toast already has a way to display an action
https://sonner.emilkowal.ski/toast#action