mirror of
https://github.com/documenso/documenso.git
synced 2025-11-12 07:43:16 +10:00
20 lines
597 B
TypeScript
20 lines
597 B
TypeScript
import type { ActionFunctionArgs } from 'react-router';
|
|
|
|
import { APP_I18N_OPTIONS } from '@documenso/lib/constants/i18n';
|
|
|
|
import { langCookie } from '~/storage/lang-cookie.server';
|
|
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const formData = await request.formData();
|
|
const lang = formData.get('lang') || '';
|
|
|
|
if (!APP_I18N_OPTIONS.supportedLangs.find((l) => l === lang)) {
|
|
throw new Response('Unsupported language', { status: 400 });
|
|
}
|
|
|
|
return new Response('OK', {
|
|
status: 200,
|
|
headers: { 'Set-Cookie': await langCookie.serialize(lang) },
|
|
});
|
|
};
|