-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a route to show all skill requests and pending skill requests (#…
…103)
- Loading branch information
Showing
12 changed files
with
189 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Link from "next/link" | ||
import { usePathname } from "next/navigation" | ||
|
||
import { cn } from "@/utils/classname" | ||
|
||
export type TTab = { | ||
order: number | ||
label: string | ||
href: string | ||
} | ||
|
||
type TabsProps = { | ||
tabs: TTab[] | ||
} | ||
|
||
export const Tabs = ({ tabs }: TabsProps) => { | ||
const pathname = usePathname() | ||
const sortedTabs = tabs.sort((a, b) => a.order - b.order) | ||
|
||
return ( | ||
<div className="flex w-max items-center rounded-lg bg-gray-100 p-1"> | ||
{sortedTabs.map((tab) => ( | ||
<Link | ||
href={tab.href} | ||
key={tab.href} | ||
className={cn( | ||
"flex h-8 items-center justify-center rounded px-4 text-xs font-medium", | ||
pathname === tab.href ? "bg-white" : "bg-transparent" | ||
)} | ||
> | ||
{tab.label} | ||
</Link> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PendingRequests } from "./pending-requests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { useQuery } from "@tanstack/react-query" | ||
import Link from "next/link" | ||
|
||
import { SkillsApi } from "@/api/skills" | ||
import { UserSkillStatusEnum } from "@/api/skills/skills.enum" | ||
import { Button } from "@/components/button" | ||
import { PageError } from "@/components/page-error" | ||
import { Shimmer } from "@/components/shimmer" | ||
import { RootLayout } from "@/layouts/root-layout" | ||
import { ROUTES } from "@/routes" | ||
import { useGlobalStore } from "@/store/global-store" | ||
|
||
import { RequestsTable } from "../requests/components/requests-table" | ||
import { RequestsTabs } from "../requests/components/requests-tabs" | ||
|
||
export const PendingRequests = () => { | ||
const isSuperUser = useGlobalStore((store) => store.user?.roles.super_user) | ||
|
||
const { data, isLoading, isError } = useQuery({ | ||
queryKey: ["SkillsApi.getAllPendingSkillRequests"], | ||
queryFn: () => SkillsApi.getAllPendingSkillRequests({ status: UserSkillStatusEnum.PENDING }), | ||
}) | ||
|
||
if (isLoading) { | ||
return ( | ||
<RootLayout> | ||
<div className="mx-auto w-full max-w-screen-xl flex-1 space-y-4 p-6 xl:py-10"> | ||
<Shimmer /> | ||
<Shimmer /> | ||
<Shimmer /> | ||
<Shimmer /> | ||
</div> | ||
</RootLayout> | ||
) | ||
} | ||
|
||
if (isError) { | ||
return ( | ||
<RootLayout> | ||
<PageError /> | ||
</RootLayout> | ||
) | ||
} | ||
|
||
return ( | ||
<RootLayout> | ||
<div className="w-full p-6"> | ||
<div className="mx-auto max-w-screen-lg rounded-lg border border-gray-100 bg-white p-6"> | ||
<div className="pb-6"> | ||
<RequestsTabs /> | ||
</div> | ||
|
||
<div className="flex items-center gap-4 pb-6"> | ||
<h1 className="flex-1 text-2xl font-semibold text-gray-800">Pending requests</h1> | ||
|
||
{isSuperUser && ( | ||
<Button asChild size="xs" variant="ghost" className="text-gray-500"> | ||
<Link href={ROUTES.skills.create}>Create Skill</Link> | ||
</Button> | ||
)} | ||
|
||
<Button asChild size="xs" variant="secondary"> | ||
<Link href={ROUTES.endorsements.create}>Create Endorsement</Link> | ||
</Button> | ||
</div> | ||
|
||
<RequestsTable data={data ?? { requests: [], users: [] }} /> | ||
</div> | ||
</div> | ||
</RootLayout> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Tabs, TTab } from "@/components/tabs" | ||
|
||
const tabs: TTab[] = [ | ||
{ order: 0, label: "All requests", href: "/requests" }, | ||
{ order: 1, label: "Pending requests", href: "/requests/pending" }, | ||
] | ||
|
||
export const RequestsTabs = () => { | ||
return <Tabs tabs={tabs} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { PendingRequests } from "@/modules/pending-requests" | ||
|
||
export default PendingRequests |