mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The resource API is /v1/rest and the operation API is /v1/rpc: named for what they are, so neither shadows the other, and the v2-beta alias is gone. Hanzo IAM returns to /auth/callback, the callback path IAM already derives for this host, so sign-in needs no IAM change. Claude-Session: https://claude.ai/code/session_01TUxvfuta1Z44KVNYuAz71F
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import { msg } from '@lingui/core/macro';
|
|
import { useLingui } from '@lingui/react';
|
|
import { CheckIcon } from 'lucide-react';
|
|
|
|
import { SUPPORTED_LANGUAGES } from '@hanzo/esign-lib/constants/i18n';
|
|
import { dynamicActivate } from '@hanzo/esign-lib/utils/i18n';
|
|
import { cn } from '@hanzo/esign-ui/lib/utils';
|
|
import {
|
|
CommandDialog,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
} from '@hanzo/esign-ui/primitives/command';
|
|
|
|
type LanguageSwitcherDialogProps = {
|
|
open: boolean;
|
|
setOpen: (_open: boolean) => void;
|
|
};
|
|
|
|
export const LanguageSwitcherDialog = ({ open, setOpen }: LanguageSwitcherDialogProps) => {
|
|
const { i18n, _ } = useLingui();
|
|
|
|
const setLanguage = async (lang: string) => {
|
|
setOpen(false);
|
|
|
|
await dynamicActivate(lang);
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('lang', lang);
|
|
|
|
await fetch('/v1/locale', {
|
|
method: 'post',
|
|
body: formData,
|
|
});
|
|
};
|
|
|
|
return (
|
|
<CommandDialog open={open} onOpenChange={setOpen}>
|
|
<CommandInput placeholder={_(msg`Search languages...`)} />
|
|
|
|
<CommandList>
|
|
<CommandGroup>
|
|
{Object.values(SUPPORTED_LANGUAGES).map((language) => (
|
|
<CommandItem
|
|
key={language.short}
|
|
value={_(language.full)}
|
|
onSelect={async () => setLanguage(language.short)}
|
|
>
|
|
<CheckIcon
|
|
className={cn(
|
|
'mr-2 h-4 w-4',
|
|
i18n.locale === language.short ? 'opacity-100' : 'opacity-0',
|
|
)}
|
|
/>
|
|
{_(language.full)}
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</CommandDialog>
|
|
);
|
|
};
|