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-02-13 17:07:37 -05:00
|
|
|
import { handleError } from '$lib/utils/handle-error';
|
|
|
|
|
import { deleteUser, type UserResponseDto } from '@immich/sdk';
|
2024-03-06 00:45:40 -05:00
|
|
|
import { serverConfig } from '$lib/stores/server-config.store';
|
2024-02-13 17:07:37 -05:00
|
|
|
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 handleDeleteUser = async () => {
|
2023-07-01 00:50:47 -04:00
|
|
|
try {
|
2024-02-13 17:07:37 -05:00
|
|
|
const { deletedAt } = await deleteUser({ id: user.id });
|
|
|
|
|
if (deletedAt == undefined) {
|
2023-12-15 03:54:21 +01:00
|
|
|
dispatch('fail');
|
2024-02-02 04:18:00 +01:00
|
|
|
} else {
|
|
|
|
|
dispatch('success');
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
handleError(error, 'Unable to delete user');
|
2023-12-15 03:54:21 +01:00
|
|
|
dispatch('fail');
|
2023-07-01 00:50:47 -04:00
|
|
|
}
|
|
|
|
|
};
|
2022-11-07 16:53:47 -05:00
|
|
|
</script>
|
|
|
|
|
|
2024-03-07 04:18:53 +01:00
|
|
|
<ConfirmDialogue
|
|
|
|
|
title="Delete User"
|
|
|
|
|
confirmText="Delete"
|
|
|
|
|
onConfirm={handleDeleteUser}
|
|
|
|
|
onClose={() => dispatch('cancel')}
|
|
|
|
|
>
|
2023-07-01 00:50:47 -04:00
|
|
|
<svelte:fragment slot="prompt">
|
|
|
|
|
<div class="flex flex-col gap-4">
|
|
|
|
|
<p>
|
2024-03-06 00:45:40 -05:00
|
|
|
<b>{user.name}</b>'s account and assets will be permanently deleted after {$serverConfig.userDeleteDelay} days.
|
2023-07-01 00:50:47 -04:00
|
|
|
</p>
|
|
|
|
|
<p>Are you sure you want to continue?</p>
|
|
|
|
|
</div>
|
|
|
|
|
</svelte:fragment>
|
2023-06-30 21:53:16 +02:00
|
|
|
</ConfirmDialogue>
|