@licklist/design 0.44.504 → 0.44.506

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/events/edit-event-modal/IntervalInput.d.ts +4 -1
  2. package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
  3. package/dist/events/edit-event-modal/IntervalInput.js +1 -1
  4. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
  5. package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
  6. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  7. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  8. package/dist/events/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
  9. package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/notification/email-template/card/EmailTemplateCard.d.ts +4 -1
  12. package/dist/notification/email-template/card/EmailTemplateCard.d.ts.map +1 -1
  13. package/dist/notification/email-template/card/EmailTemplateCard.js +1 -1
  14. package/dist/notification/email-template/control/EmailTemplateControl.d.ts +3 -0
  15. package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
  16. package/dist/notification/email-template/control/EmailTemplateControl.js +1 -1
  17. package/dist/notification/email-template/form/EmailTemplateForm.d.ts +7 -1
  18. package/dist/notification/email-template/form/EmailTemplateForm.d.ts.map +1 -1
  19. package/dist/notification/email-template/form/EmailTemplateForm.js +1 -1
  20. package/dist/notification/hooks/useTranslatedParameters.d.ts +7 -0
  21. package/dist/notification/hooks/useTranslatedParameters.d.ts.map +1 -0
  22. package/dist/notification/hooks/useTranslatedParameters.js +1 -0
  23. package/dist/notification/sms-template/card/SmsTemplateCard.d.ts +4 -1
  24. package/dist/notification/sms-template/card/SmsTemplateCard.d.ts.map +1 -1
  25. package/dist/notification/sms-template/card/SmsTemplateCard.js +1 -1
  26. package/dist/notification/sms-template/control/SmsTemplateControl.d.ts +6 -1
  27. package/dist/notification/sms-template/control/SmsTemplateControl.d.ts.map +1 -1
  28. package/dist/notification/sms-template/control/SmsTemplateControl.js +1 -1
  29. package/dist/notification/sms-template/form/SmsTemplateForm.d.ts +5 -1
  30. package/dist/notification/sms-template/form/SmsTemplateForm.d.ts.map +1 -1
  31. package/dist/notification/sms-template/form/SmsTemplateForm.js +1 -1
  32. package/dist/product-set/control/ProductSetControl.d.ts +15 -4
  33. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  34. package/dist/product-set/control/ProductSetControl.js +1 -1
  35. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  36. package/dist/product-set/form/ProductSetForm.js +1 -1
  37. package/dist/product-set/utils/index.d.ts +4 -0
  38. package/dist/product-set/utils/index.d.ts.map +1 -1
  39. package/dist/product-set/utils/index.js +1 -1
  40. package/dist/provider/provider-details-input/ProviderDetailsInput.d.ts.map +1 -1
  41. package/dist/provider/provider-details-input/ProviderDetailsInput.js +1 -1
  42. package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts.map +1 -1
  43. package/dist/styles/snippet-templates/SnippetTemplateCard.scss +16 -0
  44. package/dist/typeahead/Typeahead.d.ts +4 -11
  45. package/dist/typeahead/Typeahead.d.ts.map +1 -1
  46. package/dist/typeahead/Typeahead.js +1 -1
  47. package/package.json +1 -1
  48. package/src/events/edit-event-modal/IntervalInput.tsx +21 -1
  49. package/src/events/edit-event-modal/component/EditEventForm/EditEventForm.tsx +3 -0
  50. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +11 -2
  51. package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +5 -4
  52. package/src/notification/email-template/card/EmailTemplateCard.stories.tsx +4 -2
  53. package/src/notification/email-template/card/EmailTemplateCard.tsx +15 -3
  54. package/src/notification/email-template/control/EmailTemplateControl.tsx +90 -6
  55. package/src/notification/email-template/form/EmailTemplateForm.stories.tsx +34 -0
  56. package/src/notification/email-template/form/EmailTemplateForm.tsx +23 -5
  57. package/src/notification/hooks/useTranslatedParameters.ts +27 -0
  58. package/src/notification/sms-template/card/SmsTemplateCard.stories.tsx +3 -1
  59. package/src/notification/sms-template/card/SmsTemplateCard.tsx +13 -3
  60. package/src/notification/sms-template/control/SmsTemplateControl.tsx +40 -2
  61. package/src/notification/sms-template/form/SmsTemplateForm.stories.tsx +28 -0
  62. package/src/notification/sms-template/form/SmsTemplateForm.tsx +6 -1
  63. package/src/product-set/control/ProductSetControl.tsx +38 -33
  64. package/src/product-set/form/ProductSetForm.stories.tsx +41 -2
  65. package/src/product-set/form/ProductSetForm.tsx +11 -0
  66. package/src/product-set/utils/index.ts +28 -0
  67. package/src/provider/provider-details-input/ProviderDetailsInput.tsx +0 -2
  68. package/src/sales/manual-booking/select-menu/SelectMenu.tsx +3 -1
  69. package/src/styles/snippet-templates/SnippetTemplateCard.scss +16 -0
  70. package/src/typeahead/Typeahead.stories.tsx +9 -6
  71. package/src/typeahead/Typeahead.tsx +9 -12
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/display-name */
2
1
  import React, { useState, useEffect } from "react";
