@licklist/design 0.44.485-dev.90 → 0.44.485-dev.91

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 (62) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/sales/manual-booking/index.d.ts +1 -5
  3. package/dist/sales/manual-booking/index.d.ts.map +1 -1
  4. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts +1 -0
  5. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.d.ts.map +1 -1
  6. package/dist/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.js +1 -1
  7. package/dist/sales/manual-booking/search-user/SearchUser.js +1 -1
  8. package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts +3 -2
  9. package/dist/sales/manual-booking/select-menu/SelectMenu.d.ts.map +1 -1
  10. package/dist/sales/manual-booking/select-menu/SelectMenu.js +1 -1
  11. package/dist/styles/sales/ManualBooking.scss +7 -1
  12. package/dist/types/iframe.d.ts +2 -0
  13. package/dist/types/iframe.d.ts.map +1 -1
  14. package/package.json +1 -1
  15. package/src/sales/manual-booking/index.ts +1 -5
  16. package/src/sales/manual-booking/number-input-horizontal/NumberInputHorizontal.tsx +3 -1
  17. package/src/sales/manual-booking/select-menu/SelectMenu.tsx +4 -2
  18. package/src/styles/sales/ManualBooking.scss +7 -1
  19. package/src/types/iframe.ts +2 -0
  20. package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts +0 -16
  21. package/dist/sales/manual-booking/category-product/CategoryProduct.d.ts.map +0 -1
  22. package/dist/sales/manual-booking/category-product/CategoryProduct.js +0 -1
  23. package/dist/sales/manual-booking/category-product/index.d.ts +0 -2
  24. package/dist/sales/manual-booking/category-product/index.d.ts.map +0 -1
  25. package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts +0 -17
  26. package/dist/sales/manual-booking/category-products/CategoryProducts.d.ts.map +0 -1
  27. package/dist/sales/manual-booking/category-products/CategoryProducts.js +0 -1
  28. package/dist/sales/manual-booking/category-products/index.d.ts +0 -2
  29. package/dist/sales/manual-booking/category-products/index.d.ts.map +0 -1
  30. package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts +0 -15
  31. package/dist/sales/manual-booking/controll/ManualBookingStepsControll.d.ts.map +0 -1
  32. package/dist/sales/manual-booking/controll/ManualBookingStepsControll.js +0 -1
  33. package/dist/sales/manual-booking/controll/index.d.ts +0 -2
  34. package/dist/sales/manual-booking/controll/index.d.ts.map +0 -1
  35. package/dist/sales/manual-booking/create-user/CreateUser.d.ts +0 -6
  36. package/dist/sales/manual-booking/create-user/CreateUser.d.ts.map +0 -1
  37. package/dist/sales/manual-booking/create-user/CreateUser.js +0 -1
  38. package/dist/sales/manual-booking/create-user/index.d.ts +0 -2
  39. package/dist/sales/manual-booking/create-user/index.d.ts.map +0 -1
  40. package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts +0 -7
  41. package/dist/sales/manual-booking/customer-info/CustomerInfo.d.ts.map +0 -1
  42. package/dist/sales/manual-booking/customer-info/CustomerInfo.js +0 -1
  43. package/dist/sales/manual-booking/customer-info/index.d.ts +0 -2
  44. package/dist/sales/manual-booking/customer-info/index.d.ts.map +0 -1
  45. package/dist/sales/manual-booking/final-step/FinalStep.d.ts +0 -7
  46. package/dist/sales/manual-booking/final-step/FinalStep.d.ts.map +0 -1
  47. package/dist/sales/manual-booking/final-step/FinalStep.js +0 -1
  48. package/dist/sales/manual-booking/final-step/index.d.ts +0 -2
  49. package/dist/sales/manual-booking/final-step/index.d.ts.map +0 -1
  50. package/src/sales/manual-booking/category-product/CategoryProduct.tsx +0 -285
  51. package/src/sales/manual-booking/category-product/index.ts +0 -1
  52. package/src/sales/manual-booking/category-products/CategoryProducts.tsx +0 -69
  53. package/src/sales/manual-booking/category-products/index.ts +0 -1
  54. package/src/sales/manual-booking/controll/ManualBookingStepsControll.tsx +0 -121
  55. package/src/sales/manual-booking/controll/index.ts +0 -1
  56. package/src/sales/manual-booking/create-user/CreateUser.stories.tsx +0 -27
  57. package/src/sales/manual-booking/create-user/CreateUser.tsx +0 -224
  58. package/src/sales/manual-booking/create-user/index.ts +0 -1
  59. package/src/sales/manual-booking/customer-info/CustomerInfo.tsx +0 -128
  60. package/src/sales/manual-booking/customer-info/index.ts +0 -1
  61. package/src/sales/manual-booking/final-step/FinalStep.tsx +0 -38
  62. package/src/sales/manual-booking/final-step/index.ts +0 -1
