Update theme toggle functionality and UI components
Implemented a new ModeToggle feature for theme switching in personal account dropdown. The changes also made adjustments to several UI components, such as transforming Dialog to AlertDialog in transfer-ownership-dialog, and introducing invitation-submit-button in team-accounts. Some minor amendments include text changes and styling modifications.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import Image from 'next/image';
|
||||
|
||||
import { Heading } from '@kit/ui/heading';
|
||||
import { If } from '@kit/ui/if';
|
||||
import { Separator } from '@kit/ui/separator';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
import { acceptInvitationAction } from '../../server/actions/team-invitations-server-actions';
|
||||
import { InvitationSubmitButton } from './invitation-submit-button';
|
||||
import { SignOutInvitationButton } from './sign-out-invitation-button';
|
||||
|
||||
export function AcceptInvitationContainer(props: {
|
||||
inviteToken: string;
|
||||
|
||||
invitation: {
|
||||
id: string;
|
||||
|
||||
account: {
|
||||
name: string;
|
||||
id: string;
|
||||
picture_url: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
paths: {
|
||||
signOutNext: string;
|
||||
accountHome: string;
|
||||
};
|
||||
}) {
|
||||
return (
|
||||
<div className={'flex flex-col items-center space-y-8'}>
|
||||
<Heading className={'text-center'} level={5}>
|
||||
<Trans
|
||||
i18nKey={'teams:acceptInvitationHeading'}
|
||||
values={{
|
||||
accountName: props.invitation.account.name,
|
||||
}}
|
||||
/>
|
||||
</Heading>
|
||||
|
||||
<If condition={props.invitation.account.picture_url}>
|
||||
{(url) => (
|
||||
<Image
|
||||
alt={`Logo`}
|
||||
src={url}
|
||||
width={64}
|
||||
height={64}
|
||||
className={'object-cover'}
|
||||
/>
|
||||
)}
|
||||
</If>
|
||||
|
||||
<div className={'text-muted-foreground text-center text-sm'}>
|
||||
<Trans
|
||||
i18nKey={'teams:acceptInvitationDescription'}
|
||||
values={{
|
||||
accountName: props.invitation.account.name,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={'flex flex-col space-y-2.5'}>
|
||||
<form className={'w-full'} action={acceptInvitationAction}>
|
||||
<input type="hidden" name={'inviteToken'} value={props.inviteToken} />
|
||||
|
||||
<input
|
||||
type={'hidden'}
|
||||
name={'nextPath'}
|
||||
value={props.paths.accountHome}
|
||||
/>
|
||||
|
||||
<InvitationSubmitButton accountName={props.invitation.account.name} />
|
||||
</form>
|
||||
|
||||
<Separator />
|
||||
|
||||
<SignOutInvitationButton nextPath={props.paths.signOutNext} />
|
||||
|
||||
<span className={'text-muted-foreground text-center text-xs'}>
|
||||
<Trans i18nKey={'teams:signInWithDifferentAccountDescription'} />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
'use client';
|
||||
|
||||
import { useFormStatus } from 'react-dom';
|
||||
|
||||
import { Button } from '@kit/ui/button';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
export function InvitationSubmitButton(props: { accountName: string }) {
|
||||
const { pending } = useFormStatus();
|
||||
|
||||
return (
|
||||
<Button className={'w-full'} disabled={pending}>
|
||||
<Trans
|
||||
i18nKey={pending ? 'teams:joiningTeam' : 'teams:joinTeam'}
|
||||
values={{
|
||||
accountName: props.accountName,
|
||||
}}
|
||||
/>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
'use client';
|
||||
|
||||
import { useSignOut } from '@kit/supabase/hooks/use-sign-out';
|
||||
import { Button } from '@kit/ui/button';
|
||||
import { Trans } from '@kit/ui/trans';
|
||||
|
||||
export function SignOutInvitationButton(
|
||||
props: React.PropsWithChildren<{
|
||||
nextPath: string;
|
||||
}>,
|
||||
) {
|
||||
const signOut = useSignOut();
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant={'ghost'}
|
||||
onClick={async () => {
|
||||
await signOut.mutateAsync();
|
||||
window.location.assign(props.nextPath);
|
||||
}}
|
||||
>
|
||||
<Trans i18nKey={'teams:signInWithDifferentAccount'} />
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user