3
2
  import { Col, Row, Form } from "react-bootstrap";
4
3
  import { useFormContext } from "react-hook-form";
@@ -16,6 +15,7 @@ import {
16
15
  PERMANENT_IMAGE_TYPE_TEMP,
17
16
  } from "@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper";
18
17
 
18
+ import { NotificationType } from "@licklist/core/dist/DataMapper/Notification/NotificationTypeDataMapper";
19
19
  import { FileUpload } from "../../../file-upload";
20
20
  import { EmailTemplateValues } from "../form";
21
21
 
@@ -26,6 +26,8 @@ export interface EmailTemplateControlProps {
26
26
  setIsLoading: (isLoading: boolean) => void;
27
27
  meta: string;
28
28
  defaultAttachments?: Attachment[];
29
+ notificationTypes?: NotificationType[];
30
+ getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string;
29
31
  }
30
32
 
31
33
  export const EmailTemplateControl = React.forwardRef(
@@ -35,6 +37,8 @@ export const EmailTemplateControl = React.forwardRef(
35
37
  meta,
36
38
  options = [],
37
39
  defaultAttachments = [],
40
+ notificationTypes = [],
41
+ getDefaultTemplateMetaByType,
38
42
  }: EmailTemplateControlProps,
39
43
  ref: any
40
44
  ) => {
@@ -48,6 +52,8 @@ export const EmailTemplateControl = React.forwardRef(
48
52
  setValue,
49
53
  formState: { errors },
50
54
  getValues,
55
+ watch,
56
+ reset,
51
57
  } = useFormContext<EmailTemplateValues>();
52
58
  const [isIncludePDF, setIsIncludePDF] = useState(false);
53
59
 
@@ -64,12 +70,29 @@ export const EmailTemplateControl = React.forwardRef(
64
70
  handlePermanentImageUploading,
65
71
  } = usePermanentImage();
66
72
 
73
+ const type = watch("type");
74
+ const id = watch("id");
75
+
76
+ useEffect(() => {
77
+ if (id || !getDefaultTemplateMetaByType || !type) return;
78
+
79
+ const formValues = getValues();
80
+
81
+ const nextMeta = getDefaultTemplateMetaByType(type);
82
+
83
+ reset({ ...formValues, meta: nextMeta });
84
+
85
+ ref.current?.loadDesign(JSON.parse(nextMeta));
86
+ // eslint-disable-next-line react-hooks/exhaustive-deps
87
+ }, [type]);
88
+
67
89
  useEffect(() => {
68
90
  setValue("attachmentMetadata", attachments);
69
91
  }, [attachments, setValue]);
70
92
 
71
93
  useEffect(() => {
72
94
  if (!permanentImages.length) return;
95
+
73
96
  setValue("imagesMetadata", permanentImages);
74
97
  }, [permanentImages, setValue]);
75
98
 
@@ -85,13 +108,15 @@ export const EmailTemplateControl = React.forwardRef(
85
108
  }, [defaultAttachments]);