@@ -1,224 +0,0 @@
1
- import React, { useEffect } from "react";
2
- import { useFormContext } from "react-hook-form";
3
- import lettersRule from "@licklist/plugins/dist/validation/Rules/lettersRule";
4
- import { useTranslation } from "react-i18next";
5
- import { Button, Form } from "react-bootstrap";
6
- import {
7
- HookFormService,
8
- checkIsValidBirthday,
9
- emailRule,
10
- phoneRule,
11
- useDashboardUserApi,
12
- } from "@licklist/plugins/dist";
13
- import clsx from "clsx";
14
- import useNotification from "@licklist/plugins/dist/context/app/hooks/useNotification";
15
- import {
16
- DEFAULT_USER_LAST_NAME,
17
- DEFAULT_USER_EMAIL,
18
- } from "@licklist/core/dist/Config/DefaultUser";
19
- import { dateToSqlDate } from "../../../static/manual-date-picker/utils";
20
- import { ManualDatePicker } from "../../../static/manual-date-picker";
21
- import { useManualDatePicker } from "../../../static/manual-date-picker/hooks/useManualDatePicker";
22
- import { Icon } from "../../../static";
23
-
24
- export const CreateUser = ({
25
- goToSearchUsers,
26
- providerId,
27
- }: {
28
- goToSearchUsers: () => void;
29
- providerId: number;
30
- }) => {
31
- const { t } = useTranslation(["Sale", "Design", "App", "Validation"]);
32
- const notification = useNotification();
33
- const { create } = useDashboardUserApi(providerId);
34
-
35
- const {
36
- formState: { errors, isSubmitted },
37
- register,
38
- setValue,
39
- watch,
40
- getValues,
41
- } = useFormContext();
42
- const birthday = watch("birthdate");
43
- const firstname = watch("firstName");
44
- const [manualDatePickerProps, { isChoosedDateValid, fieldErrors }] =
45
- useManualDatePicker({
46
- isRequired: false,
47
- isSubmitted,
48
- fieldName: "birthdate",
49
- value: birthday,
50
- fieldErrors: HookFormService.getErrors("birthdate" as const, errors),
51
- });
52
- const { day, year, month } = manualDatePickerProps;
53
-
54
- useEffect(() => {
55
- if (!day || !month || !year || !isChoosedDateValid()) {
56
- return;
57
- }
58
-
59
- setValue("birthdate" as const, dateToSqlDate(day, month, year), {
60
- shouldValidate: true,
61
- });
62
- // eslint-disable-next-line react-hooks/exhaustive-deps
63
- }, [day, month, year]);
64
-
65
- const onAddUser = async () => {
66
- const values = getValues();
67
- const user = await create.execute({
68
- first_name: values.firstName,
69
- last_name: values.lastName,
70
- email: values.email,
71
- user_detail: {
72
- phone: values.phone,
73
- birthday: values.birthdate,
74
- },
75
- });
76
-
77
- if (!user) {
78
- return;
79
- }
80
-
81
- const userInfo = {
82
- userId: String(user.id),
83
- firstName: user.firstName,
84
- lastName: user.lastName === DEFAULT_USER_LAST_NAME ? null : user.lastName,
85
- email: user.email === DEFAULT_USER_EMAIL ? null : user.email,
86
- phone:
87
- user?.userDetail && user?.userDetail?.phone
88
- ? String(user?.userDetail?.phone)
89
- : undefined,
90
- birthdate:
91
- user?.userDetail && user.userDetail?.birthday
92
- ? user.userDetail?.birthday
93
- : undefined,
94
- };
95
- Object.entries(userInfo).forEach(([field, value]) => {
96
- setValue(field as keyof typeof userInfo, value);
97
- });
98
- notification.success({
99
- title: t("App:success"),
100
- message: t("Notification:customerAddedSuccessfully"),
101
- });
102
- };
103
-
104
- return (
105
- <>
106
- <Button
107
- as="button"
108
- type="button"
109
- onClick={goToSearchUsers}
110
- variant="primary"
111
- className="mb-4 mt-4 align-items-center d-flex"
112
- >
113
- {t("Design:search")}
114
- <Icon type="search" height="1.4rem" width="1.4rem" className="ml-3" />
115
- </Button>
116
- <div className="input-label">
117
- {t("Design:firstName")}
118
- <span className="text-danger">*</span>
119
- </div>
120
- <Form.Control
121
- type="text"
122
- isInvalid={!!errors?.firstName}
123
- {...register("firstName", {
124
- pattern: lettersRule,
125
- maxLength: 255,
126
- required: true,
127
- })}
128
- />
129
- <Form.Control.Feedback type="invalid">
130
- {HookFormService.hasError(errors?.firstName, "required") &&
131
- t("Validation:fieldRequired", {
132
- attribute: t("Design:firstName"),
133
- })}
134
- {HookFormService.hasError(errors?.firstName, "pattern") &&
135
- t("Sale:fieldIsNotValid", {
136
- attribute: t("Design:firstName"),
137
- })}
138
- </Form.Control.Feedback>
139
- <div className="input-label">{t("Design:lastName")}</div>
140
- <Form.Control
141
- type="text"
142
- isInvalid={!!errors?.lastName}
143
- {...register("lastName", {
144
- pattern: lettersRule,
145
- maxLength: 255,
146
- })}
147
- />
148
- <Form.Control.Feedback type="invalid">
149
- {errors?.lastName &&
150
- t("Sale:fieldIsNotValid", { attribute: t("Design:lastName") })}
151
- </Form.Control.Feedback>
152
- <div className="input-label">{t("Design:email")}</div>
153
- <Form.Control
154
- type="text"
155
- isInvalid={HookFormService.isInvalid(`email` as const, errors)}
156
- {...register("email", { pattern: emailRule, maxLength: 255 })}
157
- />
158
- <Form.Control.Feedback type="invalid">
159
- {errors?.email &&
160
- t("Sale:fieldIsNotValid", { attribute: t("Design:email") })}
161
- </Form.Control.Feedback>
162
- <div className="input-label">{t("Design:phone")}</div>
163
- <Form.Control
164
- type="number"
165
- {...register("phone", { pattern: phoneRule, maxLength: 255 })}
166
- isInvalid={!!errors?.phone}
167
- />
168
- <Form.Control.Feedback type="invalid">
169
- {errors?.phone &&
170
- t("Sale:fieldIsNotValid", {
171
- attribute: "phone number",
172
- })}
173
- </Form.Control.Feedback>
174
- <div className="input-label">{t("Design:dayOfBirthShort")}</div>
175
- <Form.Control
176
- type="hidden"
177
- {...register("birthdate", {
178
- validate: (value) => {
179
- if (!value) {
180
- return true;
181
- }
182
-
183
- if (!checkIsValidBirthday(value)) {
184
- return `${t("Sale:fieldIsNotValid", {
185
- attribute: t("App:birthday"),
186
- })}`;
187
- }
188
-
189
- return true;
190
- },
191
- })}
192
- isInvalid={!!errors.birthdate}
193
- className={clsx(
194
- "datetime-form-picker",
195
- birthday && "date-input-with-value"
196
- )}
197
- />
198
- <div className="d-flex">
199
- <ManualDatePicker {...manualDatePickerProps} isRequred={false} />
200
- </div>
201
- <Form.Control.Feedback type="invalid">
202
- {errors?.birthdate?.message || fieldErrors()}
203
- </Form.Control.Feedback>
204
- <Button
205
- as="button"
206
- type="button"
207
- onClick={onAddUser}
208
- variant="primary"
209
- className="mb-4"
210
- disabled={
211
- !firstname ||
212
- errors?.firstName ||
213
- errors?.lastName ||
214
- errors?.email ||
215
- errors?.phone ||
216
- errors?.birthday ||
217
- create.isLoading
218
- }
219
- >
220
- {t("Sale:addCustomer")}
221
- </Button>
222
- </>
223
- );
224
- };
@@ -1 +0,0 @@
1
- export * from "./CreateUser";
@@ -1,128 +0,0 @@
1
- import React, { FC, useEffect, useMemo, useState } from "react";
2
- import { Accordion } from "react-bootstrap";
3
- import { useTranslation } from "react-i18next";
4
- import { useFormContext } from "react-hook-form";
5
- import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
6
- import { CreateUser } from "../create-user/CreateUser";
7
- import { CollapsibleInputGroup } from "../../../collapsible-input-group";
8
- import { SearchUser } from "../search-user";
9
-
10
- type CustomerInfoProps = { providerId: number | undefined };
11
-
12
- const userFields = [
13
- "firstName",
14
- "lastName",
15
- "userId",
16
- "birthday",
17
- "phone",
18
- "email",
19
- ] as const;
20
-
21
- export const CustomerInfo: FC<CustomerInfoProps> = ({ providerId }) => {
22
- const { t } = useTranslation(["Sale", "Design", "Validation"]);
23
- const {
24
- formState: { errors },
25
- watch,
26
- clearErrors,
27
- setValue,
28
- register,
29
- } = useFormContext();
30
- const firstName = watch("firstName");
31
- const firstNameRequired = useMemo(
32
- () => HookFormService.hasError(errors?.firstName, "required"),
33
- [errors?.firstName]
34
- );
35
-
36
- const errorMessage = firstNameRequired
37
- ? t("Validation:fieldRequired", {
38
- attribute: t("Sale:Customer first name"),
39
- })
40
- : t("Sale:customerInfoError");
41
-
42
- useEffect(() => {
43
- if (!firstNameRequired || !firstName || !firstName.length) {
44
- return;
45
- }
46
-
47
- clearErrors("firstName");
48
- // eslint-disable-next-line react-hooks/exhaustive-deps
49
- }, [errors?.firstName, firstName]);
50
-
51
- const customerInfoError = useMemo(
52
- () =>
53
- !!errors?.firstName ||
54
- !!errors?.lastName ||
55
- !!errors?.email ||
56
- !!errors?.phone ||
57
- !!errors?.birthdate,
58
- [
59
- errors.firstName,
60
- errors?.lastName,
61
- errors?.email,
62
- errors?.phone,
63
- errors?.birthdate,
64
- ]
65
- );
66
-
67
- const [isCreatingUser, setCreatingUser] = useState(false);
68
-
69
- const resetFields = (fieldForSave?: string) => {
70
- userFields.forEach((field) => {
71
- if (fieldForSave && field === fieldForSave) {
72
- return;
73
- }
74
- setValue(field, undefined);
75
- });
76
- };
77
-
78
- const handleNoFoundUsers = (isSearchName?: boolean) => {
79
- setCreatingUser(true);
80
- resetFields(isSearchName ? "firstName" : "email");
81
- };
82
-
83
- const goToSearchUsers = () => {
84
- setCreatingUser(false);
85
- resetFields();
86
- };
87
-
88
- register("firstName", { required: true });
89
-
90
- return (
91
- <Accordion className="medium-accordition accordition-customer-info">
92
- <CollapsibleInputGroup
93
- description=""
94
- eventKey="medium-accordition"
95
- label={
96
- <>
97
- <div className="medium-accordition-header">
98
- <div className="product-title">{t("Sale:customerInfo")}</div>
99
- </div>
100
- {customerInfoError && (
101
- <div className="d-flex mt-3 w-100">
102
- <p className="iframe-event__message-error mb-0">
103
- {errorMessage}
104
- </p>
105
- </div>
106
- )}
107
- </>
108
- }
109
- >
110
- <div className="customer-info">
111
- {isCreatingUser ? (
112
- <>
113
- <CreateUser
114
- goToSearchUsers={goToSearchUsers}
115
- providerId={providerId}
116
- />
117
- </>
118
- ) : (
119
- <SearchUser
120
- providerId={providerId}
121
- handleNoFoundUsers={handleNoFoundUsers}
122
- />
123
- )}
124
- </div>
125
- </CollapsibleInputGroup>
126
- </Accordion>
127
- );
128
- };
@@ -1 +0,0 @@
1
- export * from "./CustomerInfo";
@@ -1,38 +0,0 @@
1
- import React, { FC } from "react";
2
- import { useTranslation } from "react-i18next";
3
- import { Controller, useFormContext } from "react-hook-form";
4
- import { CustomerInfo } from "../customer-info/CustomerInfo";
5
-
6
- type FinalStepProps = { providerId: number | undefined };
7
-
8
- export const FinalStep: FC<FinalStepProps> = ({ providerId }) => {
9
- const { t } = useTranslation("Sale");
10
- const { control } = useFormContext();
11
- return (
12
- <>
13
- <div className="manual-booking-header mt-6 mt-5 border-bottom">
14
- <div className="manual-booking-title">{t("Sale:finalSteps")}</div>
15
- </div>
16
- <CustomerInfo providerId={providerId} />
17
- <Controller
18
- control={control}
19
- name={`specialNotes` as const}
20
- render={({ field: { onChange, value, ref } }) => (
21
- <div className="special-notes-container">
22
- <div className="margin-top-2-rem input-label ">
23
- {t("specialNotes")}
24
- </div>
25
-
26
- <textarea
27
- rows={3}
28
- onChange={onChange}
29
- ref={ref}
30
- value={value}
31
- className="special-notes"
32
- />
33
- </div>
34
- )}
35
- />
36
- </>
37
- );
38
- };
@@ -1 +0,0 @@
1
- export * from "./FinalStep";