update ui and other frontend updates
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { fail, redirect } from '@sveltejs/kit';
|
||||
import { setDeviceTokenCookie } from '$lib/server/auth';
|
||||
import { SERVER_IP, PROXY_PORT } from '../../../../../../config.ts';
|
||||
|
||||
const HONO_URL = `http://${SERVER_IP}:${PROXY_PORT}`;
|
||||
|
||||
export const actions = {
|
||||
default: async (event) => {
|
||||
const code = event.params.code;
|
||||
const name = event.params.member;
|
||||
|
||||
const res = await fetch(`${HONO_URL}/api/members/direct-join`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ inviteCode: code, name }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (!res.ok) return fail(400, { error: data.error || 'Join failed' });
|
||||
|
||||
setDeviceTokenCookie(event, data.deviceToken);
|
||||
|
||||
throw redirect(303, `/${data.famSlug}/${data.name}`);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user