Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #594 from beabee-communityrm/feat/delete-contact
Browse files Browse the repository at this point in the history
feat: add delete account button
  • Loading branch information
wpf500 authored May 23, 2024
2 parents 1935c7b + 6a2c81a commit 4247df1
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 3 deletions.
8 changes: 8 additions & 0 deletions locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@
"until": "bis",
"yes": "Ja"
},
"contactAccount": {
"confirmDelete": {
"text": "Dadurch werden alle mit der Email-Adresse {email} verbundenen Daten gelöscht. Aktive Mitgliedschaften werden dadurch beendet.",
"title": "Kontakt löschen",
"warning": "Dieser Schritt kann nicht rückgängig gemacht werden. Sicher, dass du fortfahren möchtest?"
},
"contactDeleted": "Kontakt gelöscht."
},
"contactContribution": {
"confirmCancel": {
"confirm": "Ja, Mitgliedschaft kündigen",
Expand Down
3 changes: 3 additions & 0 deletions locales/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@
"timeAgo": "vor",
"timeIn": "in"
},
"contactAccount": {
"confirmDelete": {}
},
"contactContribution": {
"confirmCancel": {},
"updateNotice": {}
Expand Down
8 changes: 8 additions & 0 deletions locales/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,14 @@
"until": "bis",
"yes": "Ja"
},
"contactAccount": {
"confirmDelete": {
"text": "Dadurch werden alle mit der Email-Adresse {email} verbundenen Daten gelöscht. Aktive Mitgliedschaften werden dadurch beendet.",
"title": "Kontakt löschen",
"warning": "Dieser Schritt kann nicht rückgängig gemacht werden. Sicher, dass du fortfahren möchtest?"
},
"contactDeleted": "Kontakt gelöscht."
},
"contactContribution": {
"confirmCancel": {
"confirm": "Ja, Mitgliedschaft kündigen",
Expand Down
8 changes: 8 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,14 @@
"until": "until",
"yes": "Yes"
},
"contactAccount": {
"actions": "Actions",
"confirmDelete": {
"text": "This will delete all data associated with {email}. If they have an active contribution this will be cancelled.",
"title": "Delete contact",
"warning": "This is irreversible. Are you sure you want to proceed?"
}
},
"contactContribution": {
"confirmCancel": {
"confirm": "Yes, cancel it",
Expand Down
3 changes: 3 additions & 0 deletions locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
"until": "fino",
"yes": ""
},
"contactAccount": {
"confirmDelete": {}
},
"contactContribution": {
"confirmCancel": {
"confirm": "Sì, sono sicuro",
Expand Down
3 changes: 3 additions & 0 deletions locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
"timeAgo": "{time} geleden",
"timeIn": "in {time}"
},
"contactAccount": {
"confirmDelete": {}
},
"contactContribution": {
"confirmCancel": {},
"updateNotice": {}
Expand Down
3 changes: 3 additions & 0 deletions locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@
"until": "até",
"yes": "Sim"
},
"contactAccount": {
"confirmDelete": {}
},
"contactContribution": {
"confirmCancel": {},
"updateNotice": {}
Expand Down
3 changes: 3 additions & 0 deletions locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@
"until": "до",
"yes": "Да"
},
"contactAccount": {
"confirmDelete": {}
},
"contactContribution": {
"confirmCancel": {},
"updateNotice": {}
Expand Down
61 changes: 58 additions & 3 deletions src/pages/admin/contacts/[id]/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,70 @@ meta:
<ContactUpdateAccount :id="contact.id" />
</Suspense>
</template>
<template #col2>
<div class="text-right">
<ActionButton
:icon="faTrash"
variant="danger"
@click="showDeleteModal = true"
>
{{ t('contactAccount.confirmDelete.title') }}
</ActionButton>
</div>
<AppConfirmDialog
:open="showDeleteModal"
:title="t('contactAccount.confirmDelete.title')"
:cancel="t('actions.noBack')"
:confirm="t('actions.yesDelete')"
variant="danger"
@close="showDeleteModal = false"
@confirm="handleDelete"
>
<i18n-t
tag="p"
class="mb-4"
keypath="contactAccount.confirmDelete.text"
:email="contact.email"
>
<template #email
><b>{{ contact.email }}</b></template
>
</i18n-t>
<p>
<b>{{ t('contactAccount.confirmDelete.warning') }}</b>
</p>
</AppConfirmDialog>
</template>
</App2ColGrid>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import ContactUpdateAccount from '@components/contact/ContactUpdateAccount.vue';
import App2ColGrid from '@components/App2ColGrid.vue';
import AppConfirmDialog from '@components/AppConfirmDialog.vue';
import { deleteContact } from '@utils/api/contact';
import ActionButton from '@components/button/ActionButton.vue';
import { faTrash } from '@fortawesome/free-solid-svg-icons';
import { addNotification } from '@store/notifications';
import type { GetContactData } from '@type';
defineProps<{
contact: GetContactData;
}>();
const props = defineProps<{ contact: GetContactData }>();
const { t } = useI18n();
const router = useRouter();
const showDeleteModal = ref(false);
async function handleDelete() {
await deleteContact(props.contact.id);
addNotification({
variant: 'success',
title: t('contactAccount.contactDeleted'),
});
router.push('/admin/contacts');
}
</script>
4 changes: 4 additions & 0 deletions src/utils/api/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export async function updateContact(
return deserializeContact(data);
}

export async function deleteContact(id: string): Promise<void> {
await instance.delete(`/contact/${id}`);
}

export async function fetchContribution(): Promise<ContributionInfo> {
const { data } = await instance.get<Serial<ContributionInfo>>(
'/contact/me/contribution'
Expand Down

0 comments on commit 4247df1

Please sign in to comment.