Skip to content

Commit

Permalink
fix: route enum
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Mar 24, 2024
1 parent a3ea932 commit f5a9ff8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions src/app/(app)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export default function LoginPage() {
const handleLogin = async (e: any) => {
e.preventDefault()
const { login } = await import('~/atoms/owner')
login(username, password).then(() => {
const redirectPath = new URLSearchParams(location.search).get('redirect')
if (redirectPath) {
router.push(decodeURIComponent(redirectPath))
} else {
router.push(Routes.Home)
}
})
await login(username, password)

const redirectPath = new URLSearchParams(location.search).get('redirect')
if (redirectPath) {
router.push(decodeURIComponent(redirectPath))
} else {
router.push(Routes.Home)
}
}
return (
<div className="flex min-h-[calc(100vh-7rem)] center">
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/button/StyledButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const variantStyles = tv({
'bg-accent text-zinc-100',
'hover:contrast-[1.10] active:contrast-125',
'font-semibold',
'disabled:cursor-not-allowed disabled:bg-gray-400 disabled:opacity-30 disabled:dark:bg-gray-800 disabled:dark:text-zinc-50',
'disabled:cursor-not-allowed disabled:bg-accent/40 disabled:opacity-80 disabled:dark:text-zinc-50',
'dark:text-neutral-800',
),
secondary: clsx(
'group rounded-full bg-gradient-to-b from-zinc-50/50 to-white/90 px-3 py-2 shadow-lg shadow-zinc-800/5 ring-1 ring-zinc-900/5 backdrop-blur transition dark:from-zinc-900/50 dark:to-zinc-800/90 dark:ring-white/10 dark:hover:ring-white/20',
'disabled:cursor-not-allowed disabled:bg-gray-400 disabled:opacity-30 disabled:dark:bg-gray-800 disabled:dark:text-zinc-50',
'disabled:cursor-not-allowed disabled:bg-gray-400 disabled:opacity-80 disabled:dark:bg-gray-800 disabled:dark:text-zinc-50',
),
},
},
Expand Down
42 changes: 21 additions & 21 deletions src/lib/route-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const enum Routes {
Home = '',
Home = '//',

Posts = '/posts',
Post = '/posts/',
Expand Down Expand Up @@ -66,26 +66,26 @@ type OnlyId = {
export type RouteParams<T extends Routes> = T extends Routes.Home
? HomeParams
: T extends Routes.Note
? NoteParams
: T extends Routes.Notes
? NotesParams
: T extends Routes.Posts
? PostsParams
: T extends Routes.Post
? PostParams
: T extends Routes.Timelime
? TimelineParams
: T extends Routes.NoteTopic
? OnlySlug
: T extends Routes.NoteTopics
? Noop
: T extends Routes.Page
? OnlySlug
: T extends Routes.Category
? OnlySlug
: T extends Routes.Project
? OnlyId
: {}
? NoteParams
: T extends Routes.Notes
? NotesParams
: T extends Routes.Posts
? PostsParams
: T extends Routes.Post
? PostParams
: T extends Routes.Timelime
? TimelineParams
: T extends Routes.NoteTopic
? OnlySlug
: T extends Routes.NoteTopics
? Noop
: T extends Routes.Page
? OnlySlug
: T extends Routes.Category
? OnlySlug
: T extends Routes.Project
? OnlyId
: {}

export function routeBuilder<T extends Routes>(
route: T,
Expand Down

0 comments on commit f5a9ff8

Please sign in to comment.