-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #901 from bcgov/869-gurj-soft-delete-tenant
innkeeper: soft delete tenant
- Loading branch information
Showing
10 changed files
with
232 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...enant-ui/frontend/src/components/innkeeper/tenants/deleteTenant/ConfirmTenantDeletion.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template> | ||
<form @submit.prevent="handleDelete"> | ||
<div class="modal-content"> | ||
<h4> | ||
{{ | ||
$t('tenants.settings.confirmDeletion', { | ||
tenantName: tenant.tenant_name, | ||
}) | ||
}} | ||
</h4> | ||
<InputText | ||
v-model.trim="confirmationTenantName" | ||
type="text" | ||
placeholder="Type the tenant name here" | ||
class="w-full mb-4" | ||
/> | ||
<Button | ||
:disabled="!isTenantNameCorrect" | ||
label="Delete" | ||
severity="danger" | ||
class="w-full" | ||
type="submit" | ||
/> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, computed, defineProps, defineEmits } from 'vue'; | ||
import InputText from 'primevue/inputtext'; | ||
import Button from 'primevue/button'; | ||
import { useInnkeeperTenantsStore, useTenantStore } from '@/store'; | ||
import { TenantRecord } from '@/types/acapyApi/acapyInterface'; | ||
import { useToast } from 'vue-toastification'; | ||
const props = defineProps<{ | ||
tenant: TenantRecord; | ||
}>(); | ||
const emit = defineEmits(['closed', 'success']); | ||
// Using stores | ||
const innkeeperTenantsStore = useInnkeeperTenantsStore(); | ||
const tenantStore = useTenantStore(); | ||
const confirmationTenantName = ref(''); | ||
const isTenantNameCorrect = computed( | ||
() => confirmationTenantName.value === props.tenant.tenant_name | ||
); | ||
const toast = useToast(); | ||
async function handleDelete() { | ||
if (!isTenantNameCorrect.value) { | ||
toast.error( | ||
'Incorrect tenant name. Please confirm the correct name before deletion.' | ||
); | ||
return; | ||
} | ||
innkeeperTenantsStore | ||
.deleteTenant(props.tenant.tenant_id) | ||
.catch((err: string) => { | ||
console.log(err); | ||
toast.error('Failure: ${err}'); | ||
}); | ||
emit('success'); | ||
emit('closed'); | ||
} | ||
</script> |
49 changes: 49 additions & 0 deletions
49
services/tenant-ui/frontend/src/components/innkeeper/tenants/deleteTenant/DeleteTenant.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<div> | ||
<Button | ||
:title="$t('tenants.settings.deleteTenant')" | ||
icon="pi pi-trash" | ||
class="p-button-rounded p-button-icon-only p-button-text" | ||
:disabled="props.tenant.tenant_name === 'traction_innkeeper'" | ||
@click="openModal" | ||
/> | ||
<Dialog | ||
v-model:visible="displayModal" | ||
:style="{ minWidth: '500px' }" | ||
:header="'Delete Tenant'" | ||
:modal="true" | ||
@update:visible="handleClose" | ||
> | ||
<ConfirmTenantDeletion | ||
:tenant="props.tenant" | ||
@success="$emit('success')" | ||
@closed="handleClose" | ||
/> | ||
</Dialog> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import Button from 'primevue/button'; | ||
import Dialog from 'primevue/dialog'; | ||
import ConfirmTenantDeletion from './ConfirmTenantDeletion.vue'; | ||
import { TenantRecord } from '@/types/acapyApi/acapyInterface'; | ||
defineEmits(['success']); | ||
const props = defineProps<{ | ||
tenant: TenantRecord; | ||
}>(); | ||
const displayModal = ref(false); | ||
const openModal = async () => { | ||
displayModal.value = true; | ||
}; | ||
const handleClose = async () => { | ||
displayModal.value = false; | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters