From e46f3d32e58e1971bd5e8acfc42e0c79888b7735 Mon Sep 17 00:00:00 2001 From: Yaroslav Kosterin Date: Fri, 30 May 2025 14:14:10 +0300 Subject: [PATCH 01/13] add reservation note setting --- .../products-edit/elements/ProductsForm.tsx | 58 +++++++++++++++++++ .../ReservationsSettings.tsx | 49 ++++++++++++++++ .../dashboard/i18n/nl/pages/product-edit.js | 2 + .../i18n/nl/pages/reservations-settings.js | 2 + .../dashboard/props/models/Organization.tsx | 2 + react/src/dashboard/props/models/Product.tsx | 2 + .../props/models/Sponsor/SponsorProduct.tsx | 2 + .../src/dashboard/services/ProductService.ts | 2 + 8 files changed, 119 insertions(+) diff --git a/react/src/dashboard/components/pages/products-edit/elements/ProductsForm.tsx b/react/src/dashboard/components/pages/products-edit/elements/ProductsForm.tsx index 93771f9fd..e52c39f09 100644 --- a/react/src/dashboard/components/pages/products-edit/elements/ProductsForm.tsx +++ b/react/src/dashboard/components/pages/products-edit/elements/ProductsForm.tsx @@ -32,6 +32,7 @@ import TranslateHtml from '../../../elements/translate-html/TranslateHtml'; import FormGroupInfo from '../../../elements/forms/elements/FormGroupInfo'; import SponsorProduct from '../../../../props/models/Sponsor/SponsorProduct'; import usePushApiError from '../../../../hooks/usePushApiError'; +import FormGroup from '../../../elements/forms/controls/FormGroup'; export default function ProductsForm({ organization, @@ -77,6 +78,11 @@ export default function ProductsForm({ required: 'Verplicht', }); + const [reservationNoteOptionText] = useState(() => [ + { value: 'no', label: 'Geen' }, + { value: 'custom', label: 'Aangepaste aankoopnotitie' }, + ]); + const [reservationFieldOptions] = useState(() => [ { value: 'no', label: 'Nee' }, { value: 'optional', label: 'Optioneel' }, @@ -130,6 +136,15 @@ export default function ProductsForm({ ]; }, [organization?.reservation_birth_date, reservationFieldText, reservationFieldOptions]); + const reservationNoteOptions = useMemo(() => { + const defaultValue = organization.reservation_note ? 'Ja' : 'Nee'; + + return [ + { value: 'global', label: `Gebruik standaard instelling (${defaultValue})` }, + ...reservationNoteOptionText, + ]; + }, [organization?.reservation_note, reservationNoteOptionText]); + const [priceTypes] = useState([ { value: 'regular', label: 'Normaal' }, { value: 'discount_fixed', label: 'Korting €' }, @@ -251,6 +266,8 @@ export default function ProductsForm({ reservation_birth_date: 'global' | 'no' | 'optional' | 'required'; reservation_extra_payments: 'global' | 'no' | 'yes'; reservation_policy?: 'global' | 'accept' | 'review'; + reservation_note?: 'global' | 'no' | 'custom'; + reservation_note_text?: string; }>(null, (values) => { if (product && !product.unlimited_stock && form.values.stock_amount < 0) { form.setIsLocked(false); @@ -492,6 +509,8 @@ export default function ProductsForm({ reservation_birth_date: 'global', reservation_extra_payments: 'global', reservation_policy: 'global', + reservation_note: 'global', + reservation_note_text: '', }, ); }, [product, sourceProduct, updateForm, productService, id, sourceId, organization]); @@ -1061,6 +1080,45 @@ export default function ProductsForm({ )} +
+
+
+ ( + { + form.update({ reservation_note }); + }} + options={reservationNoteOptions} + /> + )} + /> + + {form.values.reservation_note === 'custom' && ( + ( +