Skip to content

Commit

Permalink
Merge pull request #31 from NishantGupt786/master
Browse files Browse the repository at this point in the history
pr
  • Loading branch information
NishantGupt786 authored Mar 12, 2024
2 parents 7257108 + 65e3c3f commit d9351d0
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 31 deletions.
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/edit-idea/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function Page() {
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<div className="flex h-[100vh] w-[4.7rem] items-start justify-center gap-x-8 bg-background px-6 py-2 pt-12 max-[445px]:w-[3.7rem]">
<Link href="/">
<Link href="/home">
<ArrowLeft className="text-[#0019FF]" />
</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/edit-project/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Page() {
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<div className="flex h-[100vh] w-[4.7rem] items-start justify-center gap-x-8 bg-background px-6 py-2 pt-12 max-[445px]:w-[3.7rem]">
<Link href="/">
<Link href="/home">
<ArrowLeft className="text-[#0019FF]" />
</Link>
</div>
Expand Down
4 changes: 3 additions & 1 deletion devsoc24-portal-fe/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -311,8 +312,9 @@ export default function HomePage() {
</div>
<div className="flex flex-col">
{showModal === "leave" && <LeaveTeam />}
{showModal === "kick" && <Kick />}
<div className="my-8 px-4">
<TimelineComponent count={2} />
<TimelineComponent count={4} />
</div>
<div className="mt-4 flex h-fit w-full flex-col justify-between gap-4 overflow-y-auto px-4 md:flex-row lg:h-[85%]">
{team ? (
Expand Down
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/app/submit-idea/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Page() {
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<div className="flex h-[100vh] w-[4.7rem] items-start justify-center gap-x-8 bg-background px-6 py-2 pt-12 max-[445px]:w-[3.7rem]">
<Link href="/">
<Link href="/home">
<ArrowLeft className="text-[#0019FF]" />
</Link>
</div>
Expand Down
42 changes: 23 additions & 19 deletions devsoc24-portal-fe/src/app/submit-project/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<main className="flex min-[931px]:min-h-screen flex-col min-[931px]:h-[100vh] h-[200%] items-start bg-[#F4F5FA] overflow-x-hidden">
<div className="flex h-[10%] w-full items-center gap-x-8 bg-background px-3 py-2">
<Logo className="h-9/10 w-auto" />
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<div className="flex h-[100vh] w-[4.7rem] max-[445px]:w-[3.7rem] items-start justify-center gap-x-8 bg-background px-6 py-2 pt-12">
<Link href="/"><ArrowLeft className="text-[#0019FF]" /></Link>
</div>
<div className="mt-[11vh] ml-[4.7rem] max-[445px]:ml-[3.7rem] absolute pt-5 pl-5 bg-[#F4F5FA] w-[91.9vw] flex flex-col max-[931px]:justify-center ">
<p className="text-black text-4xl font-medium mb-4">Project Submission For Devsoc24</p>
<SubmitProjectForm />
</div>
</main>
)
}
return (
<main className="flex h-[200%] flex-col items-start overflow-x-hidden bg-[#F4F5FA] min-[931px]:h-[100vh] min-[931px]:min-h-screen">
<div className="flex h-[10%] w-full items-center gap-x-8 bg-background px-3 py-2">
<Logo className="h-9/10 w-auto" />
<Image src={Dashtitle as HTMLImageElement} alt="title" />
</div>
<div className="flex h-[100vh] w-[4.7rem] items-start justify-center gap-x-8 bg-background px-6 py-2 pt-12 max-[445px]:w-[3.7rem]">
<Link href="/home">
<ArrowLeft className="text-[#0019FF]" />
</Link>
</div>
<div className="absolute ml-[4.7rem] mt-[11vh] flex w-[91.9vw] flex-col bg-[#F4F5FA] pl-5 pt-5 max-[931px]:justify-center max-[445px]:ml-[3.7rem] ">
<p className="mb-4 text-4xl font-medium text-black">
Project Submission For Devsoc24
</p>
<SubmitProjectForm />
</div>
</main>
);
}
2 changes: 1 addition & 1 deletion devsoc24-portal-fe/src/components/team/joinTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLInputElement>(null);
Expand Down
131 changes: 131 additions & 0 deletions devsoc24-portal-fe/src/components/team/kick.tsx
Original file line number Diff line number Diff line change
@@ -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<APIResponse>(
`${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 (
<div className="fixed inset-0 z-[60] flex items-center justify-center backdrop-blur-sm backdrop-brightness-50 backdrop-filter">
<div className="rounded-lg bg-white p-8">
<button
className="absolute right-0 top-0 p-2 text-gray-500"
onClick={() => setShowModal("")}
>
<svg
className="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</button>
<h2 className="text-xl font-semibold text-gray-800">
Are you sure you want to kick your team mate?
</h2>
<div className="mt-4 flex justify-center">
<button
onClick={leaveTeam}
className="mr-4 rounded-md bg-[#458B71] px-4 py-2 text-white"
>
Yes
</button>
<button
onClick={() => setShowModal("")}
className="rounded-md bg-[#458B71] px-4 py-2 text-white"
>
No
</button>
</div>
</div>
</div>
);
};

export default Kick;
11 changes: 8 additions & 3 deletions devsoc24-portal-fe/src/components/team/leaveTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useUserStore,
useIdeaStore,
useTeamEditStore,
useLeaderStore,
useTeamDataStore,
showModalStore,
} from "@/store/store";
import axios from "axios";
Expand All @@ -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<userProps>(
`${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) {
Expand All @@ -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);
Expand All @@ -75,6 +78,8 @@ const LeaveTeam = () => {
},
error: `Something went wrong`,
});


};

return (
Expand Down
14 changes: 10 additions & 4 deletions devsoc24-portal-fe/src/components/teamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -34,7 +35,8 @@ const TeamCard: React.FC<teamDataProps> = (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);
Expand Down Expand Up @@ -113,7 +115,6 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
return (
<>
<div>

<div className="h-fit w-full rounded-xl bg-white md:w-[32vw]">
<div className="flex w-full items-center justify-between pl-6 pt-4 font-semibold text-[#45464E]">
<p>Your Devsoc Team</p>
Expand Down Expand Up @@ -164,7 +165,12 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
>
<span>{member.name}</span>

<div onClick={() => handleDialogTriggerClick("leave")}>
<div
onClick={() => {
handleDialogTriggerClick("kick");
setKickMate(member.id);
}}
>
<span className="text-[#AD1136] hover:scale-[1.05] hover:cursor-pointer">
{edit ? <BadgeMinus /> : <></>}
</span>
Expand Down
10 changes: 10 additions & 0 deletions devsoc24-portal-fe/src/store/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,13 @@ export const showModalStore = create<showModalStore>((set) => ({
showModal: "",
setShowModal: (showModal: string) => set({ showModal }),
}));

interface kickStore {
kickMate: string;
setKickMate: (kickMate: string) => void;
}

export const showkickStore = create<kickStore>((set) => ({
kickMate: "",
setKickMate: (kickMate: string) => set({ kickMate }),
}));

0 comments on commit d9351d0

Please sign in to comment.