2022-11-07 16:53:47 -05:00
|
|
|
<script lang="ts">
|
2024-06-21 22:08:36 +02:00
|
|
|
import FormatMessage from '$lib/components/i18n/format-message.svelte';
|
2025-05-12 18:02:49 -04:00
|
|
|
import ConfirmModal from '$lib/modals/ConfirmModal.svelte';
|
2024-03-08 17:49:39 -05:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2024-05-26 18:15:52 -04:00
|
|
|
import { restoreUserAdmin, type UserResponseDto } from '@immich/sdk';
|
2024-06-22 18:08:56 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
user: UserResponseDto;
|
2025-05-05 23:54:42 +02:00
|
|
|
onClose: (confirmed?: true) => void;
|
2024-11-14 08:43:25 -06:00
|
|
|
}
|
|
|
|
|
|
2025-05-05 23:54:42 +02:00
|
|
|
let { user, onClose }: Props = $props();
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2024-02-13 17:07:37 -05:00
|
|
|
const handleRestoreUser = async () => {
|
2024-03-08 17:49:39 -05:00
|
|
|
try {
|
2025-05-09 17:05:01 -04:00
|
|
|
await restoreUserAdmin({ id: user.id });
|
|
|
|
|
onClose(true);
|
2024-03-08 17:49:39 -05:00
|
|
|
} catch (error) {
|
2024-06-04 21:53:00 +02:00
|
|
|
handleError(error, $t('errors.unable_to_restore_user'));
|
2023-11-28 15:16:27 -05:00
|
|
|
}
|
2023-07-01 00:50:47 -04:00
|
|
|
};
|
2022-11-07 16:53:47 -05:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-12 18:02:49 -04:00
|
|
|
<ConfirmModal
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('restore_user')}
|
|
|
|
|
confirmText={$t('continue')}
|
2025-03-14 09:37:56 -04:00
|
|
|
confirmColor="success"
|
2025-05-05 23:54:42 +02:00
|
|
|
onClose={(confirmed) => (confirmed ? handleRestoreUser() : onClose())}
|
2024-02-13 17:07:37 -05:00
|
|
|
>
|
2024-11-14 08:43:25 -06:00
|
|
|
{#snippet promptSnippet()}
|
2024-06-21 22:08:36 +02:00
|
|
|
<p>
|
2024-11-14 08:43:25 -06:00
|
|
|
<FormatMessage key="admin.user_restore_description" values={{ user: user.name }}>
|
|
|
|
|
{#snippet children({ message })}
|
|
|
|
|
<b>{message}</b>
|
|
|
|
|
{/snippet}
|
2024-06-21 22:08:36 +02:00
|
|
|
</FormatMessage>
|
|
|
|
|
</p>
|
2024-11-14 08:43:25 -06:00
|
|
|
{/snippet}
|
2025-05-12 18:02:49 -04:00
|
|
|
</ConfirmModal>
|