@licklist/design 0.44.486-dev.64 → 0.44.486-dev.65
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.
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts +5 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +4 -1
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts +3 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
- package/dist/sales/payment-form/SalePaymentForm.js +1 -1
- package/dist/styles/form/CustomCheckbox.scss +1 -0
- package/dist/styles/zones/ZoneForm.scss +3 -0
- package/dist/zone/form/ZoneForm.d.ts +1 -1
- package/dist/zone/form/ZoneForm.d.ts.map +1 -1
- package/dist/zone/form/ZoneForm.js +1 -1
- package/dist/zone/form/components/ZoneControl.d.ts +1 -1
- package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneControl.js +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
- package/package.json +1 -1
- package/src/product-set/control/DateAndRecurrenceInput.tsx +62 -2
- package/src/product-set/control/ProductSetControl.tsx +8 -0
- package/src/product-set/form/ProductSetForm.tsx +7 -0
- package/src/styles/form/CustomCheckbox.scss +1 -0
- package/src/styles/zones/ZoneForm.scss +3 -0
- package/src/zone/form/ZoneForm.tsx +1 -2
- package/src/zone/form/components/ZoneControl.tsx +1 -2
- package/src/zone/form/components/ZoneRecurrencesControl.tsx +2 -51
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Modifier } from "@popperjs/core";
|
|
3
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
3
4
|
import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
|
|
4
5
|
export interface DateAndRecurrenceInputValues {
|
|
5
6
|
menuRecurrences?: Partial<ProductSetRecurrence>[];
|
|
6
7
|
}
|
|
7
8
|
interface DateAndRecurrenceInputProps {
|
|
8
9
|
isEventEditProductSet?: boolean;
|
|
10
|
+
workHours?: WorkHour[];
|
|
11
|
+
providerHasBookingManagement: boolean;
|
|
12
|
+
isLoading?: boolean;
|
|
9
13
|
}
|
|
10
|
-
export declare const DateAndRecurrenceInput: ({ isEventEditProductSet, }: DateAndRecurrenceInputProps) => JSX.Element;
|
|
14
|
+
export declare const DateAndRecurrenceInput: ({ isEventEditProductSet, providerHasBookingManagement, workHours, isLoading, }: DateAndRecurrenceInputProps) => JSX.Element;
|
|
11
15
|
export declare const sameWidthPopperModifier: Modifier<"sameWidth", Record<string, unknown>>;
|
|
12
16
|
export {};
|
|
13
17
|
//# sourceMappingURL=DateAndRecurrenceInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateAndRecurrenceInput.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/DateAndRecurrenceInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateAndRecurrenceInput.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/DateAndRecurrenceInput.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAO1C,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAuB7G,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;CACnD;AAED,UAAU,2BAA2B;IACnC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,4BAA4B,EAAE,OAAO,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,sBAAsB,mFAKhC,2BAA2B,gBAiQ7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,WAAW,EACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),a=require("react-bootstrap"),u=require("../../static/Icon.js"),o=require("react-hook-form"),s=require("@react-aria/utils"),l=require("react-use"),c=require("luxon");require("../../static/index.js");var d=require("@dnd-kit/core"),m=require("@dnd-kit/modifiers"),f=require("@dnd-kit/sortable"),v=require("../../modals/confirmation/ConfirmModal.js"),p=require("@licklist/core/dist/Config/Date"),g=require("../../recurring-date-picker-input/RecurringDatePickerInput.js"),T=require("./ProductSetRecurrenceControl.js"),b=require("../../zone/form/components/AvailableTimesControl.js"),_={name:"sameWidth",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(e){var r=e.state,t={width:"".concat(r.rects.reference.width+4,"px"),marginLeft:"-2px",maxWidth:"unset"};Object.assign(r.styles.popper,t)},effect:function(e){var r=e.state,t=r.elements.reference.getBoundingClientRect().width,n={width:"".concat(t,"px"),maxWidth:"unset"};Object.assign(r.elements.popper.style,n)}};exports.DateAndRecurrenceInput=function(e){var x,E,h=e.isEventEditProductSet,q=e.providerHasBookingManagement,D=e.workHours,R=e.isLoading,S=o.useFormContext(),C=S.control,y=S.register,k=S.formState.errors,I=S.getValues,w=S.setValue,A=S.clearErrors,M=r.__read(t.useState([]),2),O=M[0],F=M[1],N=t.useRef(),j=o.useFieldArray({name:"menuRecurrences",control:C,keyName:"_id"}),P=j.fields,V=j.append,L=j.update,W=j.move,B=r.__read(t.useState(!1),2),H=B[0],z=B[1],G=r.__read(t.useState({index:null,values:null}),2),K=G[0],J=G[1],Q=function(){return J({index:null,values:null})},U=t.useRef();l.useClickAway(U,(function(e){var r,t,n;v.CONFIRM_MODAL_ACTIONS.includes(null===(n=null===(t=null===(r=e.target)||void 0===r?void 0:r.attributes)||void 0===t?void 0:t.getNamedItem("data-id"))||void 0===n?void 0:n.value)||(z(!1),Q())}));var X=s.useId(),Y=i.useTranslation("Design").t,Z=function(){Q(),z((function(e){return!e}))};return t.useEffect((function(){P.length&&A("menuRecurrences")}),[P,A]),n.createElement(a.Form.Group,null,n.createElement(a.Form.Label,null,Y(h?"whenOverridesAvailable":"productSetAvailable")),n.createElement(a.OverlayTrigger,{show:H,overlay:n.createElement(a.Popover,{id:X,className:"rounded"},n.createElement(a.Popover.Content,{className:"shadow-lg rounded",ref:U},n.createElement(g.RecurringDatePickerInput,{defaultValues:K.values,onChange:function(e){return r.__awaiter(void 0,void 0,void 0,(function(){var t,n,i,a,u,o,s;return r.__generator(this,(function(l){switch(l.label){case 0:return[4,null===(u=N.current)||void 0===u?void 0:u.trigger()];case 1:return l.sent()?!(null==e?void 0:e.startTime)||!(null==e?void 0:e.endTime)||(t=c.DateTime.fromISO(e.startTime),n=c.DateTime.fromISO(e.endTime),i=N.current.getValues().availableTimes,i.every((function(e){var r=c.DateTime.fromFormat(e,p.TIME_FORMAT);return r.diff(t,"minutes").minutes>=0&&r.diff(n,"minutes").minutes<=0})))?(a=r.__assign({rrule:e.rrule,startDate:e.startDate,endDate:e.endDate,startTime:e.startTime,endTime:e.endTime},N.current.getValues()),(null===(o=K.values)||void 0===o?void 0:o.id)&&(a.id=null===(s=K.values)||void 0===s?void 0:s.id),null!==K.index?L(K.index,a):V(a),z((function(){return!1})),Q(),[2]):(N.current.setError("availableTimes",{message:Y("Validation:fieldTimeBetween",{attribute:Y("Design:startTimesSmall"),min:t.toFormat(p.TIME_FORMAT),max:n.toFormat(p.TIME_FORMAT)})}),[2]):[2]}}))}))},onDelete:function(){var e=K.index;z(!1),Q(),setTimeout((function(){var r=I().menuRecurrences;w("menuRecurrences",(void 0===r?[]:r).filter((function(r,t){return t!==e})))}),100)}},q&&n.createElement(b.AvailableTimesControl,{workHours:D,isLoading:R,defaultValues:O,ref:N})))),trigger:"click",placement:"bottom",popperConfig:{modifiers:[_]}},n.createElement("div",{className:"product-set-recurrences"},n.createElement(d.DndContext,{onDragEnd:function(e){var r=e.over,t=e.active;if(r.id!==t.id){var n=P.findIndex((function(e){return String(e._id)===t.id})),i=P.findIndex((function(e){return String(e._id)===r.id}));W(n,i)}},modifiers:[m.restrictToVerticalAxis]},n.createElement(f.SortableContext,{items:null!==(x=null==P?void 0:P.map((function(e){return String(e._id)})))&&void 0!==x?x:[],strategy:f.verticalListSortingStrategy},P.map((function(e,r){return n.createElement(T.ProductSetRecurrenceControl,{key:e._id,menuRecurrence:e,onEdit:function(){return function(e,r){Q(),setTimeout((function(){J({index:r,values:e}),F(e.availableTimes||[]),z((function(){return!0}))}),100)}(e,r)}})})))),(!h||(null==P?void 0:P.length)<1)&&n.createElement("div",{className:"product-set-recurrence-icon-wrapper",role:"button",tabIndex:0,onClick:Z,onKeyDown:Z},n.createElement(u.default,{type:"plus-circle",height:"1rem",className:"product-set-recurrence-icon-add mr-2"}),Y("addDates")),n.createElement(a.Form.Control,r.__assign({type:"hidden"},y("menuRecurrences",{required:{value:!0,message:Y("Validation:fieldMinNumber",{attribute:Y("dates"),min:1})}}))),n.createElement("div",{className:"manual-form-error"},null===(E=k.menuRecurrences)||void 0===E?void 0:E.message))))},exports.sameWidthPopperModifier=_;
|
|
@@ -3,6 +3,7 @@ import { OperationalCostType, ProductSetType, RelyOnPeopleType } from "@licklist
|
|
|
3
3
|
import { FieldSet } from "@licklist/core/dist/DataMapper/Order/FieldSetDataMapper";
|
|
4
4
|
import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/EmailTemplateDataMapper";
|
|
5
5
|
import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemplateDataMapper";
|
|
6
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
6
7
|
import { SelectItem } from "../../types/generic/SelectItem";
|
|
7
8
|
import { DateAndRecurrenceInputValues } from "./DateAndRecurrenceInput";
|
|
8
9
|
import { Step } from "../types";
|
|
@@ -41,6 +42,8 @@ export interface ProductSetControlProps {
|
|
|
41
42
|
fieldSets?: FieldSet[];
|
|
42
43
|
showEmailTemplate?: boolean;
|
|
43
44
|
showSmsTemplate?: boolean;
|
|
45
|
+
workHours?: WorkHour[];
|
|
46
|
+
providerHasBookingManagement?: boolean;
|
|
44
47
|
}
|
|
45
|
-
export declare function ProductSetControl({ companyName, isLoading, fee, fieldSets, emailTemplates, smsTemplates, isEventEditProductSet, isCreateAction, showEmailTemplate, showSmsTemplate, }: ProductSetControlProps): JSX.Element;
|
|
48
|
+
export declare function ProductSetControl({ companyName, isLoading, fee, fieldSets, emailTemplates, smsTemplates, isEventEditProductSet, isCreateAction, showEmailTemplate, showSmsTemplate, workHours, providerHasBookingManagement, }: ProductSetControlProps): JSX.Element;
|
|
46
49
|
//# sourceMappingURL=ProductSetControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductSetControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/ProductSetControl.tsx"],"names":[],"mappings":";AAKA,OAAO,EAOL,mBAAmB,EACnB,cAAc,EAEd,gBAAgB,EACjB,MAAM,6DAA6D,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,mEAAmE,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductSetControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/ProductSetControl.tsx"],"names":[],"mappings":";AAKA,OAAO,EAOL,mBAAmB,EACnB,cAAc,EAEd,gBAAgB,EACjB,MAAM,6DAA6D,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,yDAAyD,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,mEAAmE,CAAC;AAGhG,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAEtF,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAIL,4BAA4B,EAC7B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAehC,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,aAAa,GAAG,WAAW,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAwB,SAAQ,4BAA4B;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,mBAAmB,CAAC;IACrC,aAAa,CAAC,EAAE,UAAU,EAAE,CAAC;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC;AAED,wBAAgB,iBAAiB,CAAC,EAChC,WAAW,EACX,SAAS,EACT,GAAU,EACV,SAAc,EACd,cAAmB,EACnB,YAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,4BAAoC,GACrC,EAAE,sBAAsB,eAuQxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=e(require("react")),r=require("react-i18next"),n=require("react-bootstrap"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),i=require("@react-aria/utils"),s=e(require("clsx")),m=require("../../static/WarningMessage.js");require("../../static/index.js");var c,u,d=require("@licklist/core/dist/DataMapper/Product/ProductSetDataMapper"),E=require("@licklist/plugins/dist/validation/Rules/urlRule"),p=(e(E),require("./DateAndRecurrenceInput.js")),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=e(require("react")),r=require("react-i18next"),n=require("react-bootstrap"),o=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/HookFormService")),i=require("@react-aria/utils"),s=e(require("clsx")),m=require("../../static/WarningMessage.js");require("../../static/index.js");var c,u,d=require("@licklist/core/dist/DataMapper/Product/ProductSetDataMapper"),E=require("@licklist/plugins/dist/validation/Rules/urlRule"),p=(e(E),require("./DateAndRecurrenceInput.js")),g=require("./TutorialGifCard.js"),P=require("../form/StepsControl.js"),T=require("../../typeahead/Typeahead.js"),_=((c={})[d.OPERATIONAL_COST_PROVIDER]="operationalCostProvider",c[d.OPERATIONAL_COST_CUSTOMER]="operationalCostCustomer",c),v=((u={})[d.RELY_ON_PEOPLE_PRODUCT_CAPACITY_QUANTITY]="peopleProductCapacityQuantity",u[d.RELY_ON_PEOPLE_PRODUCT_QUANTITY]="peopleProductQuantity",u[d.RELY_ON_PEOPLE_QUANTITY]="peopleQuantity",u);exports.ProductSetControl=function(e){var c,u=e.companyName,O=e.isLoading,C=e.fee,f=void 0===C?"5%":C,L=e.fieldSets,F=void 0===L?[]:L,N=e.emailTemplates,h=void 0===N?[]:N,R=e.smsTemplates,A=void 0===R?[]:R,S=e.isEventEditProductSet,y=e.isCreateAction,D=e.showEmailTemplate,I=e.showSmsTemplate,b=e.workHours,Y=e.providerHasBookingManagement,k=void 0!==Y&&Y,q=r.useTranslation(["Design","Validation","Notification"]).t,U=o.useFormContext(),M=U.register,j=U.control,x=U.formState.errors,V=U.watch,G=U.setError,w=U.clearErrors,Q=V("steps"),H=i.useId(),B=i.useId(),W=i.useId();return a.createElement(n.Row,{className:"product-set-form ".concat(S&&"event-edit-product-set")},a.createElement(n.Col,{md:6,sm:12,className:"pr-5"},a.createElement(n.Form.Group,{controlId:H},a.createElement(n.Form.Label,null,q("Design:name"),"*"),a.createElement(n.Form.Control,t.__assign({},M("name",{required:q("Validation:fieldRequired",{attribute:q("name")}),maxLength:255,validate:function(){var e;return Q.length?(null===(e=x.steps)||void 0===e?void 0:e.type)===l.manualErrorType&&w("steps"):G("steps",{type:l.manualErrorType,message:q("Validation:fieldMinNumber",{attribute:q("steps"),min:1})}),!0}}),{placeholder:q("Design:placeholderProductSetName"),isInvalid:Boolean(x.name)})),a.createElement(n.Form.Control.Feedback,{type:"invalid"},null===(c=x.name)||void 0===c?void 0:c.message)),y&&a.createElement(p.DateAndRecurrenceInput,{isEventEditProductSet:S,workHours:b,isLoading:O,providerHasBookingManagement:k}),a.createElement("div",{className:"divider"}),a.createElement(g.default,null),a.createElement(P.StepsControl,{isLoading:O})),a.createElement(n.Col,{md:6,sm:12},a.createElement("div",{className:"second-column"},a.createElement(n.Form.Group,null,a.createElement(n.Form.Label,{className:"mb-0"},q("Design:operationalCost")),a.createElement("div",{className:"d-flex"},a.createElement("span",{className:"booking-fee-text"},q("bookingFeePaid",{fee:f}))),a.createElement(n.Form.Control,t.__assign({},M("operationalCost",{required:!0}),{as:"select",defaultValue:d.OPERATIONAL_COST_PROVIDER}),Object.keys(d.OPERATIONAL_COST_TYPES).map((function(e){return a.createElement("option",{value:d.OPERATIONAL_COST_TYPES[e],key:d.OPERATIONAL_COST_TYPES[e]},q(_[d.OPERATIONAL_COST_TYPES[e]],{companyName:u}))})))),a.createElement(n.Form.Group,{controlId:W},a.createElement(n.Form.Label,null,q("peopleQuantityType")),a.createElement(n.Form.Control,t.__assign({},M("relyOnPeopleType"),{as:"select",defaultValue:null}),a.createElement("option",{value:""},q("notRequired")),Object.keys(d.RELY_ON_PEOPLE_TYPES).map((function(e){return a.createElement("option",{value:d.RELY_ON_PEOPLE_TYPES[e],key:d.RELY_ON_PEOPLE_TYPES[e]},q(v[d.RELY_ON_PEOPLE_TYPES[e]]))})))),a.createElement(n.Form.Group,{controlId:B},a.createElement(n.Form.Label,null,q("Design:termsAndConditions")),a.createElement(n.Form.Control,t.__assign({},M("termsAndConditions"),{as:"textarea",rows:2,disabled:O}))),a.createElement(n.Form.Group,null,a.createElement(n.Form.Label,{className:"mt-4"},q("Design:emailTemplate")),D?a.createElement(T.Typeahead,{name:"emailTemplates",options:h,isMultipleChoise:!0,placeholder:q("Design:choose"),noOptionsMessage:q("Design:noActiveTemplates",{notification:q("Design:email")})}):a.createElement(m.default,{message:q("Design:noActiveTemplates",{notification:q("Design:email")})}),a.createElement(n.Form.Label,{className:s(h.length>0?"mt-4":"mt-1")},q("Design:smsTemplate")),I?a.createElement(T.Typeahead,{name:"smsTemplates",options:A,isMultipleChoise:!0,placeholder:q("Design:choose"),noOptionsMessage:q("Design:noActiveTemplates",{notification:q("Design:sms")})}):a.createElement(m.default,{message:q("Design:noActiveTemplates",{notification:q("Design:sms")})})),a.createElement(n.Form.Group,null,a.createElement(o.Controller,{control:j,name:"fieldSetId",render:function(e){var t=e.field,r=Number(t.value);return a.createElement(a.Fragment,null,a.createElement(n.Form.Label,null,q("Design:customFields")),a.createElement(n.Form.Control,{onChange:t.onChange,value:r,as:"select"},a.createElement("option",{value:""},q("Design:choose")),null==F?void 0:F.map((function(e){return a.createElement("option",{value:e.id,key:e.id},e.name)}))))}})),a.createElement(n.Form.Group,{controlId:"thankYouPageUrlId"},a.createElement(n.Form.Label,null,q("thankYouPageUrl")),a.createElement(n.Form.Control,t.__assign({},M("thankYouPageUrl",{validate:function(e){return!e||(!!E.ruleForUrlWithProtocol.test(e)||q("Validation:fieldValidWebURL",{attribute:q("thankYouPageUrl")}))}}),{isInvalid:l.isInvalid("thankYouPageUrl",x)})),a.createElement(n.Form.Control.Feedback,{type:"invalid"},l.getErrors("thankYouPageUrl",x))))))};
|
|
@@ -4,6 +4,7 @@ import { VenueMapSet } from "@licklist/core/dist/DataMapper/Product/VenueMapSetD
|
|
|
4
4
|
import { ServerError } from "@licklist/plugins/dist/hooks/Api/useHttpQuery";
|
|
5
5
|
import { ProviderBookingManagementSetting } from "@licklist/core/dist/DataMapper/Provider/ProviderBookingManagementSettingDataMapper";
|
|
6
6
|
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
7
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
7
8
|
import { ProductSetControlShared, ProductSetControlValues } from "../control";
|
|
8
9
|
import { Step } from "../types";
|
|
9
10
|
import { SelectItem } from "../../types/generic/SelectItem";
|
|
@@ -28,6 +29,7 @@ export interface ProductSetFormProps extends WithIsLoading, ProductSetControlSha
|
|
|
28
29
|
providerHasBookingManagement?: ProviderBookingManagementSetting["hasBookingManagement"];
|
|
29
30
|
zones?: Zone[] | null;
|
|
30
31
|
isCreateAction?: boolean;
|
|
32
|
+
workHours?: WorkHour[];
|
|
31
33
|
}
|
|
32
|
-
export declare function ProductSetForm({ companyName, isLoading, defaultValues, onSubmitAndRedirect, onSubmitNoRedirect, productGroupList, serverErrors, providerHasMap, venueMapSets, providerHasBookingManagement, zones, isCreateAction, ...shared }: ProductSetFormProps): JSX.Element;
|
|
34
|
+
export declare function ProductSetForm({ companyName, isLoading, defaultValues, onSubmitAndRedirect, onSubmitNoRedirect, productGroupList, serverErrors, providerHasMap, venueMapSets, providerHasBookingManagement, zones, isCreateAction, workHours, ...shared }: ProductSetFormProps): JSX.Element;
|
|
33
35
|
//# sourceMappingURL=ProductSetForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductSetForm.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductSetForm.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAI1F,OAAO,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAK5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oFAAoF,CAAC;AACtI,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductSetForm.d.ts","sourceRoot":"","sources":["../../../src/product-set/form/ProductSetForm.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAI1F,OAAO,EAAE,WAAW,EAAE,MAAM,8DAA8D,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAK5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,oFAAoF,CAAC;AACtI,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAEtF,OAAO,EAEL,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAI5D,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,OAAO,CAAC;CACpB;AACD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;CACZ;AACD,MAAM,WAAW,oBACf,SAAQ,UAAU,EAChB,MAAM,EACN,uBAAuB;IACzB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,mBACf,SAAQ,aAAa,EACnB,uBAAuB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,mBAAmB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5D,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5D,gBAAgB,CAAC,EAAE,UAAU,EAAE,CAAC;IAChC,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC;IAC7B,4BAA4B,CAAC,EAAE,gCAAgC,CAAC,sBAAsB,CAAC,CAAC;IACxF,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,SAAS,EACT,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,cAAsB,EACtB,YAAiB,EACjB,4BAA4B,EAC5B,KAAK,EACL,cAAc,EACd,SAAS,EACT,GAAG,MAAM,EACV,EAAE,mBAAmB,eA2HrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),o=require("react"),r=e(o),n=require("react-i18next"),a=require("react-bootstrap"),i=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/FormErrorService")),l=require("lodash"),d=require("../../modals/dialog/Dialog.js"),u=require("../../modals/dialog/DialogContext.js"),m=require("./context.js"),c=require("../utils/index.js"),p=require("../control/ProductSetControl.js");exports.ProductSetForm=function(e){var v=e.companyName,g=e.isLoading,E=e.defaultValues,f=e.onSubmitAndRedirect,
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),o=require("react"),r=e(o),n=require("react-i18next"),a=require("react-bootstrap"),i=require("react-hook-form"),s=e(require("@licklist/plugins/dist/services/Form/FormErrorService")),l=require("lodash"),d=require("../../modals/dialog/Dialog.js"),u=require("../../modals/dialog/DialogContext.js"),m=require("./context.js"),c=require("../utils/index.js"),p=require("../control/ProductSetControl.js");exports.ProductSetForm=function(e){var v=e.companyName,g=e.isLoading,E=e.defaultValues,f=e.onSubmitAndRedirect,w=e.onSubmitNoRedirect,S=e.productGroupList,b=e.serverErrors,C=e.providerHasMap,h=void 0!==C&&C,q=e.venueMapSets,T=void 0===q?[]:q,k=e.providerHasBookingManagement,D=e.zones,L=e.isCreateAction,M=e.workHours,x=t.__rest(e,["companyName","isLoading","defaultValues","onSubmitAndRedirect","onSubmitNoRedirect","productGroupList","serverErrors","providerHasMap","venueMapSets","providerHasBookingManagement","zones","isCreateAction","workHours"]),H=n.useTranslation("Design").t,P=u.useDialogContext(),A=P.isShownDialog,F=P.onBeforeUnload,N=P.onPopState,B=P.onApproveDialog,_=P.onDeclineDialog,j=i.useForm({defaultValues:E,mode:"onChange"}),y=j.setError,R=j.reset,z=j.watch();return o.useEffect((function(){E&&!l.isEqual(E,z)&&R(E)}),[E]),o.useEffect((function(){b&&s.handleServerErrors(b,y)}),[b,y]),o.useEffect((function(){return window.history.pushState(null,"",window.location.pathname),window.addEventListener("beforeunload",F),window.addEventListener("popstate",N),function(){window.removeEventListener("beforeunload",F),window.removeEventListener("popstate",N)}}),[]),r.createElement(m.ProductSetContextProvider,{productGroupList:S,providerHasMap:h,venueMapSets:T,providerHasBookingManagement:k,zones:D},r.createElement(d.Dialog,{isActive:A,title:H("Design:leavePage"),content:H("Design:changesNotBeSaved"),onApprove:B,onDecline:_}),r.createElement(i.FormProvider,t.__assign({},j),r.createElement(a.Form,{onSubmit:j.handleSubmit(f)},r.createElement(m.ProductSetLoadingContext.Consumer,null,(function(e){var o=e.isLoading;return r.createElement(r.Fragment,null,r.createElement(p.ProductSetControl,t.__assign({},x,{smsTemplates:c.getFilteredTemplates(null==x?void 0:x.smsTemplates,null==z?void 0:z.smsTemplates),emailTemplates:c.getFilteredTemplates(null==x?void 0:x.emailTemplates,null==z?void 0:z.emailTemplates),showEmailTemplate:!!(null==x?void 0:x.emailTemplates),showSmsTemplate:!!(null==x?void 0:x.smsTemplates),isLoading:g,isCreateAction:L,companyName:v,workHours:M,providerHasBookingManagement:k})),r.createElement(a.Row,null,r.createElement(a.Col,{md:6,sm:12}),r.createElement(a.Col,{className:"product-set-save-btn-wrapper p-0 pl-4 d-flex mw-100",md:6,sm:12},w&&r.createElement(a.Button,{className:"product-set-save-btn mt-5 ml-5 d-no dne d-md-block",onClick:j.handleSubmit(w),disabled:g||o||!z.name},H("save")),r.createElement(a.Button,{className:"product-set-save-btn mt-5 ml-5 d-no dne d-md-block",type:"submit",disabled:g||o||!z.name},H("saveAndClose")))))})))))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),n=require("react"),r=e(n),a=require("react-i18next"),i=e(require("react-bootstrap/Button")),l=require("react-bootstrap"),u=require("react-hook-form"),o=require("luxon"),d=require("../modals/confirmation/ConfirmModal.js");require("../modals/dialog/Dialog.js"),require("../modals/dialog/DialogContext.js");var s=require("../product-set/elements/DeleteFieldButton.js"),c=require("rrule"),m=e(c),f=require("
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),n=require("react"),r=e(n),a=require("react-i18next"),i=e(require("react-bootstrap/Button")),l=require("react-bootstrap"),u=require("react-hook-form"),o=require("luxon"),d=require("../modals/confirmation/ConfirmModal.js");require("../modals/dialog/Dialog.js"),require("../modals/dialog/DialogContext.js");var s=require("../product-set/elements/DeleteFieldButton.js"),c=require("rrule"),m=e(c),f=require("@licklist/core/dist/Config/Date"),v=require("react-intl"),D=require("@licklist/plugins/dist/hooks/Value/usePreviousValue"),y=require("./RecurrenceIntervalAndFrequencyInput.js"),T=require("./utils.js"),p=require("./RecurrenceWeekdaysInput.js");var q=function(e){var n=e.rrule,r=e.startDate,a=e.endDate,i=e.startTime,l=e.endTime,u=e.initialFrequency,o=void 0===u?c.Frequency.DAILY:u;return t.__assign({startDate:r,endDate:a,startTime:i,endTime:l,interval:1,freq:o},n&&T.parseAndValidateRRule({rrule:n,date:r}))},g=function(e){var r=e.startDate,a=e.endDate,i=e.startTime,l=e.endTime,u=e.byWeekDay,d=void 0===u?[]:u,s=k(r,i||"00:00:00"),c=k(a,l||"23:59:59"),m=v.useIntl(),f=m.formatList,D=m.formatNumber;return n.useMemo((function(){if(s instanceof o.DateTime&&c instanceof o.DateTime&&s.isValid&&c.isValid){var e=o.Interval.fromDateTimes(s.set({second:0}),c.set({second:0})).toDuration(["days","hours","minutes"]);if(e.isValid){var n=function(e,t){return D(e,{style:"unit",unit:t,unitDisplay:"long"})},r=o.Interval.fromDateTimes(s.minus({second:1}),c.plus({second:1})).splitBy({days:1});if(!(d.length?r.reduce((function(e,t){return d.some((function(e){return e.weekday+1===t.start.weekday}))?e+1:e}),0):1))return n(0,"minute");var a=[[e.days,"day"],[e.hours,"hour"],[e.minutes,"minute"]].filter((function(e){return t.__read(e,1)[0]}));return a.length||a.push([0,"minute"]),f(a.map((function(e){return n.apply(void 0,t.__spreadArray([],t.__read(e),!1))})),{style:"long",type:"unit"})}}}),[s,c,d,f,D])},k=function(e,t){var n=o.DateTime.fromFormat("".concat(e," ").concat(t),f.DATE_TIME_FORMAT);if(n.isValid)return n;var r=o.DateTime.fromFormat("".concat(e," ").concat(t),f.DATE_TIME_FULL_FORMAT);return r.isValid?r:""};exports.RecurringDatePickerInput=function(e){var v,T,_,b,F,E,w=e.disabled,h=void 0!==w&&w,I=e.onChange,A=e.onDelete,V=e.defaultValues,x=e.initialFrequency,L=void 0===x?c.Frequency.DAILY:x,j=e.setInitialStartDateAfterSelect,M=void 0!==j&&j,R=e.children,S=e.minDate,N=a.useTranslation(["Design"]).t,C=u.useForm({defaultValues:q({rrule:null!==(v=null==V?void 0:V.rrule)&&void 0!==v?v:"",startDate:null!==(T=null==V?void 0:V.startDate)&&void 0!==T?T:"",endDate:null!==(_=null==V?void 0:V.endDate)&&void 0!==_?_:"",startTime:null!==(b=null==V?void 0:V.startTime)&&void 0!==b?b:"",endTime:null!==(F=null==V?void 0:V.endTime)&&void 0!==F?F:"",initialFrequency:null!==(E=null==V?void 0:V.freq)&&void 0!==E?E:L}),mode:"onChange"}),P=C.watch,W=C.setValue,O=C.handleSubmit,B=P("startDate"),Y=P("endDate"),U=P("startTime"),Q=P("endTime"),J=P("byweekday"),K=D.usePreviousValue(B),z=g({startDate:B,endDate:Y,startTime:U,endTime:Q,byWeekDay:J}),G=function(e){var n,r=k(Y,Q||"23:59:59"),a=Array.isArray(e.byweekday)?e.byweekday.map((function(e){return e instanceof c.Weekday?e:new c.Weekday(null==e?void 0:e.weekday)})):e.byweekday,i=(null==e?void 0:e.endTime)?o.DateTime.fromISO(null==e?void 0:e.endTime).toFormat(f.TIME_FULL_FORMAT):"",l=null!==(n=null==e?void 0:e.endDate)&&void 0!==n?n:"",u=m.optionsToString({until:r instanceof o.DateTime&&r.isValid?null==r?void 0:r.toJSDate():null,byweekday:a,count:e.count,freq:(null==a?void 0:a.length)?c.Frequency.WEEKLY:c.Frequency.DAILY,interval:e.interval}).replace("RRULE:","");I(t.__assign(t.__assign({},e),{endDate:l,endTime:i,rrule:u}))};return n.useEffect((function(){var e,t;if(M&&(!K||B)&&!B&&J&&J.length&&!Number.isNaN(null===(e=J[0])||void 0===e?void 0:e.weekday)){var n=(null===(t=J[0])||void 0===t?void 0:t.weekday)+1,r=o.DateTime.local(),a=o.DateTime.local().set({weekday:n});a>=r||n===r.weekday?W("startDate",a.toSQLDate()):W("startDate",a.plus({week:1}).toSQLDate())}}),[J,M]),r.createElement(u.FormProvider,t.__assign({},C),r.createElement(l.Form,{noValidate:!0,onSubmit:function(e){return e.preventDefault(),e.stopPropagation(),O(G)(e)}},r.createElement(p.default,{date:B,disabled:h}),r.createElement(y.default,{disabled:h,minDate:S}),R,r.createElement("div",{className:"d-inline-flex align-items-center w-100"},r.createElement(i,{type:"submit"},N("Design:apply")),r.createElement("div",{className:"d-flex flex-grow-1 text-muted mx-3 flex-column"},r.createElement("div",null,z&&"lasts ".concat(z))),V&&r.createElement("div",{className:"d-flex justify-content-end delete-btn"},r.createElement(d.ConfirmModal,null,(function(e){return r.createElement(s.DeleteFieldButton,{onDelete:function(){return e(A)}})}))))))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),a=require("react-i18next"),o=require("react-bootstrap"),i=require("react-hook-form"),l=e(require("clsx")),u=require("luxon"),s=require("../../static/CurrencyNumberInput.js"),m=require("lodash"),c=require("@licklist/core/dist/DataMapper/Order/OrderPaymentDataMapper"),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),r=require("react"),n=e(r),a=require("react-i18next"),o=require("react-bootstrap"),i=require("react-hook-form"),l=e(require("clsx")),u=require("luxon"),s=require("../../static/CurrencyNumberInput.js"),m=require("lodash"),c=require("@licklist/core/dist/Services/Date"),d=require("@licklist/core/dist/DataMapper/Order/OrderPaymentDataMapper"),E=require("../constants.js"),_=require("@licklist/plugins/dist/context/sale/SalePaymentFormContext"),p=require("./components/RyftPayment/RyftPayment.js"),T=r.forwardRef((function(e,T){var y,f,D=e.calculatedAmount,P=void 0===D?0:D,v=e.showAmountField,N=void 0!==v&&v,g=e.orderPaymentTypeError,A=t.__rest(e,["calculatedAmount","showAmountField","orderPaymentTypeError"]),R=a.useTranslation(["Design","Validation","Sale"]).t,Y=r.useContext(_.SalePaymentFormContext),F=Y.formValues,x=Y.setFormValues,q=t.__read(r.useState(F),1)[0],M=r.useRef(null),k=i.useForm({defaultValues:q,mode:"onChange"}),C=k.trigger,S=k.watch,b=k.reset,I=k.register,h=k.formState.errors,L=S(),O=r.useCallback((function(){return t.__awaiter(void 0,void 0,void 0,(function(){return t.__generator(this,(function(e){return[2,C(function(){var e=[];return N&&e.push("amount"),L.orderPaymentType===d.ORDER_PAYMENT_TYPE_PAYMENT_LINK&&e.push("paymentLinkExpireDate"),e}(),{shouldFocus:!0})]}))}))}),[C,L,N]);return r.useImperativeHandle(T,(function(){return{onTriggerForm:O}})),r.useEffect((function(){void 0!==P&&L.amount!==P&&b(t.__assign(t.__assign({},L),{amount:P}))}),[P]),r.useEffect((function(){m.isEqual(L,F)||x(L)}),[L]),n.createElement(n.Fragment,null,n.createElement(o.Row,null,n.createElement(o.Col,{xs:12,md:6},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,R("paymentType")),n.createElement(o.Form.Control,t.__assign({className:"payment-type",as:"select"},I("orderPaymentType"),{isInvalid:!!(null==h?void 0:h.orderPaymentType)}),Object.keys(E.EXTENDED_PAYMENT_TYPE_TRANSLATION_KEYS).map((function(e){return[d.ORDER_PAYMENT_TYPE_CARD,d.ORDER_PAYMENT_TYPE_PAYMENT_LINK].includes(e)?n.createElement("option",{key:e,value:e},R("Design:".concat(E.EXTENDED_PAYMENT_TYPE_TRANSLATION_KEYS[e]))):n.createElement("option",{key:e,value:e},R("Design:paid",{argument:R("Design:".concat(E.EXTENDED_PAYMENT_TYPE_TRANSLATION_KEYS[e]))}))}))),g&&n.createElement("div",{className:"error-message"},g))),N&&n.createElement(o.Col,{xs:12,md:4},n.createElement(o.Form.Group,null,n.createElement(s.CurrencyNumberInput,t.__assign({label:R("Design:amount")},I("amount",{required:R("Validation:fieldRequired",{attribute:R("Design:amount")})}),{isInvalid:!!h.amount,error:null===(y=null==h?void 0:h.amount)||void 0===y?void 0:y.message}))))),n.createElement("div",{className:l(L.orderPaymentType!==d.ORDER_PAYMENT_TYPE_CARD&&"d-none")},n.createElement(p.RyftPayment,t.__assign({},A))),L.orderPaymentType===d.ORDER_PAYMENT_TYPE_PAYMENT_LINK&&n.createElement(o.Row,null,n.createElement(o.Col,{sm:12,md:4},n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,R("Design:expirationDate")),n.createElement(o.Form.Control,t.__assign({type:"datetime-local",placeholder:R("Design:date"),value:L.paymentLinkExpireDate},I("paymentLinkExpireDate",{validate:function(e){return!e||(!(u.DateTime.now()>u.DateTime.fromISO(e))||R("Validation:fieldMinNumber",{attribute:R("Design:expirationDate"),min:c.transformToIsoWithoutMilisecondsAndSeconds(u.DateTime.now()).split("T").join(" ")}))}}),{ref:M,onClick:function(){var e;return null===(e=null==M?void 0:M.current)||void 0===e?void 0:e.showPicker()},isInvalid:!!h.paymentLinkExpireDate,min:c.transformToIsoWithoutMilisecondsAndSeconds(u.DateTime.now().minus({minutes:1}))})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(f=null==h?void 0:h.paymentLinkExpireDate)||void 0===f?void 0:f.message)))))}));exports.SalePaymentForm=T;
|
|
@@ -12,5 +12,5 @@ export type ZoneFormProps = {
|
|
|
12
12
|
export type ZoneFormValues = Partial<Zone> & {
|
|
13
13
|
localImageBlobURL?: string;
|
|
14
14
|
};
|
|
15
|
-
export declare const ZoneForm: ({ defaultValues, onSubmit, serverErrors, isLoading,
|
|
15
|
+
export declare const ZoneForm: ({ defaultValues, onSubmit, serverErrors, isLoading, }: ZoneFormProps) => JSX.Element;
|
|
16
16
|
//# sourceMappingURL=ZoneForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoneForm.d.ts","sourceRoot":"","sources":["../../../src/zone/form/ZoneForm.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAGtF,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"ZoneForm.d.ts","sourceRoot":"","sources":["../../../src/zone/form/ZoneForm.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAGtF,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAC1C,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,QAAQ,0DAKlB,aAAa,gBAiDf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),o=e(t),n=require("react-i18next"),s=require("react-bootstrap"),a=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/FormErrorService")),
|
|
1
|
+
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),o=e(t),n=require("react-i18next"),s=require("react-bootstrap"),a=require("react-hook-form"),l=e(require("@licklist/plugins/dist/services/Form/FormErrorService")),i=require("./components/ZoneControl.js");exports.ZoneForm=function(e){var u=e.defaultValues,c=e.onSubmit,m=e.serverErrors,d=e.isLoading,f=void 0!==d&&d,b=n.useTranslation("Design").t,p=a.useForm({mode:"onChange",defaultValues:{zoneRecurrences:[]}}),v=p.reset,E=p.setError,g=p.handleSubmit,q=(0,p.watch)();return t.useEffect((function(){u&&v(u)}),[u,v]),t.useEffect((function(){m&&l.handleServerErrors(m,E)}),[m,E]),o.createElement(a.FormProvider,r.__assign({},p),o.createElement(s.Form,{onSubmit:g((function(e){e.localImageBlobURL;var t=r.__rest(e,["localImageBlobURL"]);c(t)}))},o.createElement(i.ZoneControl,{isLoading:f}),o.createElement(s.Row,null,o.createElement(s.Col,{md:6,sm:12}),o.createElement(s.Col,{className:"product-set-save-btn-wrapper p-0 pl-4 d-flex mw-100",md:6,sm:12},o.createElement(s.Button,{className:"product-set-save-btn mt-5 ml-5 d-no dne d-md-block",type:"submit",disabled:f||!q.name},b("saveAndClose"))))))};
|
|
@@ -4,5 +4,5 @@ export type ZoneControlProps = {
|
|
|
4
4
|
isLoading: boolean;
|
|
5
5
|
workHours?: WorkHour[];
|
|
6
6
|
};
|
|
7
|
-
export declare const ZoneControl: ({ isLoading,
|
|
7
|
+
export declare const ZoneControl: ({ isLoading, }: ZoneControlProps) => JSX.Element;
|
|
8
8
|
//# sourceMappingURL=ZoneControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoneControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAStF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"ZoneControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneControl.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAStF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,WAAW,mBAErB,gBAAgB,gBA0BlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("react"),t=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,o=require("react-bootstrap"),n=require("./NameControl.js"),l=require("./ZoneTypeControl.js"),a=require("./SortControl.js"),i=require("./ZoneRecurrencesControl.js"),m=require("./DescriptionControl.js"),s=require("./ZoneImageControl.js"),c=require("./GameDurationControl.js");exports.ZoneControl=function(e){var r=e.isLoading;return t.createElement(o.Row,null,t.createElement(o.Col,{md:6,sm:12,className:"pr-5"},t.createElement(n.NameControl,{isLoading:r}),t.createElement(i.ZoneRecurrencesControl,null),t.createElement("hr",null),t.createElement(o.Row,null,t.createElement(o.Col,{md:6,sm:6},t.createElement(l.ZoneTypeControl,{isLoading:r}),t.createElement(a.SortControl,{isLoading:r}),t.createElement(c.GameDurationControl,{isLoading:r})),t.createElement(o.Col,{md:6,sm:6},t.createElement(s.ZoneImageControl,{isLoading:r}))),t.createElement("hr",null),t.createElement(o.Row,null,t.createElement(o.Col,{md:12,sm:12},t.createElement(m.DescriptionControl,{isLoading:r})))))};
|
|
@@ -8,5 +8,5 @@ export type ZoneRecurrenceControlProps = {
|
|
|
8
8
|
workHours?: WorkHour[];
|
|
9
9
|
isLoading?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare const ZoneRecurrencesControl: (
|
|
11
|
+
export declare const ZoneRecurrencesControl: () => JSX.Element;
|
|
12
12
|
//# sourceMappingURL=ZoneRecurrencesControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZoneRecurrencesControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneRecurrencesControl.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAMlG,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;
|
|
1
|
+
{"version":3,"file":"ZoneRecurrencesControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/ZoneRecurrencesControl.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAMlG,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAWtF,MAAM,WAAW,4BAA4B;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;CAC7C;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,mBAsMlC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),o=require("react-bootstrap"),a=require("../../../static/Icon.js"),u=require("react-hook-form"),l=require("@react-aria/utils"),c=require("react-use");require("../../../static/index.js");var d=require("@dnd-kit/core"),s=require("@dnd-kit/sortable"),m=require("../../../modals/confirmation/ConfirmModal.js"),v=require("../../../recurring-date-picker-input/RecurringDatePickerInput.js"),f=require("../../../product-set/control/DateAndRecurrenceInput.js"),p=require("./ZoneRecurrenceControl.js");exports.ZoneRecurrencesControl=function(){var e,g,_=u.useFormContext(),E=_.control,q=_.register,x=_.formState.errors,C=_.getValues,D=_.setValue,R=_.clearErrors,b=u.useFieldArray({name:"zoneRecurrences",control:E,keyName:"_id"}),y=b.fields,I=b.append,S=b.update,k=b.move,z=r.__read(t.useState(!1),2),N=z[0],h=z[1],j=r.__read(t.useState({index:null,values:null}),2),T=j[0],A=j[1],w=function(){return A({index:null,values:null})},F=t.useRef();c.useClickAway(F,(function(e){var r,t,n;m.CONFIRM_MODAL_ACTIONS.includes(null===(n=null===(t=null===(r=e.target)||void 0===r?void 0:r.attributes)||void 0===t?void 0:t.getNamedItem("data-id"))||void 0===n?void 0:n.value)||(h(!1),w())}));var M=l.useId(),P=i.useTranslation(["Design","Validation"]).t,O=function(){w(),h((function(e){return!e}))};return t.useEffect((function(){y.length&&R("zoneRecurrences")}),[y,R]),n.createElement(o.Form.Group,null,n.createElement(o.Form.Label,null,P("zoneAvailable")),n.createElement(o.OverlayTrigger,{show:N,overlay:n.createElement(o.Popover,{id:M,className:"rounded"},n.createElement(o.Popover.Content,{className:"shadow-lg rounded",ref:F},n.createElement(v.RecurringDatePickerInput,{defaultValues:T.values,onChange:function(e){return r.__awaiter(void 0,void 0,void 0,(function(){var t,n,i;return r.__generator(this,(function(r){return t={rrule:e.rrule,startDate:e.startDate,endDate:e.endDate,startTime:e.startTime,endTime:e.endTime},(null===(n=T.values)||void 0===n?void 0:n.id)&&(t.id=null===(i=T.values)||void 0===i?void 0:i.id),null!==T.index?S(T.index,t):I(t),h((function(){return!1})),w(),[2]}))}))},onDelete:function(){var e=T.index;h(!1),w(),setTimeout((function(){var r=C().zoneRecurrences;D("zoneRecurrences",(void 0===r?[]:r).filter((function(r,t){return t!==e})))}),100)},setInitialStartDateAfterSelect:!0}))),trigger:"click",placement:"bottom",popperConfig:{modifiers:[f.sameWidthPopperModifier]}},n.createElement("div",{className:"zone-recurrences"},n.createElement(d.DndContext,{onDragEnd:function(e){var r=e.over,t=e.active;if(r.id!==t.id){var n=y.findIndex((function(e){return String(e._id)===t.id})),i=y.findIndex((function(e){return String(e._id)===r.id}));k(n,i)}}},n.createElement(s.SortableContext,{items:null!==(e=null==y?void 0:y.map((function(e){return String(e._id)})))&&void 0!==e?e:[],strategy:s.verticalListSortingStrategy},null==y?void 0:y.map((function(e,r){return n.createElement(p.ZoneRecurrenceControl,{key:e._id,zoneRecurrence:e,onEdit:function(){return function(e,r){w(),A({index:r,values:e}),h((function(){return!0}))}(e,r)}})})))),n.createElement("div",{className:"zone-recurrence-icon-wrapper",role:"button",tabIndex:0,onClick:O,onKeyDown:O},n.createElement(a.default,{type:"plus-circle",height:"1rem",className:"zone-recurrence-icon-add mr-2"}),P("addDates")),n.createElement(o.Form.Control,r.__assign({type:"hidden"},q("zoneRecurrences",{required:{value:!0,message:P("Validation:fieldMinNumber",{attribute:P("dates"),min:1})}}))),n.createElement("div",{className:"manual-form-error"},null===(g=x.zoneRecurrences)||void 0===g?void 0:g.message))))};
|
package/package.json
CHANGED
|
@@ -5,8 +5,11 @@ import { Form, OverlayTrigger, Popover } from "react-bootstrap";
|
|
|
5
5
|
import { useFieldArray, useFormContext } from "react-hook-form";
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
7
|
import { useClickAway } from "react-use";
|
|
8
|
+
import { DateTime } from "luxon";
|
|
9
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
8
10
|
import { ProductSetRecurrence } from "@licklist/core/dist/DataMapper/Product/ProductSetRecurrenceDataMapper";
|
|
9
11
|
import { DndContext } from "@dnd-kit/core";
|
|
12
|
+
import { TIME_FORMAT } from "@licklist/core/dist/Config/Date";
|
|
10
13
|
import {
|
|
11
14
|
SortableContext,
|
|
12
15
|
verticalListSortingStrategy,
|
|
@@ -20,6 +23,11 @@ import {
|
|
|
20
23
|
RecurringDatePickerInputValues,
|
|
21
24
|
} from "../../recurring-date-picker-input/RecurringDatePickerInput";
|
|
22
25
|
import { ProductSetRecurrenceControl } from "./ProductSetRecurrenceControl";
|
|
26
|
+
import {
|
|
27
|
+
AvailableTimesControl,
|
|
28
|
+
AvailableTimesControlRef,
|
|
29
|
+
} from "../../zone/form/components/AvailableTimesControl";
|
|
30
|
+
|
|
23
31
|
// eslint-disable-next-line max-len
|
|
24
32
|
|
|
25
33
|
export interface DateAndRecurrenceInputValues {
|
|
@@ -28,10 +36,16 @@ export interface DateAndRecurrenceInputValues {
|
|
|
28
36
|
|
|
29
37
|
interface DateAndRecurrenceInputProps {
|
|
30
38
|
isEventEditProductSet?: boolean;
|
|
39
|
+
workHours?: WorkHour[];
|
|
40
|
+
providerHasBookingManagement: boolean;
|
|
41
|
+
isLoading?: boolean;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
export const DateAndRecurrenceInput = ({
|
|
34
45
|
isEventEditProductSet,
|
|
46
|
+
providerHasBookingManagement,
|
|
47
|
+
workHours,
|
|
48
|
+
isLoading,
|
|
35
49
|
}: DateAndRecurrenceInputProps) => {
|
|
36
50
|
const {
|
|
37
51
|
control,
|
|
@@ -42,6 +56,9 @@ export const DateAndRecurrenceInput = ({
|
|
|
42
56
|
clearErrors,
|
|
43
57
|
} = useFormContext<DateAndRecurrenceInputValues>();
|
|
44
58
|
|
|
59
|
+
const [availableTimes, setAvailableTimes] = useState<string[]>([]);
|
|
60
|
+
const availableTimesFormRef = useRef<AvailableTimesControlRef>();
|
|
61
|
+
|
|
45
62
|
const { fields, append, update, move } = useFieldArray({
|
|
46
63
|
name: "menuRecurrences",
|
|
47
64
|
control,
|
|
@@ -78,13 +95,46 @@ export const DateAndRecurrenceInput = ({
|
|
|
78
95
|
const { t } = useTranslation("Design");
|
|
79
96
|
|
|
80
97
|
// in this method we should fulfill the form with a proper data
|
|
81
|
-
const handleRecurringDateChange = (
|
|
98
|
+
const handleRecurringDateChange = async (
|
|
99
|
+
next: RecurringDatePickerInputValues
|
|
100
|
+
) => {
|
|
101
|
+
const isAvailableTimesFormValid =
|
|
102
|
+
await availableTimesFormRef.current?.trigger();
|
|
103
|
+
if (!isAvailableTimesFormValid) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (next?.startTime && next?.endTime) {
|
|
107
|
+
const startTime = DateTime.fromISO(next.startTime);
|
|
108
|
+
const endTime = DateTime.fromISO(next.endTime);
|
|
109
|
+
const { availableTimes } = availableTimesFormRef.current.getValues();
|
|
110
|
+
const validAvalilableTimes = availableTimes.every((time) => {
|
|
111
|
+
const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
currentAvailableTime.diff(startTime, "minutes").minutes >= 0 &&
|
|
115
|
+
currentAvailableTime.diff(endTime, "minutes").minutes <= 0
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
if (!validAvalilableTimes) {
|
|
119
|
+
availableTimesFormRef.current.setError("availableTimes", {
|
|
120
|
+
message: t("Validation:fieldTimeBetween", {
|
|
121
|
+
attribute: t("Design:startTimesSmall"),
|
|
122
|
+
min: startTime.toFormat(TIME_FORMAT),
|
|
123
|
+
max: endTime.toFormat(TIME_FORMAT),
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
82
131
|
const values = {
|
|
83
132
|
rrule: next.rrule,
|
|
84
133
|
startDate: next.startDate,
|
|
85
134
|
endDate: next.endDate,
|
|
86
135
|
startTime: next.startTime,
|
|
87
136
|
endTime: next.endTime,
|
|
137
|
+
...availableTimesFormRef.current.getValues(),
|
|
88
138
|
} as Partial<ProductSetRecurrence>;
|
|
89
139
|
|
|
90
140
|
if (editState.values?.id) {
|
|
@@ -107,6 +157,7 @@ export const DateAndRecurrenceInput = ({
|
|
|
107
157
|
// Hotfix for an issue with Popover close & open actions
|
|
108
158
|
setTimeout(() => {
|
|
109
159
|
setEditState({ index, values: next });
|
|
160
|
+
setAvailableTimes(next.availableTimes || []);
|
|
110
161
|
setIsDatePopoverVisible(() => true);
|
|
111
162
|
}, 100);
|
|
112
163
|
};
|
|
@@ -176,7 +227,16 @@ export const DateAndRecurrenceInput = ({
|
|
|
176
227
|
defaultValues={editState.values}
|
|
177
228
|
onChange={handleRecurringDateChange}
|
|
178
229
|
onDelete={handleDelete}
|
|
179
|
-
|
|
230
|
+
>
|
|
231
|
+
{providerHasBookingManagement && (
|
|
232
|
+
<AvailableTimesControl
|
|
233
|
+
workHours={workHours}
|
|
234
|
+
isLoading={isLoading}
|
|
235
|
+
defaultValues={availableTimes}
|
|
236
|
+
ref={availableTimesFormRef}
|
|
237
|
+
/>
|
|
238
|
+
)}
|
|
239
|
+
</RecurringDatePickerInput>
|
|
180
240
|
</Popover.Content>
|
|
181
241
|
</Popover>
|
|
182
242
|
}
|
|
@@ -21,6 +21,7 @@ import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/Email
|
|
|
21
21
|
import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemplateDataMapper";
|
|
22
22
|
import HookFormService from "@licklist/plugins/dist/services/Form/HookFormService";
|
|
23
23
|
import { ruleForUrlWithProtocol } from "@licklist/plugins/dist/validation/Rules/urlRule";
|
|
24
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
24
25
|
import { WarningMessage } from "../../static";
|
|
25
26
|
import { SelectItem } from "../../types/generic/SelectItem";
|
|
26
27
|
import {
|
|
@@ -83,6 +84,8 @@ export interface ProductSetControlProps {
|
|
|
83
84
|
fieldSets?: FieldSet[];
|
|
84
85
|
showEmailTemplate?: boolean;
|
|
85
86
|
showSmsTemplate?: boolean;
|
|
87
|
+
workHours?: WorkHour[];
|
|
88
|
+
providerHasBookingManagement?: boolean;
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
export function ProductSetControl({
|
|
@@ -96,6 +99,8 @@ export function ProductSetControl({
|
|
|
96
99
|
isCreateAction,
|
|
97
100
|
showEmailTemplate,
|
|
98
101
|
showSmsTemplate,
|
|
102
|
+
workHours,
|
|
103
|
+
providerHasBookingManagement = false,
|
|
99
104
|
}: ProductSetControlProps) {
|
|
100
105
|
const { t } = useTranslation(["Design", "Validation", "Notification"]);
|
|
101
106
|
const {
|
|
@@ -157,6 +162,9 @@ export function ProductSetControl({
|
|
|
157
162
|
{isCreateAction && (
|
|
158
163
|
<DateAndRecurrenceInput
|
|
159
164
|
isEventEditProductSet={isEventEditProductSet}
|
|
165
|
+
workHours={workHours}
|
|
166
|
+
isLoading={isLoading}
|
|
167
|
+
providerHasBookingManagement={providerHasBookingManagement}
|
|
160
168
|
/>
|
|
161
169
|
)}
|
|
162
170
|
|
|
@@ -11,6 +11,7 @@ import { isEqual } from "lodash";
|
|
|
11
11
|
// eslint-disable-next-line max-len
|
|
12
12
|
import { ProviderBookingManagementSetting } from "@licklist/core/dist/DataMapper/Provider/ProviderBookingManagementSettingDataMapper";
|
|
13
13
|
import { Zone } from "@licklist/core/dist/DataMapper/Provider/ZoneDataMapper";
|
|
14
|
+
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
14
15
|
import { Dialog, useDialogContext } from "../../modals/dialog";
|
|
15
16
|
import {
|
|
16
17
|
ProductSetControl,
|
|
@@ -22,6 +23,7 @@ import { ProductSetContextProvider, ProductSetLoadingContext } from "./context";
|
|
|
22
23
|
import { SelectItem } from "../../types/generic/SelectItem";
|
|
23
24
|
import { getFilteredTemplates } from "../utils";
|
|
24
25
|
|
|
26
|
+
|
|
25
27
|
export interface WithIsLoading {
|
|
26
28
|
isLoading: boolean;
|
|
27
29
|
}
|
|
@@ -49,6 +51,7 @@ export interface ProductSetFormProps
|
|
|
49
51
|
providerHasBookingManagement?: ProviderBookingManagementSetting["hasBookingManagement"];
|
|
50
52
|
zones?: Zone[] | null;
|
|
51
53
|
isCreateAction?: boolean;
|
|
54
|
+
workHours?: WorkHour[];
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
export function ProductSetForm({
|
|
@@ -64,6 +67,7 @@ export function ProductSetForm({
|
|
|
64
67
|
providerHasBookingManagement,
|
|
65
68
|
zones,
|
|
66
69
|
isCreateAction,
|
|
70
|
+
workHours,
|
|
67
71
|
...shared
|
|
68
72
|
}: ProductSetFormProps) {
|
|
69
73
|
const { t } = useTranslation("Design");
|
|
@@ -75,6 +79,7 @@ export function ProductSetForm({
|
|
|
75
79
|
onDeclineDialog,
|
|
76
80
|
} = useDialogContext();
|
|
77
81
|
|
|
82
|
+
|
|
78
83
|
const form = useForm<ProductSetFormValues>({
|
|
79
84
|
defaultValues,
|
|
80
85
|
mode: "onChange",
|
|
@@ -147,6 +152,8 @@ export function ProductSetForm({
|
|
|
147
152
|
isLoading={isLoading}
|
|
148
153
|
isCreateAction={isCreateAction}
|
|
149
154
|
companyName={companyName}
|
|
155
|
+
workHours={workHours}
|
|
156
|
+
providerHasBookingManagement={providerHasBookingManagement}
|
|
150
157
|
/>
|
|
151
158
|
<Row>
|
|
152
159
|
<Col md={6} sm={12} />
|
|
@@ -25,7 +25,6 @@ export const ZoneForm = ({
|
|
|
25
25
|
onSubmit,
|
|
26
26
|
serverErrors,
|
|
27
27
|
isLoading = false,
|
|
28
|
-
workHours = [],
|
|
29
28
|
}: ZoneFormProps) => {
|
|
30
29
|
const { t } = useTranslation("Design");
|
|
31
30
|
const form = useForm<ZoneFormValues>({
|
|
@@ -55,7 +54,7 @@ export const ZoneForm = ({
|
|
|
55
54
|
return (
|
|
56
55
|
<FormProvider {...form}>
|
|
57
56
|
<Form onSubmit={handleSubmit(onFormSubmit)}>
|
|
58
|
-
<ZoneControl isLoading={isLoading}
|
|
57
|
+
<ZoneControl isLoading={isLoading}/>
|
|
59
58
|
<Row>
|
|
60
59
|
<Col md={6} sm={12} />
|
|
61
60
|
<Col
|
|
@@ -16,13 +16,12 @@ export type ZoneControlProps = {
|
|
|
16
16
|
|
|
17
17
|
export const ZoneControl = ({
|
|
18
18
|
isLoading,
|
|
19
|
-
workHours = [],
|
|
20
19
|
}: ZoneControlProps) => {
|
|
21
20
|
return (
|
|
22
21
|
<Row>
|
|
23
22
|
<Col md={6} sm={12} className="pr-5">
|
|
24
23
|
<NameControl isLoading={isLoading} />
|
|
25
|
-
<ZoneRecurrencesControl
|
|
24
|
+
<ZoneRecurrencesControl />
|
|
26
25
|
<hr />
|
|
27
26
|
<Row>
|
|
28
27
|
<Col md={6} sm={6}>
|
|
@@ -11,8 +11,6 @@ import {
|
|
|
11
11
|
} from "@dnd-kit/sortable";
|
|
12
12
|
import { DndContext } from "@dnd-kit/core";
|
|
13
13
|
import { WorkHour } from "@licklist/core/dist/DataMapper/Provider/WorkHourDataMapper";
|
|
14
|
-
import { DateTime } from "luxon";
|
|
15
|
-
import { TIME_FORMAT } from "@licklist/core/dist/Config";
|
|
16
14
|
|
|
17
15
|
import { CONFIRM_MODAL_ACTIONS } from "../../../modals/confirmation/ConfirmModal";
|
|
18
16
|
import { Icon } from "../../../static";
|
|
@@ -21,10 +19,6 @@ import {
|
|
|
21
19
|
RecurringDatePickerInputValues,
|
|
22
20
|
} from "../../../recurring-date-picker-input/RecurringDatePickerInput";
|
|
23
21
|
import { ZoneRecurrenceControl } from "./ZoneRecurrenceControl";
|
|
24
|
-
import {
|
|
25
|
-
AvailableTimesControl,
|
|
26
|
-
AvailableTimesControlRef,
|
|
27
|
-
} from "./AvailableTimesControl";
|
|
28
22
|
import { sameWidthPopperModifier } from "../../../product-set/control/DateAndRecurrenceInput";
|
|
29
23
|
|
|
30
24
|
export interface DateAndRecurrenceInputValues {
|
|
@@ -36,10 +30,7 @@ export type ZoneRecurrenceControlProps = {
|
|
|
36
30
|
isLoading?: boolean;
|
|
37
31
|
};
|
|
38
32
|
|
|
39
|
-
export const ZoneRecurrencesControl = ({
|
|
40
|
-
workHours,
|
|
41
|
-
isLoading = false,
|
|
42
|
-
}: ZoneRecurrenceControlProps) => {
|
|
33
|
+
export const ZoneRecurrencesControl = () => {
|
|
43
34
|
const {
|
|
44
35
|
control,
|
|
45
36
|
register,
|
|
@@ -63,9 +54,7 @@ export const ZoneRecurrencesControl = ({
|
|
|
63
54
|
values: null,
|
|
64
55
|
});
|
|
65
56
|
const clearEditState = () => setEditState({ index: null, values: null });
|
|
66
|
-
const [availableTimes, setAvailableTimes] = useState<string[]>([]);
|
|
67
57
|
const popoverRef = useRef<HTMLDivElement>();
|
|
68
|
-
const availableTimesFormRef = useRef<AvailableTimesControlRef>();
|
|
69
58
|
|
|
70
59
|
useClickAway(popoverRef, (event) => {
|
|
71
60
|
const isModal = CONFIRM_MODAL_ACTIONS.includes(
|
|
@@ -88,42 +77,12 @@ export const ZoneRecurrencesControl = ({
|
|
|
88
77
|
const handleRecurringDateChange = async (
|
|
89
78
|
next: RecurringDatePickerInputValues
|
|
90
79
|
) => {
|
|
91
|
-
const isAvailableTimesFormValid =
|
|
92
|
-
await availableTimesFormRef.current?.trigger();
|
|
93
|
-
if (!isAvailableTimesFormValid) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (next?.startTime && next?.endTime) {
|
|
97
|
-
const startTime = DateTime.fromISO(next.startTime);
|
|
98
|
-
const endTime = DateTime.fromISO(next.endTime);
|
|
99
|
-
const { availableTimes } = availableTimesFormRef.current.getValues();
|
|
100
|
-
const validAvalilableTimes = availableTimes.every((time) => {
|
|
101
|
-
const currentAvailableTime = DateTime.fromFormat(time, TIME_FORMAT);
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
currentAvailableTime.diff(startTime, "minutes").minutes >= 0 &&
|
|
105
|
-
currentAvailableTime.diff(endTime, "minutes").minutes <= 0
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
if (!validAvalilableTimes) {
|
|
109
|
-
availableTimesFormRef.current.setError("availableTimes", {
|
|
110
|
-
message: t("Validation:fieldTimeBetween", {
|
|
111
|
-
attribute: t("Design:startTimesSmall"),
|
|
112
|
-
min: startTime.toFormat(TIME_FORMAT),
|
|
113
|
-
max: endTime.toFormat(TIME_FORMAT),
|
|
114
|
-
}),
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
80
|
const values = {
|
|
121
81
|
rrule: next.rrule,
|
|
122
82
|
startDate: next.startDate,
|
|
123
83
|
endDate: next.endDate,
|
|
124
84
|
startTime: next.startTime,
|
|
125
85
|
endTime: next.endTime,
|
|
126
|
-
...availableTimesFormRef.current.getValues(),
|
|
127
86
|
} as Partial<ZoneRecurrence>;
|
|
128
87
|
|
|
129
88
|
if (editState.values?.id) {
|
|
@@ -144,7 +103,6 @@ export const ZoneRecurrencesControl = ({
|
|
|
144
103
|
clearEditState();
|
|
145
104
|
|
|
146
105
|
setEditState({ index, values: next });
|
|
147
|
-
setAvailableTimes(next.availableTimes || []);
|
|
148
106
|
setIsDatePopoverVisible(() => true);
|
|
149
107
|
};
|
|
150
108
|
|
|
@@ -208,14 +166,7 @@ export const ZoneRecurrencesControl = ({
|
|
|
208
166
|
onChange={handleRecurringDateChange}
|
|
209
167
|
onDelete={handleDelete}
|
|
210
168
|
setInitialStartDateAfterSelect
|
|
211
|
-
|
|
212
|
-
<AvailableTimesControl
|
|
213
|
-
workHours={workHours}
|
|
214
|
-
isLoading={isLoading}
|
|
215
|
-
defaultValues={availableTimes}
|
|
216
|
-
ref={availableTimesFormRef}
|
|
217
|
-
/>
|
|
218
|
-
</RecurringDatePickerInput>
|
|
169
|
+
/>
|
|
219
170
|
</Popover.Content>
|
|
220
171
|
</Popover>
|
|
221
172
|
}
|