-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #386 from Sid-80/feat/384
Feat/384
- Loading branch information
Showing
5 changed files
with
133 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from "../ui/alert-dialog"; | ||
import { Button } from "../ui/button"; | ||
import { CheckCircle2, Trash2 } from "lucide-react"; | ||
import axiosInstance from "@/config/AxiosInstance"; | ||
import { deleteTeamMemberUrl } from "@/lib/API-URLs"; | ||
import { useSelector } from "react-redux"; | ||
import { RootState } from "@/app/store"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
type Props = { | ||
email: string; | ||
}; | ||
|
||
export default function DeleteTeamMember({ email }: Props) { | ||
const [isSubmitted, setIsSubmitted] = useState(false); | ||
const router = useRouter(); | ||
const teamId = useSelector((state: RootState) => state.team.teamId); | ||
|
||
const DeleteHandler = async () => { | ||
try { | ||
axiosInstance.put(`${deleteTeamMemberUrl}/${teamId}`, { email }) | ||
.then((res)=>{ | ||
if(res.status === 200) setIsSubmitted(true); | ||
}) | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
}; | ||
|
||
return ( | ||
<AlertDialog> | ||
<AlertDialogTrigger> | ||
<Button size={"icon"} className=" bg-red-600 hover:bg-red-700"> | ||
<Trash2 className="w-5 h-5" /> | ||
</Button> | ||
</AlertDialogTrigger> | ||
<AlertDialogContent> | ||
{!isSubmitted && ( | ||
<> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
This action cannot be undone. This will remove the member from | ||
the team and files created by the member will be permanently | ||
deleted. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
<Button onClick={() => DeleteHandler()}>Continue</Button> | ||
</AlertDialogFooter> | ||
</> | ||
)} | ||
{isSubmitted && ( | ||
<> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle className="flex gap-2"> | ||
<p>Team Member Removed Successfully!!</p>{" "} | ||
<CheckCircle2 className="w-6 h-6" /> | ||
</AlertDialogTitle> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter> | ||
<AlertDialogAction | ||
onClick={() => { | ||
router.push('/dashboard') | ||
}} | ||
> | ||
Continue | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</> | ||
)} | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const changeToPrivateUrl = "/api/files/private" | ||
export const changeToPublicUrl = "/api/files/public" | ||
export const getTeamMembersData = "/api/teams/members"; | ||
export const getTeamMembersData = "/api/teams/members"; | ||
export const deleteTeamMemberUrl = "/api/teams/members"; |