-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔄 Merge pull request #7 from steeeee0223/feature/worxpace
Setup pages
- Loading branch information
Showing
21 changed files
with
617 additions
and
29 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,9 @@ | ||
import { PropsWithChildren } from "react"; | ||
|
||
const ClerkLayout = ({ children }: PropsWithChildren) => { | ||
return ( | ||
<div className="flex h-full items-center justify-center">{children}</div> | ||
); | ||
}; | ||
|
||
export default ClerkLayout; |
11 changes: 11 additions & 0 deletions
11
apps/worxpace/src/app/(platform)/(clerk)/select-role/[[...select-role]]/page.tsx
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,11 @@ | ||
import { OrganizationList } from "@clerk/nextjs"; | ||
|
||
export default function Page() { | ||
return ( | ||
<OrganizationList | ||
afterSelectPersonalUrl="/personal/:id" | ||
afterSelectOrganizationUrl="/organization/:id" | ||
afterCreateOrganizationUrl="/organization/:id" | ||
/> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/worxpace/src/app/(platform)/(clerk)/sign-in/[[...sign-in]]/page.tsx
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,5 @@ | ||
import { SignIn } from "@clerk/nextjs"; | ||
|
||
export default function Page() { | ||
return <SignIn />; | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/worxpace/src/app/(platform)/(clerk)/sign-up/[[...sign-up]]/page.tsx
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,5 @@ | ||
import { SignUp } from "@clerk/nextjs"; | ||
|
||
export default function Page() { | ||
return <SignUp />; | ||
} |
13 changes: 13 additions & 0 deletions
13
apps/worxpace/src/app/(platform)/(tools)/[role]/[clientId]/page.tsx
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,13 @@ | ||
interface Params { | ||
params: { role: string; clientId: string }; | ||
} | ||
|
||
const Client = ({ params: { role, clientId } }: Params) => { | ||
return ( | ||
<div> | ||
Client {role} - {clientId} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Client; |
14 changes: 14 additions & 0 deletions
14
apps/worxpace/src/app/(platform)/(tools)/[role]/layout.tsx
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,14 @@ | ||
import { type PropsWithChildren } from "react"; | ||
import { redirect } from "next/navigation"; | ||
|
||
interface Params extends PropsWithChildren { | ||
params: { role: string }; | ||
} | ||
|
||
const RoleLayout = ({ children, params: { role } }: Params) => { | ||
if (role !== "admin" && role !== "personal" && role !== "organization") | ||
redirect("/select-role"); | ||
return <>{children}</>; | ||
}; | ||
|
||
export default RoleLayout; |
83 changes: 83 additions & 0 deletions
83
apps/worxpace/src/app/(platform)/(tools)/_components/sidebar.tsx
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,83 @@ | ||
/* eslint-disable jsx-a11y/no-static-element-interactions */ | ||
/* eslint-disable jsx-a11y/click-events-have-key-events */ | ||
/* eslint-disable jsx-a11y/interactive-supports-focus */ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
import { usePathname } from "next/navigation"; | ||
import { ChevronsLeft, MenuIcon } from "lucide-react"; | ||
|
||
import { useNavControl } from "@acme/ui/hooks"; | ||
import { cn } from "@acme/ui/lib"; | ||
|
||
import { theme } from "~/constants/theme"; | ||
|
||
export const Sidebar = () => { | ||
const pathname = usePathname(); | ||
const { | ||
isMobile, | ||
sidebarRef, | ||
navbarRef, | ||
isResetting, | ||
isCollapsed, | ||
handleMouseDown, | ||
collapse, | ||
resetWidth, | ||
} = useNavControl(); | ||
|
||
useEffect(() => { | ||
isMobile ? collapse() : resetWidth(); | ||
}, [isMobile]); | ||
|
||
useEffect(() => { | ||
if (isMobile) collapse(); | ||
}, [pathname, isMobile]); | ||
|
||
return ( | ||
<> | ||
<aside | ||
ref={sidebarRef} | ||
className={cn( | ||
"group/sidebar relative z-[99999] flex h-full w-60 flex-col overflow-y-auto bg-secondary", | ||
isResetting && "transition-all duration-300 ease-in-out", | ||
isMobile && "w-0", | ||
)} | ||
> | ||
<div | ||
onClick={collapse} | ||
role="button" | ||
className={cn( | ||
theme.bg.hover, | ||
"absolute right-2 top-3 h-6 w-6 rounded-sm text-muted-foreground opacity-0 transition group-hover/sidebar:opacity-100", | ||
isMobile && "opacity-100", | ||
)} | ||
> | ||
<ChevronsLeft className="h-6 w-6" /> | ||
</div> | ||
<div | ||
onMouseDown={handleMouseDown} | ||
onClick={resetWidth} | ||
className="absolute right-0 top-0 h-full w-1 cursor-ew-resize bg-primary/10 opacity-0 transition group-hover/sidebar:opacity-100" | ||
/> | ||
</aside> | ||
<div | ||
ref={navbarRef} | ||
className={cn( | ||
"absolute left-60 top-0 z-[99999] w-[calc(100%-240px)]", | ||
isResetting && "transition-all duration-300 ease-in-out", | ||
isMobile && "left-0 w-full", | ||
)} | ||
> | ||
<nav className="w-full bg-transparent px-3 py-2"> | ||
{isCollapsed && ( | ||
<MenuIcon | ||
onClick={resetWidth} | ||
role="button" | ||
className="h-6 w-6 text-muted-foreground" | ||
/> | ||
)} | ||
</nav> | ||
</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,5 @@ | ||
const Documents = () => { | ||
return <div>This is a protected page</div>; | ||
}; | ||
|
||
export default Documents; |
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,19 @@ | ||
import { type PropsWithChildren } from "react"; | ||
import { redirect } from "next/navigation"; | ||
import { auth } from "@clerk/nextjs"; | ||
|
||
import { Sidebar } from "./_components/sidebar"; | ||
|
||
const ToolsLayout = ({ children }: PropsWithChildren) => { | ||
const { userId } = auth(); | ||
if (!userId) redirect("/select-role"); | ||
|
||
return ( | ||
<div className="flex h-full dark:bg-[#1F1F1F]"> | ||
<Sidebar /> | ||
<main className="h-full flex-1 overflow-y-auto">{children}</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ToolsLayout; |
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,6 @@ | ||
import type { PropsWithChildren } from "react"; | ||
import { ClerkProvider } from "@clerk/nextjs"; | ||
|
||
export default function PlatformLayout({ children }: PropsWithChildren) { | ||
return <ClerkProvider>{children}</ClerkProvider>; | ||
} |
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 @@ | ||
export * from "./utils"; |
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,6 @@ | ||
import { auth } from "@clerk/nextjs"; | ||
|
||
export function isAuthenticated(): boolean { | ||
const { userId } = auth(); | ||
return !!userId; | ||
} |
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,27 @@ | ||
import { NextResponse } from "next/server"; | ||
import { authMiddleware, redirectToSignIn } from "@clerk/nextjs"; | ||
|
||
// This example protects all routes including api/trpc routes | ||
// Please edit this to allow other routes to be public as needed. | ||
// See https://clerk.com/docs/references/nextjs/auth-middleware for more information about configuring your Middleware | ||
export default authMiddleware({ | ||
publicRoutes: ["/", "/api/webhook"], | ||
afterAuth(auth, req) { | ||
if (auth.userId && auth.isPublicRoute) { | ||
const path = auth.orgId | ||
? `/organization/${auth.orgId}` | ||
: `/personal/${auth.userId}`; | ||
const orgSelection = new URL(path, req.url); | ||
return NextResponse.redirect(orgSelection); | ||
} | ||
|
||
if (!auth.userId && !auth.isPublicRoute) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return redirectToSignIn({ returnBackUrl: req.url }); | ||
} | ||
}, | ||
}); | ||
|
||
export const config = { | ||
matcher: ["/((?!.+\\.[\\w]+$|_next).*)", "/", "/(api|trpc)(.*)"], | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./use-action"; | ||
export * from "./use-fetch"; | ||
export * from "./use-nav-control"; | ||
export * from "./use-scroll-top"; |
Oops, something went wrong.