Skip to content

Commit

Permalink
feat: api for team members
Browse files Browse the repository at this point in the history
  • Loading branch information
Sid-80 committed Jun 28, 2024
1 parent 13f8992 commit 62ec222
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 21 deletions.
16 changes: 0 additions & 16 deletions src/app/api/teams/get/route.ts

This file was deleted.

28 changes: 28 additions & 0 deletions src/app/api/teams/members/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ConvexHttpClient } from "convex/browser";
import { api } from "../../../../../../convex/_generated/api";
import { Id } from "../../../../../../convex/_generated/dataModel";

export async function GET(
request: Request,
{ params }: { params: { id: string } }
) {
const {id} = params;


if (!id) return new Response('Parameters missing!!',{status: 401});

const client = new ConvexHttpClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

const teamInfo = await client.query(api.teams.getTeamById,{_id:id as Id<"teams">});

const memberDataPromises = teamInfo.teamMembers.map((mem:string) =>
client.query(api.user.getUser, { email: mem })
);

const results = await Promise.all(memberDataPromises);

const memberData = results.flatMap((result) => result || []);

return Response.json({memberData});

}
1 change: 1 addition & 0 deletions src/app/dashboard/_components/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function SideNav() {

<div>
<SideNavBottomSection
user={user}
totalFiles={totalFiles}
onFileCreate={onFileCreate}
activeTeam={activeTeam}
Expand Down
27 changes: 23 additions & 4 deletions src/app/dashboard/_components/SideNavBottomSection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Button } from "@/components/ui/button";
import { Archive, CheckCircle2, File, Github, Settings, Trash2 } from "lucide-react";
import {
Archive,
CheckCircle2,
File,
Github,
Settings,
Trash2,
UserCog2Icon,
} from "lucide-react";
import React, { useState, useContext, useEffect } from "react";
import {
Dialog,
Expand All @@ -17,7 +25,7 @@ import PricingDialog from "./PricingDialog";
import { FileListContext } from "@/app/_context/FilesListContext";
import { ErrorMessage } from "@/components/ui/error";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import { Id } from "../../../../convex/_generated/dataModel";
import { useMutation } from "convex/react";
import { api } from "../../../../convex/_generated/api";
Expand All @@ -40,7 +48,7 @@ interface TEAM {
_id: String;
}

function SideNavBottomSection({ onFileCreate, totalFiles, activeTeam }: any) {
function SideNavBottomSection({ onFileCreate, totalFiles, activeTeam, user }: any) {
const pathname = usePathname();
const menuList = [
{
Expand Down Expand Up @@ -68,7 +76,7 @@ function SideNavBottomSection({ onFileCreate, totalFiles, activeTeam }: any) {
path: `/dashboard/settings`,
},
];

const router = useRouter()
const { fileList_, setFileList_ } = useContext(FileListContext);
const [fileList, setFileList] = useState<any>([]);
const [fileInput, setFileInput] = useState<string>("");
Expand Down Expand Up @@ -115,6 +123,17 @@ function SideNavBottomSection({ onFileCreate, totalFiles, activeTeam }: any) {
</Link>
))}

{user?.email === activeTeam?.createdBy && <Link href={`/dashboard/team`}>
<h2
className={`flex gap-2 p-1 ${
pathname == `/dashboard/team` ? "bg-muted" : ""
} px-2 text-[14px] hover:bg-muted rounded-md cursor-pointer`}
>
<UserCog2Icon className="h-5 w-5" />
Team Settings
</h2>
</Link>}

{/* Add New File Button */}
<Dialog>
<DialogTrigger className="w-full" asChild>
Expand Down
1 change: 0 additions & 1 deletion src/app/dashboard/profile/_components/TeamList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import moment from "moment";
import { useConvex } from "convex/react";
import { api } from "../../../../../convex/_generated/api";
import { useState } from "react";

type Props = {
teamList: Team[];
Expand Down
6 changes: 6 additions & 0 deletions src/app/dashboard/team/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

export default function Page() {
return (
<div>Page</div>
)
}
7 changes: 7 additions & 0 deletions src/components/shared/MemberCarousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

export default function MemberCarousel() {
return (
<div>MemberCarousel</div>
)
}

0 comments on commit 62ec222

Please sign in to comment.