From 3fef60a3daf7d17dff22d815400e03f36e4128c9 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Sun, 22 Feb 2026 13:02:35 +0200 Subject: feat(web): oauth redirect --- website/package.json | 3 +- website/pnpm-lock.yaml | 8 ++ website/src/lib/schemas/profile.ts | 13 ++ website/src/routes/+layout.svelte | 4 +- website/src/routes/+page.svelte | 4 + website/src/routes/login/+page.svelte | 94 +++++++------ website/src/routes/welcome/+page.server.ts | 38 +++++ website/src/routes/welcome/+page.svelte | 219 +++++++++++++++++++++++++++++ 8 files changed, 338 insertions(+), 45 deletions(-) create mode 100644 website/src/lib/schemas/profile.ts create mode 100644 website/src/routes/welcome/+page.server.ts create mode 100644 website/src/routes/welcome/+page.svelte (limited to 'website') diff --git a/website/package.json b/website/package.json index ed45685..7f30897 100644 --- a/website/package.json +++ b/website/package.json @@ -40,6 +40,7 @@ "vitest": "^4.0.18" }, "dependencies": { - "lucide-svelte": "^0.564.0" + "lucide-svelte": "^0.564.0", + "zod": "^4.3.6" } } diff --git a/website/pnpm-lock.yaml b/website/pnpm-lock.yaml index 1e9ef82..e7fb2e1 100644 --- a/website/pnpm-lock.yaml +++ b/website/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: lucide-svelte: specifier: ^0.564.0 version: 0.564.0(svelte@5.51.0) + zod: + specifier: ^4.3.6 + version: 4.3.6 devDependencies: '@eslint/compat': specifier: ^2.0.2 @@ -1614,6 +1617,9 @@ packages: zimmerframe@1.1.4: resolution: {integrity: sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==} + zod@4.3.6: + resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==} + snapshots: '@esbuild/aix-ppc64@0.27.3': @@ -2870,3 +2876,5 @@ snapshots: yocto-queue@0.1.0: {} zimmerframe@1.1.4: {} + + zod@4.3.6: {} diff --git a/website/src/lib/schemas/profile.ts b/website/src/lib/schemas/profile.ts new file mode 100644 index 0000000..7272800 --- /dev/null +++ b/website/src/lib/schemas/profile.ts @@ -0,0 +1,13 @@ +import { z } from 'zod'; + +export const profileSchema = z.object({ + username: z + .string() + .min(3, { message: 'Username must be at least 3 characters' }) + .max(20, { message: 'Username is too long' }) + .regex(/^[a-zA-Z0-9_]+$/, { message: 'Only letters, numbers, and underscores allowed' }), + bio: z.string().max(160, { message: 'Bio must be under 160 characters' }).optional().default(''), +}); + +// Automatically generate a TS type from the Zod schema +export type ProfileSchema = z.infer; diff --git a/website/src/routes/+layout.svelte b/website/src/routes/+layout.svelte index e68c098..48f0b78 100644 --- a/website/src/routes/+layout.svelte +++ b/website/src/routes/+layout.svelte @@ -12,5 +12,7 @@
- {@render children()} +
+ {@render children()} +
diff --git a/website/src/routes/+page.svelte b/website/src/routes/+page.svelte index cc88df0..a9c8dd0 100644 --- a/website/src/routes/+page.svelte +++ b/website/src/routes/+page.svelte @@ -1,2 +1,6 @@ +

Welcome to SvelteKit

Visit svelte.dev/docs/kit to read the documentation

diff --git a/website/src/routes/login/+page.svelte b/website/src/routes/login/+page.svelte index 29be51e..1226799 100644 --- a/website/src/routes/login/+page.svelte +++ b/website/src/routes/login/+page.svelte @@ -1,51 +1,59 @@ - -
-
-
-
- -
-

sellershut

-

Please sign in to access the platform

-
-
- +
+
+
+
+

sellershut

+

Please sign in to access the platform

+
-
- - sellershut.com - -
+ -

- By signing in, you agree to our - Terms of Service -

+
+ + sellershut.com +
+ +

+ By signing in, you agree to our + Terms of Service +

diff --git a/website/src/routes/welcome/+page.server.ts b/website/src/routes/welcome/+page.server.ts new file mode 100644 index 0000000..503f361 --- /dev/null +++ b/website/src/routes/welcome/+page.server.ts @@ -0,0 +1,38 @@ +import { fail, redirect } from '@sveltejs/kit'; +import type { Actions, PageServerLoad } from './$types'; +import { profileSchema } from '$lib/schemas/profile'; + +export const actions: Actions = { + default: async ({ request, fetch }) => { + console.log("hello"); + const formData = await request.formData(); + const data = Object.fromEntries(formData); + + // 1. Zod Validation + const result = profileSchema.safeParse(data); + + if (!result.success) { + return fail(400, { + errors: result.error.flatten().fieldErrors, + data: data as Record + }); + } + + // 2. Example: Check availability against your backend + // Replace this with your actual backend URL + const response = await fetch(`/api/check-username?u=${result.data.username}`); + const { available } = await response.json(); + + if (!available) { + return fail(400, { + errors: { username: ["This username is already taken"] }, + data: data as Record + }); + } + + // 3. Success: Send to backend to create profile + // await fetch('...', { method: 'POST', body: JSON.stringify(result.data) }); + + throw redirect(303, '/dashboard'); + } +}; diff --git a/website/src/routes/welcome/+page.svelte b/website/src/routes/welcome/+page.svelte new file mode 100644 index 0000000..863b69f --- /dev/null +++ b/website/src/routes/welcome/+page.svelte @@ -0,0 +1,219 @@ + + +
+
+
+
+
+ {#if avatarPreview} + Preview + {:else} +
+ + + +
+ {/if} +
+ +
+ + + +
+ +
+
+
+ +
+

Final Touches

+

Tell the world a bit about yourself.

+ +
+
+ + +
+ + + + + + + + + + + + + +
+
+
+ + +
+ @ + + + + + @{domain} + +
+ + {#if errors?.username} +

{errors.username[0]}

+ {/if} +
+
+ + + {#if errors?.bio} +

{errors.bio[0]}

+ {/if} +
+ + + +

sellershut.com

+
+
+
-- cgit v1.2.3