Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 51 additions & 18 deletions src/components/authentication/strategies/StrategySettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useRouter } from 'next/navigation';
import { toast } from '@/lib/hooks/use-toast';
import { CheckIcon, LucideX } from 'lucide-react';
import { ErrorPre } from '@/components/ui/error-pre';
import { ScrollArea } from '@/components/ui/scroll-area';

export interface StrategySettingsProps {
strategy: StrategyInterface;
Expand All @@ -29,9 +30,20 @@ export const StrategySettings: React.FC<StrategySettingsProps> = ({

const onSubmit = async (data: unknown) => {
try {
await patchAuthenticationSettingsMerged({
[strategy.key as string]: data as Record<string, unknown>,
});
if (strategy.key === 'apple') {
const { getAuthenticationSettings, patchAuthenticationSettings } =
await import('@/lib/api/authentication');
const { config } = await getAuthenticationSettings();
const updatedConfig = {
...config,
apple: data as typeof config.apple,
};
await patchAuthenticationSettings(updatedConfig);
} else {
await patchAuthenticationSettingsMerged({
[strategy.key as string]: data as Record<string, unknown>,
});
}
toast({
title: strategy.name,
description: (
Expand Down Expand Up @@ -67,7 +79,11 @@ export const StrategySettings: React.FC<StrategySettingsProps> = ({
<DialogTrigger asChild>
<Button variant="outline">Settings</Button>
</DialogTrigger>
<DialogContent>
<DialogContent
className={
strategy.key === 'apple' ? 'max-w-3xl max-h-[90vh]' : undefined
}
>
<DialogHeader>
<DialogTitle className={'flex flex-row justify-between mt-5'}>
{strategy.name} settings configuration
Expand All @@ -79,20 +95,37 @@ export const StrategySettings: React.FC<StrategySettingsProps> = ({
Documentation
</a>
</DialogTitle>
<DialogDescription>
<hr className={'my-2'} />
{strategy.form ? (
<strategy.form
name={strategy.name}
data={strategy.data}
onSubmit={onSubmit}
onCancel={() => {
setOpen(false);
}}
/>
) : (
'No settings available'
)}
<DialogDescription asChild>
<div>
<hr className={'my-2'} />
{strategy.key === 'apple' ? (
<ScrollArea className="max-h-[calc(90vh-8rem)] pr-4">
{strategy.form ? (
<strategy.form
name={strategy.name}
data={strategy.data}
onSubmit={onSubmit}
onCancel={() => {
setOpen(false);
}}
/>
) : (
'No settings available'
)}
</ScrollArea>
) : strategy.form ? (
<strategy.form
name={strategy.name}
data={strategy.data}
onSubmit={onSubmit}
onCancel={() => {
setOpen(false);
}}
/>
) : (
'No settings available'
)}
</div>
</DialogDescription>
</DialogHeader>
</DialogContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ export const LocalConfigForm: React.FC<
/>
</>
)}
<div className={'flex flex-row gap-x-1 items-center'}>
<InputField
fieldName={'forgot_password_redirect_uri'}
label={'Forgot password redirect URI'}
description={
'Specify where the user will be redirected to after clicking the forgot password link in their email'
}
/>
</div>
<InputField
fieldName={'forgot_password_redirect_uri'}
label={'Forgot password redirect URI'}
description={
'Specify where the user will be redirected to after clicking the forgot password link in their email'
}
classNames={{
label: 'pl-0 text-sm font-normal text-text-dark-gray',
description: 'pl-0',
}}
/>
<div className={'flex flex-row gap-x-1 items-center'}>
<SwitchField
fieldName={'username_auth_enabled'}
Expand Down
Loading
Loading