2022-11-07 16:53:47 -05:00
|
|
|
<script lang="ts">
|
2024-05-28 09:10:43 +07:00
|
|
|
import ConfirmDialog from '$lib/components/shared-components/dialog/confirm-dialog.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-02-13 17:07:37 -05:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
export let user: UserResponseDto;
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2023-12-15 03:54:21 +01:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
|
success: void;
|
|
|
|
|
fail: void;
|
2024-03-07 04:18:53 +01:00
|
|
|
cancel: void;
|
2023-12-15 03:54:21 +01:00
|
|
|
}>();
|
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 {
|
2024-05-26 18:15:52 -04:00
|
|
|
const { deletedAt } = await restoreUserAdmin({ id: user.id });
|
2024-03-08 17:49:39 -05:00
|
|
|
if (deletedAt == undefined) {
|
|
|
|
|
dispatch('success');
|
|
|
|
|
} else {
|
|
|
|
|
dispatch('fail');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
2024-06-04 21:53:00 +02:00
|
|
|
handleError(error, $t('errors.unable_to_restore_user'));
|
2023-12-15 03:54:21 +01:00
|
|
|
dispatch('fail');
|
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>
|
|
|
|
|
|
2024-05-28 09:10:43 +07:00
|
|
|
<ConfirmDialog
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('restore_user')}
|
|
|
|
|
confirmText={$t('continue')}
|
2024-02-13 17:07:37 -05:00
|
|
|
confirmColor="green"
|
2024-03-07 04:18:53 +01:00
|
|
|
onConfirm={handleRestoreUser}
|
2024-05-28 09:10:43 +07:00
|
|
|
onCancel={() => dispatch('cancel')}
|
2024-02-13 17:07:37 -05:00
|
|
|
>
|
2023-07-01 00:50:47 -04:00
|
|
|
<svelte:fragment slot="prompt">
|
2023-11-11 20:03:32 -05:00
|
|
|
<p><b>{user.name}</b>'s account will be restored.</p>
|
2023-07-01 00:50:47 -04:00
|
|
|
</svelte:fragment>
|
2024-05-28 09:10:43 +07:00
|
|
|
</ConfirmDialog>
|