86
109
 
87
110
  useEffect(() => {
88
- if (!options.length) return;
111
+ if (!options?.length) return;
112
+
89
113
  const fileSelectorOptions = options.find(
90
114
  (option) => option.type === OPTION_TYPE.files_selector
91
115
  );
92
- if (fileSelectorOptions.selectedValue) {
93
- setIsIncludePDF(true);
94
- }
116
+
117
+ if (!fileSelectorOptions?.selectedValue) return;
118
+
119
+ setIsIncludePDF(true);
95
120
  }, [options]);
96
121
 
97
122
  const handleDeleteEmailImage = (content) => {
@@ -175,6 +200,42 @@ export const EmailTemplateControl = React.forwardRef(
175
200
 
176
201
  return (
177
202
  <>
203
+ <Row>
204
+ <Form.Group
205
+ as={Col}
206
+ controlId="type"
207
+ xs
208
+ sm={12}
209
+ md={8}
210
+ lg={10}
211
+ xl={12}
212
+ >
213
+ <Form.Label>{t("type")}</Form.Label>
214
+ <Form.Control
215
+ as="select"
216
+ {...register("type", {
217
+ required: t("Validation:fieldRequired", {
218
+ attribute: t("type"),
219
+ }) as string,
220
+ })}
221
+ name="type"
222
+ required
223
+ isInvalid={Boolean(errors.type)}
224
+ placeholder={t("Design:type")}
225
+ disabled={!!id}
226
+ >
227
+ <option value="">{t("Design:choose")}</option>
228
+ {notificationTypes.map((key) => (
229
+ <option key={key} value={key}>
230
+ {t(`Design:${key}`)}
231
+ </option>
232
+ ))}
233
+ </Form.Control>
234
+ <Form.Control.Feedback type="invalid">
235
+ {errors.type?.message}
236
+ </Form.Control.Feedback>
237
+ </Form.Group>
238
+ </Row>
178
239
  <Row>
179
240
  <Form.Group
180
241
  as={Col}
@@ -279,7 +340,7 @@ export const EmailTemplateControl = React.forwardRef(
279
340
  isLoading={isAttachmentLoading}
280
341
  />
281
342
  </Row>
282
- {options.length > 0 && (
343
+ {options?.length > 0 && (
283
344
  <Row>
284
345
  <Form.Group as={Col}>
285
346
  {options.map((option) => {
@@ -347,6 +408,27 @@ export const EmailTemplateControl = React.forwardRef(
347
408
  </>
348
409
  );
349
410
  }
411
+
412
+ if (option.type === OPTION_TYPE.days_reminder) {
413
+ return (
414
+ <>
415
+ <Form.Label className="mt-4">
416
+ {t(`Design:${option.name}`)}
417
+ </Form.Label>
418
+ <Form.Control
419
+ {...register(
420
+ `templateOptionValues.${option?.id}.value` as any
421
+ )}
422
+ type="number"
423
+ placeholder={t(`Design:${option.name}`)}
424
+ id={option.name + option.id}
425
+ defaultValue={option.selectedValue || ""}
426
+ />
427
+ <Form.Text>{option.description}</Form.Text>
428
+ </>
429
+ );
430
+ }
431
+
350
432
  return null;
351
433
  })}
352
434
  </Form.Group>
@@ -356,3 +438,5 @@ export const EmailTemplateControl = React.forwardRef(
356
438
  );
357
439
  }
358
440
  );
441
+
442
+ EmailTemplateControl.displayName = "EmailTemplateControl";
@@ -185,6 +185,7 @@ Default.args = {
185
185
  notificationType: "confirmation",
186
186
  type: "checkbox",
187
187
  defaultValue: "true",
188
+ descrption: "",
188
189
  },
189
190
  {
190
191
  id: 12,
@@ -192,6 +193,7 @@ Default.args = {
192
193
  notificationType: "confirmation",
193
194
  type: "checkbox",
194
195
  defaultValue: "false",
196
+ descrption: "",
195
197
  },
196
198
  {
197
199
  selectedValue: "invoice",
@@ -201,6 +203,17 @@ Default.args = {
201
203
  type: "files_selector",
202
204
  defaultValue:
203
205
  '{"confirmation":"Confirmation / Function Sheet","invoice":"Invoice"}',
206
+ descrption: "",
207
+ },
208
+ {
209
+ id: 13,
210
+ name: "days_reminder",
211
+ notificationType: "confirmation",
212
+ type: "days_reminder",
213
+ defaultValue: "",
214
+ description: `N.B. Add positive integer for days before the event, or negative for days after the event.
215
+ E.g. if you want this remainder to be send 2 days before the event, enter 2.
216
+ If you want this to be send 3 days after the event enter -3.`,
204
217
  },
205
218
  ],
206
219
  defaultValues: {
@@ -219,6 +232,13 @@ Default.args = {
219
232
  attachableType: "mail",
220
233
  },
221
234
  ],
235
+ type: "confirmation",
236
+ notificationTypes: [
237
+ "confirmation",
238
+ "paymentLink",
239
+ "afterBooking",
240
+ "preliminaryMail",
241
+ ],
222
242
  },
223
243
  };
224
244
 
@@ -248,10 +268,24 @@ ServerErrors.args = {
248
268
  body: "",
249
269
  meta: JSON.stringify(DefaultEmailTemplate),
250
270
  },
271
+ type: "confirmation",
272
+ notificationTypes: [
273
+ "confirmation",
274
+ "paymentLink",
275
+ "afterBooking",
276
+ "preliminaryMail",
277
+ ],
251
278
  };
252
279
 
253
280
  Empty.args = {
254
281
  onSubmit: (data) => console.log(data),
255
282
  isLoading: true,
256
283
  placeholders: [],
284
+ type: "confirmation",
285
+ notificationTypes: [
286
+ "confirmation",
287
+ "paymentLink",
288
+ "afterBooking",
289
+ "preliminaryMail",
290
+ ],
257
291
  };
@@ -13,12 +13,13 @@ import { ServerError } from "@licklist/plugins/dist/hooks/Api/useHttpQuery";
13
13
  import FormErrorService from "@licklist/plugins/dist/services/Form/FormErrorService";
14
14
  import { AttachmentsWithHash } from "@licklist/plugins/dist/hooks/Media/useAttachments";
15
15
  import { UploadPermanentImage } from "@licklist/core/dist/DataMapper/Media/UploadPermanentImageDataMapper";
16
-
16
+ import { NotificationType } from "@licklist/core/dist/DataMapper/Notification/NotificationTypeDataMapper";
17
17
  import { NotificationPlaceholders } from "../../components/NotificationPlaceholders";
18
18
  import { EmailTemplateControl } from "../control/EmailTemplateControl";
19
19
  import { BlockLoader } from "../../../static";
20
20
 
21
21
  export interface EmailTemplateValues extends FormValues {
22
+ id?: number | string;
22
23
  name: string;
23
24
  subject: string;
24
25
  isActive: boolean;
@@ -29,6 +30,7 @@ export interface EmailTemplateValues extends FormValues {
29
30
  attachments?: Attachment[];
30
31
  templateOptionValues?: TemplateOptionValue[];
31
32
  imagesMetadata?: UploadPermanentImage[];
33
+ type?: NotificationType;
32
34
  }
33
35
 
34
36
  export interface EmailTemplateProps extends HasPermissionProp {
@@ -39,9 +41,12 @@ export interface EmailTemplateProps extends HasPermissionProp {
39
41
  placeholders?: NotificationPlaceholder[];
40
42
  options?: TemplateOption[];
41
43
  serverErrors?: ServerError;
44
+ notificationTypes?: NotificationType[];
45
+ getDefaultTemplateMetaByType?: (type?: NotificationType | null) => string;
46
+ onTypeChange?: (type?: NotificationType | null) => void;
42
47
  }
43
48
 
44
- export function EmailTemplateForm({
49
+ export const EmailTemplateForm = ({
45
50
  defaultValues,
46
51
  onSubmitSave,
47
52
  onSubmitSaveAndSend,
@@ -49,7 +54,10 @@ export function EmailTemplateForm({
49
54
  placeholders = [],
50
55
  options = [],
51
56
  serverErrors,
52
- }: EmailTemplateProps) {
57
+ notificationTypes = [],
58
+ getDefaultTemplateMetaByType,
59
+ onTypeChange,
60
+ }: EmailTemplateProps) => {
53
61
  const { t } = useTranslation("Design");
54
62
  const [isLoading, setIsLoading] = useState(false);
55
63
  const emailEditorRef = useRef(null);
@@ -59,12 +67,20 @@ export function EmailTemplateForm({
59
67
  defaultValues,
60
68
  });
61
69
 
62
- const { setError } = form;
70
+ const { setError, watch } = form;
71
+ const type = watch("type");
63
72
 
64
73
  useEffect(() => {
65
74
  FormErrorService.handleServerErrors(serverErrors, setError);
66
75
  }, [serverErrors, setError]);
67
76
 
77
+ useEffect(() => {
78
+ if (!onTypeChange) return;
79
+
80
+ onTypeChange(type);
81
+ // eslint-disable-next-line react-hooks/exhaustive-deps
82
+ }, [type]);
83
+
68
84
  return (
69
85
  <FormProvider {...form}>
70
86
  {isLoading && <BlockLoader />}
@@ -81,6 +97,8 @@ export function EmailTemplateForm({
81
97
  meta={defaultValues?.meta || null}
82
98
  defaultAttachments={defaultValues?.attachments || []}
83
99
  options={options}
100
+ notificationTypes={notificationTypes}
101
+ getDefaultTemplateMetaByType={getDefaultTemplateMetaByType}
84
102
  />
85
103
  <NotificationPlaceholders placeholders={placeholders} />
86
104
  {/* update email template */}
@@ -106,4 +124,4 @@ export function EmailTemplateForm({
106
124
  </Form>
107
125
  </FormProvider>
108
126
  );
109
- }
127
+ };
@@ -0,0 +1,27 @@
1
+ import { useTranslation } from "react-i18next";
2
+
3
+ type UseTranslatedParametersProps = {
4
+ isDefault: boolean;
5
+ isActive: boolean;
6
+ };
7
+
8
+ export const useTranslatedParameters = ({
9
+ isActive,
10
+ isDefault,
11
+ }: UseTranslatedParametersProps) => {
12
+ const { t } = useTranslation(["Design"]);
13
+
14
+ const translatedParameters = () => {
15
+ const texts: string[] = [];
16
+ if (isDefault) {
17
+ texts.push(t("Design:default"));
18
+ }
19
+ if (isActive) {
20
+ texts.push(t("Design:active"));
21
+ }
22
+
23
+ return texts.join(", ");
24
+ };
25
+
26
+ return translatedParameters();
27
+ };
@@ -14,7 +14,9 @@ export const Default: Story<SmsTemplateCardProps> = (args) => (
14
14
 
15
15
  Default.args = {
16
16
  href: "#",
17
- name: "Default Sms Template",
17
+ name: "Default Sms Template with Long name",
18
18
  hasPermission: true,
19
19
  isDefault: true,
20
+ templateType: "confirmation",
21
+ isActive: true,
20
22
  };
@@ -1,16 +1,19 @@
1
1
  import React from "react";
2
2
  import { Link } from "react-router-dom";
3
- import { HasPermissionProp } from "@licklist/plugins/dist/types/permission/Permission";
4
3
  import { useTranslation } from "react-i18next";
5
-
4
+ import { HasPermissionProp } from "@licklist/plugins/dist/types/permission/Permission";
5
+ import { NotificationType } from "@licklist/core/dist/DataMapper/Notification/NotificationTypeDataMapper";
6
6
  import { ConfirmModal, ConfirmModalType } from "../../../modals";
7
7
  import { Icon } from "../../../static";
8
+ import { useTranslatedParameters } from "../../hooks/useTranslatedParameters";
8
9
 
9
10
  export interface SmsTemplateCardProps extends HasPermissionProp {
10
11
  name: string;
11
12
  href: string;
12
13
  onRemove: () => void;
13
14
  isDefault: boolean;
15
+ isActive: boolean;
16
+ type: NotificationType;
14
17
  }
15
18
 
16
19
  export function SmsTemplateCard({
@@ -19,9 +22,13 @@ export function SmsTemplateCard({
19
22
  onRemove,
20
23
  hasPermission = true,
21
24
  isDefault = false,
25
+ isActive = false,
26
+ type,
22
27
  }: SmsTemplateCardProps) {
23
28
  const { t } = useTranslation(["Design"]);
24
29
 
30
+ const texts = useTranslatedParameters({ isActive, isDefault });
31
+
25
32
  return (
26
33
  <div className="snippet-template-card">
27
34
  <div className="snippet-template-card-header">
@@ -50,7 +57,10 @@ export function SmsTemplateCard({
50
57
  )}
51
58
  </div>
52
59
  <div className="mt-2">
53
- {Boolean(isDefault) && <p className="mb-1">{t("Design:default")}</p>}
60
+ {!!texts.length && <p className="mb-1">{texts}</p>}
61
+ <p className="mb-0">
62
+ {t(`Design:type`)}:&nbsp;{t(`Design:${type}`)}
63
+ </p>
54
64
  </div>
55
65
  </div>
56
66
  );
@@ -4,12 +4,18 @@ import { Col, Row, Form } from "react-bootstrap";
4
4
  import { useFormContext } from "react-hook-form";
5
5
  import { useTranslation } from "react-i18next";
6
6
  import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
7
-
7
+ import { NotificationType } from "@licklist/core/dist/DataMapper/Notification/NotificationTypeDataMapper";
8
8
  import { SmsTemplateValues } from "../form";
9
9
 
10
10
  const MAX_SMS_LENGTH = 300;
11
11
 
12
- export const SmsTemplateControl = () => {
12
+ type SmsTemplateControlProps = {
13
+ notificationTypes: NotificationType[];
14
+ };
15
+
16
+ export const SmsTemplateControl = ({
17
+ notificationTypes = [],
18
+ }: SmsTemplateControlProps) => {
13
19
  const { t } = useTranslation(["Design"]);
14
20
  const {
15
21
  register,
@@ -20,9 +26,39 @@ export const SmsTemplateControl = () => {
20
26
  } = useFormContext<SmsTemplateValues>();
21
27
 
22
28
  const smsBody = watch("body");
29
+ const id = watch("id");
23
30
 
24
31
  return (
25
32
  <>
33
+ <Row>
34
+ <Form.Group as={Col} controlId="type" xs sm={12} md={8} lg={10} xl={12}>
35
+ <Form.Label>{t("type")}</Form.Label>
36
+
37
+ <Form.Control
38
+ as="select"
39
+ {...register("type", {
40
+ required: t("Validation:fieldRequired", {
41
+ attribute: t("type"),
42
+ }) as string,
43
+ })}
44
+ name="type"
45
+ required
46
+ isInvalid={Boolean(errors.type)}
47
+ placeholder={t("Design:type")}
48
+ disabled={!!id}
49
+ >
50
+ <option value="">{t("Design:choose")}</option>
51
+ {notificationTypes.map((key) => (
52
+ <option key={key} value={key}>
53
+ {t(`Design:${key}`)}
54
+ </option>
55
+ ))}
56
+ </Form.Control>
57
+ <Form.Control.Feedback type="invalid">
58
+ {errors.type?.message}
59
+ </Form.Control.Feedback>
60
+ </Form.Group>
61
+ </Row>
26
62
  <Row>
27
63
  <Form.Group
28
64
  as={Col}
@@ -62,6 +98,8 @@ export const SmsTemplateControl = () => {
62
98
  <Form.Label>{t("Design:smsBody")}</Form.Label>
63
99
  <Form.Control
64
100
  isInvalid={Boolean(errors.body)}
101
+ as="textarea"
102
+ rows={3}
65
103
  {...register("body", {
66
104
  required: true,
67
105
  maxLength: MAX_SMS_LENGTH,
@@ -38,12 +38,26 @@ Default.args = {
38
38
  isDefault: false,
39
39
  body: "Some random sms string",
40
40
  },
41
+ type: "confirmation",
42
+ notificationTypes: [
43
+ "confirmation",
44
+ "paymentLink",
45
+ "afterBooking",
46
+ "preliminaryMail",
47
+ ],
41
48
  };
42
49
 
43
50
  Empty.args = {
44
51
  onSubmit: (data) => console.log(data),
45
52
  isLoading: true,
46
53
  placeholders: [],
54
+ type: "confirmation",
55
+ notificationTypes: [
56
+ "confirmation",
57
+ "paymentLink",
58
+ "afterBooking",
59
+ "preliminaryMail",
60
+ ],
47
61
  };
48
62
 
49
63
  ServerErrors.args = {
@@ -54,4 +68,18 @@ ServerErrors.args = {
54
68
  body: ["Body field is required"],
55
69
  name: ["Name Field is required"],
56
70
  },
71
+ type: "confirmation",
72
+ notificationTypes: [
73
+ "confirmation",
74
+ "paymentLink",
75
+ "afterBooking",
76
+ "preliminaryMail",
77
+ ],
78
+ defaultValues: {
79
+ name: "",
80
+ isActive: false,
81
+ isDefault: false,
82
+ body: "Some random sms string",
83
+ id: 5,
84
+ },
57
85
  };
@@ -8,6 +8,7 @@ import { NotificationPlaceholder } from "@licklist/core/dist/DataMapper/Notifica
8
8
  import { ServerError } from "@licklist/plugins/dist/hooks/Api/useHttpQuery";
9
9
  import FormErrorService from "@licklist/plugins/dist/services/Form/FormErrorService";
10
10
 
11
+ import { NotificationType } from "@licklist/core/dist/DataMapper/Notification/NotificationTypeDataMapper";
11
12
  import { NotificationPlaceholders } from "../../components/NotificationPlaceholders";
12
13
  import { SmsTemplateControl } from "../control/SmsTemplateControl";
13
14
 
@@ -16,6 +17,8 @@ export interface SmsTemplateValues extends FormValues {
16
17
  isActive: boolean;
17
18
  isDefault: boolean;
18
19
  body: string;
20
+ type?: NotificationType;
21
+ id?: number | string;
19
22
  }
20
23
 
21
24
  export interface SmsTemplateProps extends HasPermissionProp {
@@ -24,6 +27,7 @@ export interface SmsTemplateProps extends HasPermissionProp {
24
27
  defaultValues?: SmsTemplateValues;
25
28
  placeholders?: NotificationPlaceholder[];
26
29
  serverErrors?: ServerError;
30
+ notificationTypes?: NotificationType[];
27
31
  }
28
32
 
29
33
  export function SmsTemplateForm({
@@ -32,6 +36,7 @@ export function SmsTemplateForm({
32
36
  hasPermission = true,
33
37
  placeholders = [],
34
38
  serverErrors,
39
+ notificationTypes = [],
35
40
  }: SmsTemplateProps) {
36
41
  const { t } = useTranslation("Design");
37
42
 
@@ -46,7 +51,7 @@ export function SmsTemplateForm({
46
51
  return (
47
52
  <FormProvider {...form}>
48
53
  <Form onSubmit={form.handleSubmit(onSubmit)}>
49
- <SmsTemplateControl />
54
+ <SmsTemplateControl notificationTypes={notificationTypes} />
50
55
  <NotificationPlaceholders placeholders={placeholders} />
51
56
 
52
57
  {hasPermission && (