From 5d496abc26e811a7b24ec4d8386927f3ee16f826 Mon Sep 17 00:00:00 2001
From: RonniSkansing
Date: Mon, 5 Oct 2026 17:08:45 +0200
Subject: [PATCH] add create recipient to group view
Signed-off-by: RonniSkansing
---
.../routes/recipient/group/[id]/+page.svelte | 175 ++++++++++++++++++
1 file changed, 175 insertions(+)
diff --git a/frontend/src/routes/recipient/group/[id]/+page.svelte b/frontend/src/routes/recipient/group/[id]/+page.svelte
index b0e5937c..cba86ad5 100644
--- a/frontend/src/routes/recipient/group/[id]/+page.svelte
+++ b/frontend/src/routes/recipient/group/[id]/+page.svelte
@@ -28,6 +28,7 @@
import Button from '$lib/components/Button.svelte';
import FormColumns from '$lib/components/FormColumns.svelte';
import FormColumn from '$lib/components/FormColumn.svelte';
+ import TextField from '$lib/components/TextField.svelte';
import Table from '$lib/components/table/Table.svelte';
import FormFooter from '$lib/components/FormFooter.svelte';
import HeadTitle from '$lib/components/HeadTitle.svelte';
@@ -73,6 +74,23 @@
let selectedRecipientsImportPaginatedChunk = [];
let isImportModalVisible = false;
+ // create recipient
+ let isCreateRecipientModalVisible = false;
+ let createRecipientForm = null;
+ let createRecipientError = '';
+ let createRecipientValues = {
+ email: '',
+ phone: '',
+ extraIdentifier: '',
+ firstName: '',
+ lastName: '',
+ position: '',
+ department: '',
+ city: '',
+ country: '',
+ misc: ''
+ };
+
// local state
let isAddRecipientModalVisible = false;
let isSubmitting = false;
@@ -369,6 +387,65 @@
refreshImportsPaginated();
};
+ const onClickCreateRecipient = async () => {
+ try {
+ isSubmitting = true;
+ const res = await api.recipient.create({
+ email: createRecipientValues.email,
+ phone: createRecipientValues.phone,
+ extraIdentifier: createRecipientValues.extraIdentifier,
+ firstName: createRecipientValues.firstName,
+ lastName: createRecipientValues.lastName,
+ position: createRecipientValues.position,
+ department: createRecipientValues.department,
+ city: createRecipientValues.city,
+ country: createRecipientValues.country,
+ misc: createRecipientValues.misc,
+ companyID: contextCompanyID
+ });
+ if (!res.success) {
+ createRecipientError = res.error;
+ return;
+ }
+ const addRes = await api.recipient.addToGroup($page.params.id, [res.data.id]);
+ if (!addRes.success) {
+ createRecipientError = addRes.error;
+ return;
+ }
+ addToast('Recipient created and added to group', 'Success');
+ refreshRecipients();
+ closeCreateRecipientModal();
+ } catch (err) {
+ addToast('Failed to create recipient', 'Error');
+ console.error('failed to create recipient', err);
+ } finally {
+ isSubmitting = false;
+ }
+ };
+
+ const openCreateRecipientModal = () => {
+ createRecipientError = '';
+ isCreateRecipientModalVisible = true;
+ };
+
+ const closeCreateRecipientModal = () => {
+ isCreateRecipientModalVisible = false;
+ createRecipientError = '';
+ createRecipientValues = {
+ email: '',
+ phone: '',
+ extraIdentifier: '',
+ firstName: '',
+ lastName: '',
+ position: '',
+ department: '',
+ city: '',
+ country: '',
+ misc: ''
+ };
+ createRecipientForm.reset();
+ };
+
const openAddRecipientsModal = () => {
isAddRecipientModalVisible = true;
};
@@ -422,6 +499,10 @@
are included automatically.
{:else}
+ New Recipient
Add Recipients
+
+
+
+
+ Email
+ First name
+ Last name
+ Phone
+ Extra identifier
+ Position
+
+
+ Department
+ City
+ Country
+ Miscallaneous
+
+
+
+
+
+