2022-11-07 16:53:47 -05:00
|
|
|
<script lang="ts">
|
2024-01-20 13:47:41 -05:00
|
|
|
import { api, type UserResponseDto } from '@api';
|
2023-07-01 00:50:47 -04:00
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
|
import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.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;
|
|
|
|
|
}>();
|
2022-11-07 16:53:47 -05:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
const restoreUser = async () => {
|
2023-08-03 14:17:38 -04:00
|
|
|
const restoredUser = await api.userApi.restoreUser({ id: user.id });
|
2024-02-02 04:18:00 +01:00
|
|
|
if (restoredUser.data.deletedAt == undefined) {
|
2023-12-15 03:54:21 +01:00
|
|
|
dispatch('success');
|
2023-11-28 15:16:27 -05:00
|
|
|
} else {
|
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>
|
|
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
<ConfirmDialogue title="Restore User" confirmText="Continue" confirmColor="green" on:confirm={restoreUser} on:cancel>
|
|
|
|
|
<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>
|