2022-11-07 16:53:47 -05:00
|
|
|
<script lang="ts">
|
2023-07-01 00:50:47 -04:00
|
|
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
|
2024-03-08 17:49:39 -05:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
2024-02-13 17:07:37 -05:00
|
|
|
import { restoreUser, type UserResponseDto } from '@immich/sdk';
|
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
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 {
|
|
|
|
|
const { deletedAt } = await restoreUser({ id: user.id });
|
|
|
|
|
if (deletedAt == undefined) {
|
|
|
|
|
dispatch('success');
|
|
|
|
|
} else {
|
|
|
|
|
dispatch('fail');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleError(error, '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-02-13 17:07:37 -05:00
|
|
|
<ConfirmDialogue
|
2024-04-08 21:02:09 +00:00
|
|
|
id="restore-user-modal"
|
|
|
|
|
title="Restore user"
|
2024-02-13 17:07:37 -05:00
|
|
|
confirmText="Continue"
|
|
|
|
|
confirmColor="green"
|
2024-03-07 04:18:53 +01:00
|
|
|
onConfirm={handleRestoreUser}
|
|
|
|
|
onClose={() => 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>
|
2023-06-30 21:53:16 +02:00
|
|
|
</ConfirmDialogue>
|