Revert "Unify workspace dropdowns; Update layouts (#458)"

This reverts commit 4bc8448a1d.
This commit is contained in:
gbuomprisco
2026-03-11 14:47:47 +08:00
parent 4bc8448a1d
commit 4912e402a3
530 changed files with 11182 additions and 14382 deletions

View File

@@ -20,22 +20,19 @@ export function enhanceAction<
auth?: boolean;
captcha?: boolean;
schema?: z.ZodType<
Config['captcha'] extends true ? Args & { captchaToken: string } : Args
Config['captcha'] extends true ? Args & { captchaToken: string } : Args,
z.ZodTypeDef
>;
},
>(
fn: (
params: Config['schema'] extends ZodType
? z.output<Config['schema']>
: Args,
params: Config['schema'] extends ZodType ? z.infer<Config['schema']> : Args,
user: Config['auth'] extends false ? undefined : JWTUserData,
) => Response | Promise<Response>,
config: Config,
) {
return async (
params: Config['schema'] extends ZodType
? z.output<Config['schema']>
: Args,
params: Config['schema'] extends ZodType ? z.infer<Config['schema']> : Args,
) => {
type UserParam = Config['auth'] extends false ? undefined : JWTUserData;
@@ -83,11 +80,6 @@ export function enhanceAction<
user = auth.data as UserParam;
}
return fn(
data as Config['schema'] extends ZodType
? z.output<Config['schema']>
: Args,
user,
);
return fn(data, user);
};
}

View File

@@ -1,55 +0,0 @@
import 'server-only';
import { redirect } from 'next/navigation';
import { createSafeActionClient } from 'next-safe-action';
import { verifyCaptchaToken } from '@kit/auth/captcha/server';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
const baseClient = createSafeActionClient({
handleServerError: (error) => error.message,
});
/**
* @name publicActionClient
* @description Safe action client for public actions that don't require authentication.
*/
export const publicActionClient = baseClient;
/**
* @name authActionClient
* @description Safe action client for authenticated actions. Adds user context.
*/
export const authActionClient = baseClient.use(async ({ next }) => {
const auth = await requireUser(getSupabaseServerClient());
if (!auth.data) {
redirect(auth.redirectTo);
}
return next({ ctx: { user: auth.data } });
});
/**
* @name captchaActionClient
* @description Safe action client for actions that require CAPTCHA and authentication.
*/
export const captchaActionClient = baseClient.use(
async ({ next, clientInput }) => {
const input = clientInput as Record<string, unknown>;
const token =
typeof input?.captchaToken === 'string' ? input.captchaToken : '';
await verifyCaptchaToken(token);
const auth = await requireUser(getSupabaseServerClient());
if (!auth.data) {
redirect(auth.redirectTo);
}
return next({ ctx: { user: auth.data } });
},
);

View File

@@ -3,7 +3,7 @@ import 'server-only';
import { redirect } from 'next/navigation';
import { NextRequest, NextResponse } from 'next/server';
import * as z from 'zod';
import { z } from 'zod';
import { verifyCaptchaToken } from '@kit/auth/captcha/server';
import { requireUser } from '@kit/supabase/require-user';
@@ -22,7 +22,7 @@ interface HandlerParams<
> {
request: NextRequest;
user: RequireAuth extends false ? undefined : JWTUserData;
body: Schema extends z.ZodType ? z.output<Schema> : undefined;
body: Schema extends z.ZodType ? z.infer<Schema> : undefined;
params: Record<string, string>;
}
@@ -48,7 +48,7 @@ interface HandlerParams<
*/
export const enhanceRouteHandler = <
Body,
Params extends Config<z.ZodType<Body>>,
Params extends Config<z.ZodType<Body, z.ZodTypeDef>>,
>(
// Route handler function
handler: