Skip to content

Commit

Permalink
Merge pull request #22 from Abh1noob/master
Browse files Browse the repository at this point in the history
hh
  • Loading branch information
Abh1noob authored Mar 11, 2024
2 parents 7b990ac + 755c994 commit d06c6c0
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
3 changes: 2 additions & 1 deletion devsoc24-portal-fe/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TeamCard from "@/components/teamCard";
import axios, { type AxiosResponse } from "axios";
import {
useIdeaStore,
useLeaderStore,
useTeamDataStore,
useTeamStore,
useUserStore,
Expand Down Expand Up @@ -58,7 +59,7 @@ export default function HomePage() {
const { user, setUser } = useUserStore();
const [getIdea, SetIdea] = useState("");
const { teamData, setTeamData } = useTeamDataStore();
const [isLeader, setIsLeader] = useState(false);
const { isLeader, setIsLeader } = useLeaderStore();

const logout = async () => {
try {
Expand Down
4 changes: 4 additions & 0 deletions devsoc24-portal-fe/src/assets/images/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 35 additions & 4 deletions devsoc24-portal-fe/src/components/teamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@ import { Button } from "@/components/ui/button";
import { CopyToClipboard } from "react-copy-to-clipboard";
import { teamDataProps, userProps } from "@/interfaces";
import axios, { AxiosResponse } from "axios";
import { useIdeaStore, useTeamStore, useUserStore } from "@/store/store";
import {
useIdeaStore,
useLeaderStore,
useTeamEditStore,
useTeamStore,
useUserStore,
} from "@/store/store";
import { useRouter } from "next/navigation";
import editImg from "@/assets/images/edit.svg";
import Image from "next/image";

interface keyProps {
message: string;
Expand All @@ -20,6 +28,8 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
const { team, setTeam } = useTeamStore();
const { user, setUser } = useUserStore();
const { idea, setIdea } = useIdeaStore();
const { edit, setEdit } = useTeamEditStore();
const { isLeader, setIsLeader } = useLeaderStore();

const router = useRouter();

Expand Down Expand Up @@ -68,7 +78,7 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
},
);
setTeam(false);
fetchTeam();
void fetchTeam();
} catch (e) {
if (axios.isAxiosError(e)) {
switch (e.response?.status) {
Expand All @@ -90,12 +100,33 @@ const TeamCard: React.FC<teamDataProps> = (props) => {
}
}, [props.team]);

const toggleEdit = () => {
setEdit(!edit);
};

return (
<>
<div>
<div className="h-fit w-full rounded-xl bg-white md:w-[32vw]">
<div className="pl-6 pt-4 font-semibold text-[#45464E]">
Your Devsoc Team
<div className="flex w-full items-center justify-between pl-6 pt-4 font-semibold text-[#45464E]">
<p>Your Devsoc Team</p>
{isLeader ? (
<div
className="mx-2 flex flex-row items-center justify-between gap-3 rounded-lg border-2 border-[#53545C] px-2 py-1 transition-all duration-150 ease-in-out hover:cursor-pointer hover:bg-black/10"
onClick={toggleEdit}
>
<Image
src={editImg}
alt="edit"
height={0}
width={0}
className="h-fit w-fit"
/>
Edit
</div>
) : (
<></>
)}
</div>
<div className="flex flex-col items-center justify-center p-8">
<p className="text-2xl font-semibold">{props.team?.team_name}</p>
Expand Down
20 changes: 20 additions & 0 deletions devsoc24-portal-fe/src/store/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ export const useTeamStore = create<teamStore>((set) => ({
setTeam: (team: boolean) => set({ team }),
}));

interface leaderStore {
isLeader: boolean;
setIsLeader: (isLeader: boolean) => void;
}

export const useLeaderStore = create<leaderStore>((set) => ({
isLeader: false,
setIsLeader: (isLeader: boolean) => set({ isLeader }),
}));

interface teamEditStore {
edit: boolean;
setEdit: (setTeam: boolean) => void;
}

export const useTeamEditStore = create<teamEditStore>((set) => ({
edit: false,
setEdit: (edit: boolean) => set({ edit }),
}));

interface userStore {
user: userProps;
setUser: (setUser: userProps) => void;
Expand Down

0 comments on commit d06c6c0

Please sign in to comment.