Skip to content

Commit 4f2af82

Browse files
🔄 refactor: Enhance user feedback during project join process
- Introduced loading state management to disable the "Join project" button while the join operation is in progress. - This change aims to improve the user experience by providing visual feedback during the invitation acceptance process, preventing multiple submissions and clarifying the operation's ongoing status.
1 parent 6eb53d0 commit 4f2af82

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎app/(dashboard)/app/project/join/[invitationCode]/AcceptInvite.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { navigate } from "@/actions";
44
import { Button } from "@/components/ui/button";
55
import { Project } from "@prisma/client";
6+
import { useState } from "react";
67
import { toast } from "sonner";
78

89
interface AcceptInviteProps {
@@ -14,7 +15,10 @@ export const AcceptInvite = ({
1415
handleAcceptInvite,
1516
projectId,
1617
}: AcceptInviteProps) => {
18+
const [isJoining, setIsJoining] = useState(false);
19+
1720
const onAcceptInvite = async () => {
21+
setIsJoining(true);
1822
try {
1923
toast.promise(handleAcceptInvite, {
2024
loading: "Joining project...",
@@ -27,8 +31,9 @@ export const AcceptInvite = ({
2731
} catch (error) {
2832
// Error handling can be expanded as needed
2933
console.error("Error joining project:", error);
34+
setIsJoining(false);
3035
}
3136
};
3237

33-
return <Button onClick={onAcceptInvite}>Join project</Button>;
38+
return <Button onClick={onAcceptInvite} disabled={isJoining} >Join project</Button>;
3439
};

0 commit comments

Comments
 (0)