Skip to content

Commit

Permalink
feat: update middleware & create popover alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Oct 5, 2024
1 parent 1fecc37 commit 6080162
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"drizzle-zod": "^0.5.1",
"framer-motion": "^11.11.1",
"geist": "^1.3.1",
"jiti": "^2.2.1",
"jiti": "^2.3.1",
"lucide-react": "^0.447.0",
"next": "14.2.14",
"next-mdx-remote": "^5.0.0",
Expand Down
13 changes: 7 additions & 6 deletions src/app/(dashboard)/app/_components/create-module-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function IconPicker({ iconOnClickHandler }: IconPickerProps) {
}

const formSchema = z.object({
name: z.string().min(2),
moduleName: z.string().min(2),
description: z.string().optional(),
code: z.string().min(2),
credits: z.string(),
Expand All @@ -115,7 +115,7 @@ export function CreateModulePopover() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
name: '',
moduleName: '',
code: '',
credits: '0',
icon: 'default',
Expand All @@ -127,9 +127,10 @@ export function CreateModulePopover() {
await mutation.mutateAsync({
...values,
credits: parseInt(values.credits),
name: values.moduleName,
});
form.reset({
name: '',
moduleName: '',
code: '',
credits: '0',
icon: 'default',
Expand All @@ -151,7 +152,7 @@ export function CreateModulePopover() {
</Button>
</PopoverTrigger>

<PopoverContent side="right" className="w-[328px]">
<PopoverContent align="start" side="right" className="w-[328px]">
<ResizablePanel>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="p-4">
Expand All @@ -164,11 +165,11 @@ export function CreateModulePopover() {
<div className="space-y-2">
<FormField
control={form.control}
name="name"
name="moduleName"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs text-foreground">
Name
Module Name
</FormLabel>
<FormControl>
<Input
Expand Down
8 changes: 4 additions & 4 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
import { NextResponse } from 'next/server';

const isProtectedRoute = createRouteMatcher(['/app(.*)']);

export default clerkMiddleware((auth, req) => {
if (isProtectedRoute(req)) {
auth().protect();
}

return NextResponse.next();
});

export const config = {
matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
matcher: [
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
'/(api|trpc)(.*)',
],
};

0 comments on commit 6080162

Please sign in to comment.