diff --git a/devsoc24-portal-fe/src/app/edit-idea/page.tsx b/devsoc24-portal-fe/src/app/edit-idea/page.tsx index ba594f0..c96cdbe 100644 --- a/devsoc24-portal-fe/src/app/edit-idea/page.tsx +++ b/devsoc24-portal-fe/src/app/edit-idea/page.tsx @@ -17,7 +17,7 @@ export default function Page() { title
- +
diff --git a/devsoc24-portal-fe/src/app/edit-project/page.tsx b/devsoc24-portal-fe/src/app/edit-project/page.tsx index a2aa4de..a143286 100644 --- a/devsoc24-portal-fe/src/app/edit-project/page.tsx +++ b/devsoc24-portal-fe/src/app/edit-project/page.tsx @@ -15,7 +15,7 @@ export default function Page() { title
- +
diff --git a/devsoc24-portal-fe/src/app/home/page.tsx b/devsoc24-portal-fe/src/app/home/page.tsx index 2fb8f49..5a693b1 100644 --- a/devsoc24-portal-fe/src/app/home/page.tsx +++ b/devsoc24-portal-fe/src/app/home/page.tsx @@ -33,6 +33,7 @@ import ToastContainer from "@/components/ToastContainer"; import Link from "next/link"; import TimelineComponent from "@/components/timeline/timelineComponent"; import LeaveTeam from "@/components/team/leaveTeam"; +import Kick from "@/components/team/kick"; interface ideaProps { message: string; @@ -311,8 +312,9 @@ export default function HomePage() {
{showModal === "leave" && } + {showModal === "kick" && }
- +
{team ? ( diff --git a/devsoc24-portal-fe/src/app/submit-idea/page.tsx b/devsoc24-portal-fe/src/app/submit-idea/page.tsx index 0bfbf64..c4cb599 100644 --- a/devsoc24-portal-fe/src/app/submit-idea/page.tsx +++ b/devsoc24-portal-fe/src/app/submit-idea/page.tsx @@ -18,7 +18,7 @@ export default function Page() { title
- +
diff --git a/devsoc24-portal-fe/src/app/submit-project/page.tsx b/devsoc24-portal-fe/src/app/submit-project/page.tsx index ef47e43..5174d13 100644 --- a/devsoc24-portal-fe/src/app/submit-project/page.tsx +++ b/devsoc24-portal-fe/src/app/submit-project/page.tsx @@ -1,27 +1,31 @@ -"use client" +"use client"; import Image from "next/image"; import Logo from "@/components/logo"; import Dashtitle from "@/assets/images/titleDashboard.svg"; -import active from "@/assets/images/active.svg" +import active from "@/assets/images/active.svg"; import SubmitProjectForm from "./submit-project-form"; -import { ArrowLeft } from 'lucide-react'; +import { ArrowLeft } from "lucide-react"; import Link from "next/link"; export default function Page() { - return ( -
-
- - title -
-
- -
-
-

Project Submission For Devsoc24

- -
-
- ) -} \ No newline at end of file + return ( +
+
+ + title +
+
+ + + +
+
+

+ Project Submission For Devsoc24 +

+ +
+
+ ); +} diff --git a/devsoc24-portal-fe/src/components/team/joinTeam.tsx b/devsoc24-portal-fe/src/components/team/joinTeam.tsx index a7c10ba..401fc02 100644 --- a/devsoc24-portal-fe/src/components/team/joinTeam.tsx +++ b/devsoc24-portal-fe/src/components/team/joinTeam.tsx @@ -13,7 +13,7 @@ import axios, { AxiosResponse } from "axios"; import { useIdeaStore, useTeamDataStore, useTeamStore, useUserStore } from "@/store/store"; import { userProps } from "@/interfaces"; import { useRouter } from "next/navigation"; -import { APIResponse } from "@/schemas/api"; +import { type APIResponse } from "@/schemas/api"; function JoinTeam() { const inputRef = useRef(null); diff --git a/devsoc24-portal-fe/src/components/team/kick.tsx b/devsoc24-portal-fe/src/components/team/kick.tsx new file mode 100644 index 0000000..c023e9a --- /dev/null +++ b/devsoc24-portal-fe/src/components/team/kick.tsx @@ -0,0 +1,131 @@ +import { + Dialog, + DialogClose, + DialogContent, + DialogTitle, +} from "@radix-ui/react-dialog"; +import { Label } from "@radix-ui/react-label"; +import React, { useState } from "react"; +import { Button } from "../ui/button"; +import { DialogHeader, DialogFooter } from "../ui/dialog"; +import { type APIResponse } from "@/schemas/api"; +import { + useTeamStore, + useUserStore, + useIdeaStore, + useTeamEditStore, + useLeaderStore, + showModalStore, + showkickStore, + useTeamDataStore, +} from "@/store/store"; +import axios from "axios"; +import toast from "react-hot-toast"; +import { userProps } from "@/interfaces"; +import router from "next/navigation"; +import { useRouter } from "next/navigation"; + +const Kick = () => { + const { team, setTeam } = useTeamStore(); + const { showModal, setShowModal } = showModalStore(); + const { kickMate, setKickMate } = showkickStore(); + const { teamData, setTeamData } = useTeamDataStore(); + + const router = useRouter(); + + const fetchTeam = async () => { + try { + console.log("fetch team"); + const response = await axios.get( + `${process.env.NEXT_PUBLIC_API_URL}/team`, + { + withCredentials: true, + }, + ); + setTeamData(response.data); + } catch (e) { + if (axios.isAxiosError(e)) { + switch (e.response?.status) { + case 401: + void router.push("/"); + break; + case 404: + console.log("Idea Not found, but in a team"); + break; + case 409: + console.log("Not in team"); + break; + default: + console.log(e); + break; + } + } + } + }; + + const leaveTeam = async () => { + const handleClick = async () => { + await axios.post( + `${process.env.NEXT_PUBLIC_API_URL}/team/kick`, + { id: kickMate }, + { + withCredentials: true, + }, + ); + setShowModal(""); + }; + + await toast.promise(handleClick(), { + loading: "Loading...", + success: (temp) => { + return `Accepted`; + }, + error: `Something went wrong`, + }); + await fetchTeam(); + }; + + return ( +
+
+ +

+ Are you sure you want to kick your team mate? +

+
+ + +
+
+
+ ); +}; + +export default Kick; diff --git a/devsoc24-portal-fe/src/components/team/leaveTeam.tsx b/devsoc24-portal-fe/src/components/team/leaveTeam.tsx index 444d855..b909297 100644 --- a/devsoc24-portal-fe/src/components/team/leaveTeam.tsx +++ b/devsoc24-portal-fe/src/components/team/leaveTeam.tsx @@ -14,7 +14,7 @@ import { useUserStore, useIdeaStore, useTeamEditStore, - useLeaderStore, + useTeamDataStore, showModalStore, } from "@/store/store"; import axios from "axios"; @@ -27,18 +27,20 @@ const LeaveTeam = () => { const { team, setTeam } = useTeamStore(); const { user, setUser } = useUserStore(); const { showModal, setShowModal } = showModalStore(); + const { teamData, setTeamData } = useTeamDataStore(); const router = useRouter(); const fetchTeam = async () => { try { + console.log("fetching team") const response = await axios.get( `${process.env.NEXT_PUBLIC_API_URL}/team`, { withCredentials: true, }, ); - setUser(response.data); + setTeamData(response.data); } catch (e) { if (axios.isAxiosError(e)) { switch (e.response?.status) { @@ -64,9 +66,10 @@ const LeaveTeam = () => { await axios.delete(`${process.env.NEXT_PUBLIC_API_URL}/team/leave`, { withCredentials: true, }); + setShowModal("") }; - void toast.promise(handleClick(), { + await toast.promise(handleClick(), { loading: "Loading...", success: (temp) => { setTeam(true); @@ -75,6 +78,8 @@ const LeaveTeam = () => { }, error: `Something went wrong`, }); + + }; return ( diff --git a/devsoc24-portal-fe/src/components/teamCard.tsx b/devsoc24-portal-fe/src/components/teamCard.tsx index f5af223..dc835e9 100644 --- a/devsoc24-portal-fe/src/components/teamCard.tsx +++ b/devsoc24-portal-fe/src/components/teamCard.tsx @@ -12,7 +12,8 @@ import { useTeamEditStore, useTeamStore, useUserStore, - showModalStore + showModalStore, + showkickStore, } from "@/store/store"; import { useRouter } from "next/navigation"; import editImg from "@/assets/images/edit.svg"; @@ -34,7 +35,8 @@ const TeamCard: React.FC = (props) => { const { idea, setIdea } = useIdeaStore(); const { edit, setEdit } = useTeamEditStore(); const { isLeader, setIsLeader } = useLeaderStore(); - const {showModal, setShowModal} = showModalStore(); + const { showModal, setShowModal } = showModalStore(); + const { kickMate, setKickMate } = showkickStore(); const handleDialogTriggerClick = (modalType: string) => { setShowModal(modalType); @@ -113,7 +115,6 @@ const TeamCard: React.FC = (props) => { return ( <>
-

Your Devsoc Team

@@ -164,7 +165,12 @@ const TeamCard: React.FC = (props) => { > {member.name} -
handleDialogTriggerClick("leave")}> +
{ + handleDialogTriggerClick("kick"); + setKickMate(member.id); + }} + > {edit ? : <>} diff --git a/devsoc24-portal-fe/src/store/store.tsx b/devsoc24-portal-fe/src/store/store.tsx index 06799a5..a38f3f3 100644 --- a/devsoc24-portal-fe/src/store/store.tsx +++ b/devsoc24-portal-fe/src/store/store.tsx @@ -135,3 +135,13 @@ export const showModalStore = create((set) => ({ showModal: "", setShowModal: (showModal: string) => set({ showModal }), })); + +interface kickStore { + kickMate: string; + setKickMate: (kickMate: string) => void; +} + +export const showkickStore = create((set) => ({ + kickMate: "", + setKickMate: (kickMate: string) => set({ kickMate }), +}));