Skip to content

Commit

Permalink
Merge pull request #26 from Abh1noob/master
Browse files Browse the repository at this point in the history
bb
  • Loading branch information
Abh1noob authored Mar 12, 2024
2 parents 71d74ca + d9302e4 commit 62fc53f
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 69 deletions.
6 changes: 6 additions & 0 deletions devsoc24-portal-fe/public/images/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 39 additions & 30 deletions devsoc24-portal-fe/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Button } from "@/components/ui/button";
import { User } from "lucide-react";
import ToastContainer from "@/components/ToastContainer";
import Link from "next/link";
import TimelineComponent from "@/components/timeline/timelineComponent";

interface ideaProps {
message: string;
Expand Down Expand Up @@ -105,8 +106,9 @@ export default function HomePage() {
withCredentials: true,
},
);
setUser(response.data);
setIsLeader(response?.data.is_leader);
console.log(response.data.data.is_leader);
setIsLeader(response.data.data.is_leader);
console.log(isLeader);
} catch (e) {
if (axios.isAxiosError(e)) {
switch (e.response?.status) {
Expand Down Expand Up @@ -293,36 +295,43 @@ export default function HomePage() {
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="mt-4 flex h-fit w-full flex-col justify-evenly gap-4 overflow-y-auto px-4 md:flex-row lg:h-[85%]">
{team ? (
<div className="flex flex-col">
<div className="m-8">
<TimelineComponent count={5} />
</div>
<div className="mt-4 flex h-fit w-full flex-col justify-evenly gap-4 overflow-y-auto px-4 md:flex-row lg:h-[85%]">
{team ? (
<CustomCard
title="Your Devsoc Team"
cardImage="user"
cardContent="No Team Members Yet?"
cardDesc="Start A New Team or Join One"
buttonDetails={noTeamCard}
/>
) : (
<TeamCard {...teamData} />
)}
<CustomCard
title="Your Devsoc Team"
cardImage="teamCardImg"
cardContent="No Team Members Yet?"
cardDesc="Start A New Team or Join One"
buttonDetails={noTeamCard}
title="Idea Submission"
cardImage="ideaSubmissionImg"
cardContent={
getIdea === "idea found" ? "Idea Submitted" : "No Idea Yet"
}
cardDesc={
getIdea === "idea found"
? "Edit or View Idea"
: "Submit an Idea"
}
buttonDetails={
getIdea === "idea found"
? isLeader
? ideaTherecard
: notLeader
: ideaCard
}
/>
) : (
<TeamCard {...teamData} />
)}
<CustomCard
title="Idea Submission"
cardImage="ideaSubmissionImg"
cardContent={
getIdea === "idea found" ? "Idea Submitted" : "No Idea Yet"
}
cardDesc={
getIdea === "idea found" ? "Edit or View Idea" : "Submit an Idea"
}
buttonDetails={
getIdea === "idea found"
? isLeader
? ideaTherecard
: notLeader
: ideaCard
}
/>
<TrackComponent />
<TrackComponent />
</div>
</div>
</main>
</>
Expand Down
14 changes: 7 additions & 7 deletions devsoc24-portal-fe/src/app/signup/verify/verify-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ export default function ForgotForm() {
void toast.promise(handleSubmit(), {
loading: "Cooking...",
success: (temp) => {
return `Email verified successfully!`;
setTimeout(() => {
toast.dismiss();
}, 1000);
setTimeout(() => {
router.push(`/signup/details?email=${email}`);
}, 1500);
return `Success`;
},
error: (err: AxiosError) => {
switch (err.response?.status) {
Expand All @@ -75,12 +81,6 @@ export default function ForgotForm() {
}
},
});
setTimeout(() => {
toast.dismiss();
}, 1000);
setTimeout(() => {
router.push(`/signup/verify?email=${email}`);
}, 1500);
}

const resendOTP = async () => {
Expand Down
6 changes: 4 additions & 2 deletions devsoc24-portal-fe/src/app/test/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use client"
import TimelineComponent from "@/components/timeline/timelineComponent";
import TrackComponent from "@/components/track/TrackComponent";
import React from "react";

const Page = () => {
return (
<div className="h-screen w-screen bg-black flex items-center justify-center">
<TrackComponent />
<div className="flex h-screen w-screen items-center justify-center bg-black">
<TimelineComponent count={5} />
</div>
);
};
Expand Down
6 changes: 6 additions & 0 deletions devsoc24-portal-fe/src/assets/images/timeline/completed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions devsoc24-portal-fe/src/assets/images/timeline/half.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions devsoc24-portal-fe/src/assets/images/timeline/none.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions devsoc24-portal-fe/src/components/team/leaveTeam.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Dialog,
DialogClose,
DialogContent,
DialogTitle,
} from "@radix-ui/react-dialog";
import { Label } from "@radix-ui/react-label";
import React from "react";
import { Button } from "../ui/button";
import { DialogHeader, DialogFooter } from "../ui/dialog";
import { Input } from "../ui/input";

const LeaveTeam = () => {
return (
<div>
<Dialog>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
<DialogTitle>Create a team</DialogTitle>
</DialogHeader>
<div className="flex flex-col gap-y-2 py-4">
<Label
htmlFor="name"
className="text-sm font-normal text-[#53545C]"
>
Are you sure you want to leave the team?
</Label>
</div>
<div className="flex justify-center">
<DialogFooter className="sm:justify-start">
<DialogClose>
<Button
type="submit"
className="bg-[#458B71]"
// onClick={async () => {}}
>
Yes
</Button>
<Button
type="submit"
className="bg-[#458B71]"
// onClick={async () => {}}
>
No
</Button>
</DialogClose>
</DialogFooter>
</div>
</DialogContent>
</Dialog>
</div>
);
};

export default LeaveTeam;
58 changes: 38 additions & 20 deletions devsoc24-portal-fe/src/components/teamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Crown, BadgeMinus, Files, Check } from "lucide-react";
import { Button } from "@/components/ui/button";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { teamDataProps, userProps } from "@/interfaces";
import axios, { AxiosResponse } from "axios";
import axios, { AxiosError, AxiosResponse } from "axios";
import {
useIdeaStore,
useLeaderStore,
Expand All @@ -15,6 +15,8 @@ import {
import { useRouter } from "next/navigation";
import editImg from "@/assets/images/edit.svg";
import Image from "next/image";
import toast from "react-hot-toast";
import LeaveTeam from "./team/leaveTeam";

interface keyProps {
message: string;
Expand All @@ -30,6 +32,7 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
const { idea, setIdea } = useIdeaStore();
const { edit, setEdit } = useTeamEditStore();
const { isLeader, setIsLeader } = useLeaderStore();
const [showModal, setShowModal] = useState(false);

const router = useRouter();

Expand Down Expand Up @@ -70,40 +73,44 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
};

const leaveTeam = async () => {
try {
const handleClick = async () => {
const response = await axios.delete(
`${process.env.NEXT_PUBLIC_API_URL}/team/leave`,
{
withCredentials: true,
},
);
setTeam(false);
void fetchTeam();
} catch (e) {
if (axios.isAxiosError(e)) {
switch (e.response?.status) {
case 202:
console.log("Accepted");
default:
console.log(e);
}
}
}
};

void toast.promise(handleClick(), {
loading: "Loading...",
success: (temp) => {
setTeam(true);
void fetchTeam();
return `Accepted`;
},
error: `Something went wrong`,
});
};

useEffect(() => {
const leader = props.team?.users.find(
(item) => item.id === props.team?.leader_id,
);
if (leader) {
console.log("NAME:", leader.name);
setLeader(leader.name);
}
}, [props.team]);

const toggleEdit = () => {
console.log("EDIT:", edit);
setEdit(!edit);
};

const toggleModal = () => {
setShowModal(!showModal);
};

return (
<>
<div>
Expand All @@ -125,7 +132,19 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
Edit
</div>
) : (
<></>
<div
className="mx-2 flex flex-row items-center justify-between gap-3 rounded-lg border-2 border-[#AD1136] px-2 py-1 text-[#AD1136] transition-all duration-150 ease-in-out hover:cursor-pointer hover:bg-black/10"
onClick={leaveTeam}
>
<Image
src={editImg as HTMLImageElement}
alt="edit"
height={0}
width={0}
className="h-fit w-fit"
/>
Leave Team
</div>
)}
</div>
<div className="flex flex-col items-center justify-center p-8">
Expand All @@ -141,15 +160,14 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
<span className="text-[#FFBE3D]">
<Crown />
</span>
) : member.id === user.data.id ? (
) : (
<span
className="text-[#AD1136] hover:scale-[1.05] hover:cursor-pointer"
onClick={leaveTeam}
>
<BadgeMinus />
{}
{edit ? <BadgeMinus /> : <></>}
</span>
) : (
<></>
)}
</div>
))}
Expand Down
Loading

0 comments on commit 62fc53f

Please sign in to comment.