@licklist/design 0.44.486-dev.67 → 0.44.486-dev.69
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/events/event-card/EventCard.js +1 -1
- package/dist/events/event-card/utils.d.ts +1 -1
- package/dist/events/event-card/utils.d.ts.map +1 -1
- package/dist/events/event-card/utils.js +1 -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/ProductSetRecurrenceControl.d.ts +2 -1
- package/dist/product-set/control/ProductSetRecurrenceControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetRecurrenceControl.js +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/utils/index.d.ts +10 -0
- package/dist/product-set/utils/index.d.ts.map +1 -1
- package/dist/product-set/utils/index.js +1 -1
- package/dist/zone/form/components/AvailableTimesControl.d.ts +2 -0
- package/dist/zone/form/components/AvailableTimesControl.d.ts.map +1 -1
- package/dist/zone/form/components/AvailableTimesControl.js +1 -1
- package/package.json +1 -1
- package/src/events/event-card/EventCard.tsx +1 -1
- package/src/events/event-card/utils.ts +10 -19
- package/src/product-set/control/DateAndRecurrenceInput.tsx +13 -0
- package/src/product-set/control/ProductSetRecurrenceControl.tsx +6 -1
- package/src/product-set/form/ProductSetForm.stories.tsx +6 -2
- package/src/product-set/form/ProductSetForm.tsx +14 -3
- package/src/product-set/utils/index.ts +38 -0
- package/src/zone/form/components/AvailableTimesControl.tsx +89 -83
|
@@ -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=require("react"),n=e(a),r=require("@licklist/core/dist/Config"),l=require("react-i18next"),c=require("react-bootstrap"),i=require("../../static/Icon.js"),s=e(require("clsx")),m=require("react-intl"),o=require("../../tiptap-editor/TipTapEditor.js"),u=require("./utils.js"),d=require("../../assets/dashboard/chartBar.svg.js");exports.EventCard=function(e){var E=e.name,v=e.description,p=e.date,y=e.imageUrl,f=e.sales,b=e.onPreview,N=e.onEdit,C=e.onCopy,k=e.onRemove,g=e.hasPermission,x=void 0===g||g,q=e.onStatistic,w=e.eventStatistic,h=e.titleId,T=e.descriptionId,j=l.useTranslation("Design").t,I=m.useIntl(),P=I.formatNumber,_=I.formatDate,B=u.getStatisticInfo(w
|
|
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=require("react"),n=e(a),r=require("@licklist/core/dist/Config"),l=require("react-i18next"),c=require("react-bootstrap"),i=require("../../static/Icon.js"),s=e(require("clsx")),m=require("react-intl"),o=require("../../tiptap-editor/TipTapEditor.js"),u=require("./utils.js"),d=require("../../assets/dashboard/chartBar.svg.js");exports.EventCard=function(e){var E=e.name,v=e.description,p=e.date,y=e.imageUrl,f=e.sales,b=e.onPreview,N=e.onEdit,C=e.onCopy,k=e.onRemove,g=e.hasPermission,x=void 0===g||g,q=e.onStatistic,w=e.eventStatistic,h=e.titleId,T=e.descriptionId,j=l.useTranslation("Design").t,I=m.useIntl(),P=I.formatNumber,_=I.formatDate,B=u.getStatisticInfo(w),S=B.totalViews,D=t.__rest(B,["totalViews"]),M=a.useMemo((function(){return u.formatContentWithoutTags(v,u.EVENT_DESCRIPTION_SIZE)}),[v]);return n.createElement(c.Card,{className:"d-flex flex-column event-card h-100"},n.createElement("div",{className:s("event-card-image-container",!y&&"no-image")},y&&n.createElement(c.Card.Img,{variant:"top",src:y}),n.createElement(c.Badge,{className:"event-card-date",as:"time",dateTime:p,variant:"primary"},_(new Date(p),{weekday:"short",day:"numeric",month:"short",year:"numeric",hour:"numeric",minute:"numeric"}))),n.createElement(c.Card.Body,null,n.createElement(c.Card.Title,{id:h},E),n.createElement("div",{className:"flex-grow-1"},n.createElement(o.TipTapEditor,{viewMode:!0,disabled:!0,className:s("event-description",!y&&"no-image"),content:M,id:T}),n.createElement("div",{className:"mt-2 ml-2"},Object.keys(D).map((function(e){return n.createElement("div",{className:"event-card-sale",key:e},n.createElement("span",{className:"event-card-sale-name"},j(e),":"," ","totalAmount"===e?P(D[e],{style:"currency",currency:r.Currency.GBP}):D[e]))}))),f&&f.map((function(e){return n.createElement("div",{className:"event-card-sale",key:e.id},n.createElement("div",{className:"event-card-sale-text"},n.createElement("span",{className:"event-card-sale-name"},e.name)," ",n.createElement("span",{className:"event-card-sale-quantity"},[e.current,e.max].map((function(e){return P(e)})).join(" / "))),n.createElement(c.ProgressBar,{now:e.current,max:e.max}))})))),n.createElement(c.Card.Footer,null,n.createElement("div",{className:"d-flex w-100 justify-content-between"},n.createElement("div",{className:"d-flex"},n.createElement("button",{type:"button",className:"event-card-link-button ml-3 mr-4",onClick:q},n.createElement(d.ReactComponent,null)),n.createElement("div",{className:"event-card-views"},n.createElement(i.default,{type:"eye"}),n.createElement("span",null,P(S)))),n.createElement("div",null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:b},n.createElement(i.default,{type:"external-link-alt"})),x&&n.createElement(n.Fragment,null,n.createElement("button",{type:"button",className:"event-card-link-button",onClick:N},n.createElement(i.default,{type:"edit"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:C},n.createElement(i.default,{type:"copy"})),n.createElement("button",{type:"button",className:"event-card-link-button",onClick:k},n.createElement(i.default,{type:"trash-alt"})))))))};
|
|
@@ -2,7 +2,7 @@ import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventSta
|
|
|
2
2
|
export declare function formatContent(content: any, maxSymbols: any): any;
|
|
3
3
|
export declare const formatContentWithoutTags: (content: any, maxLength?: number) => any;
|
|
4
4
|
export declare const EVENT_DESCRIPTION_SIZE = 300;
|
|
5
|
-
export declare const getStatisticInfo: (eventStatistic: EventStatistic | null
|
|
5
|
+
export declare const getStatisticInfo: (eventStatistic: EventStatistic | null) => {
|
|
6
6
|
totalViews: number;
|
|
7
7
|
totalSold: number;
|
|
8
8
|
totalAmount: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/event-card/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/events/event-card/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAC;AAElG,wBAAgB,aAAa,CAAC,OAAO,KAAA,EAAE,UAAU,KAAA,OAIhD;AAED,eAAO,MAAM,wBAAwB,2CAYpC,CAAC;AAEF,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,gBAAgB,mBAAoB,cAAc,GAAG,IAAI;;;;CAwBrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.EVENT_DESCRIPTION_SIZE=300,exports.formatContent=function(t,e){return t?t.length>e?"".concat(t.slice(0,e),"..."):t:""},exports.formatContentWithoutTags=function(t,e){if(void 0===e&&(e=300),!t)return"";if(t<e)return t;var r=t.replace(/<[^>]*>/g,"").trim().replace(/ |[^a-zA-Z0-9\s]/g,"").replace(/\s\s+/g," ").slice(0,e).split(" "),o=String(t).indexOf(r[r.length-2]);return t.slice(0,o).concat("...")},exports.getStatisticInfo=function(t){var e,r=0,o=0;return t?(e=Object.values(t.views).reduce((function(t,e){return t+(e.pageViews||0)}),0),Object.values(t.productCategorySummary).forEach((function(t){return t.forEach((function(t){var e=t.totalPerCategory,n=t.productsSummary,a=void 0===n?[]:n;o+=e||0,null==a||a.forEach((function(t){var e=t.productsSold;r+=e}))}))})),{totalViews:e,totalSold:r,totalAmount:o}):{totalViews:0,totalSold:0,totalAmount:0}};
|
|
@@ -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;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,
|
|
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,gBA8Q7B,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"),a=require("react-bootstrap"),
|
|
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"),o=require("../../static/Icon.js"),u=require("react-hook-form"),l=require("@react-aria/utils"),s=require("react-use"),c=require("luxon");require("../../static/index.js");var d=require("@dnd-kit/core"),m=require("@dnd-kit/modifiers"),v=require("@dnd-kit/sortable"),f=require("../../modals/confirmation/ConfirmModal.js"),g=require("@licklist/core/dist/Config/Date"),p=require("../../recurring-date-picker-input/RecurringDatePickerInput.js"),T=require("./ProductSetRecurrenceControl.js"),b=require("../../zone/form/components/AvailableTimesControl.js"),x={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 E,_,R,h,q,D=e.isEventEditProductSet,S=e.providerHasBookingManagement,C=e.workHours,y=e.isLoading,k=u.useFormContext(),I=k.control,M=k.register,w=k.formState.errors,A=k.getValues,O=k.setValue,F=k.clearErrors,N=r.__read(t.useState([]),2),j=N[0],P=N[1],V=t.useRef(),L=u.useFieldArray({name:"menuRecurrences",control:I,keyName:"_id"}),W=L.fields,B=L.append,H=L.update,z=L.move,G=r.__read(t.useState(!1),2),K=G[0],J=G[1],Q=r.__read(t.useState({index:null,values:null}),2),U=Q[0],X=Q[1],Y=function(){return X({index:null,values:null})},Z=t.useRef();s.useClickAway(Z,(function(e){var r,t,n;f.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)||(J(!1),Y())}));var $=l.useId(),ee=i.useTranslation("Design").t,re=function(){Y(),J((function(e){return!e}))};return t.useEffect((function(){W.length&&F("menuRecurrences")}),[W,F]),n.createElement(a.Form.Group,null,n.createElement(a.Form.Label,null,ee(D?"whenOverridesAvailable":"productSetAvailable")),n.createElement(a.OverlayTrigger,{show:K,overlay:n.createElement(a.Popover,{id:$,className:"rounded"},n.createElement(a.Popover.Content,{className:"shadow-lg rounded",ref:Z},n.createElement(p.RecurringDatePickerInput,{defaultValues:U.values,onChange:function(e){return r.__awaiter(void 0,void 0,void 0,(function(){var t,n,i,a,o,u,l;return r.__generator(this,(function(s){switch(s.label){case 0:return[4,null===(o=V.current)||void 0===o?void 0:o.trigger()];case 1:return s.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=V.current.getValues().availableTimes,i.every((function(e){var r=c.DateTime.fromFormat(e,g.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},V.current.getValues()),(null===(u=U.values)||void 0===u?void 0:u.id)&&(a.id=null===(l=U.values)||void 0===l?void 0:l.id),null!==U.index?H(U.index,a):B(a),J((function(){return!1})),Y(),[2]):(V.current.setError("availableTimes",{message:ee("Validation:fieldTimeBetween",{attribute:ee("Design:startTimesSmall"),min:t.toFormat(g.TIME_FORMAT),max:n.toFormat(g.TIME_FORMAT)})}),[2]):[2]}}))}))},onDelete:function(){var e=U.index;J(!1),Y(),setTimeout((function(){var r=A().menuRecurrences;O("menuRecurrences",(void 0===r?[]:r).filter((function(r,t){return t!==e})))}),100)}},S&&n.createElement(b.AvailableTimesControl,{workHours:C,isLoading:y,defaultValues:j,ref:V,errorMessage:null===(R=null===(_=null===(E=null==w?void 0:w.menuRecurrences)||void 0===E?void 0:E["".concat(null==U?void 0:U.index)])||void 0===_?void 0:_.availableTimes)||void 0===R?void 0:R.message,clearErrorMessage:function(){return F("menuRecurrences.".concat(null==U?void 0:U.index,".availableTimes"))}})))),trigger:"click",placement:"bottom",popperConfig:{modifiers:[x]}},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=W.findIndex((function(e){return String(e._id)===t.id})),i=W.findIndex((function(e){return String(e._id)===r.id}));z(n,i)}},modifiers:[m.restrictToVerticalAxis]},n.createElement(v.SortableContext,{items:null!==(h=null==W?void 0:W.map((function(e){return String(e._id)})))&&void 0!==h?h:[],strategy:v.verticalListSortingStrategy},W.map((function(e,r){var t,i,a;return n.createElement(T.ProductSetRecurrenceControl,{key:e._id,menuRecurrence:e,onEdit:function(){return function(e,r){Y(),setTimeout((function(){X({index:r,values:e}),P(e.availableTimes||[]),J((function(){return!0}))}),100)}(e,r)},errorMessage:null===(a=null===(i=null===(t=null==w?void 0:w.menuRecurrences)||void 0===t?void 0:t["".concat(r)])||void 0===i?void 0:i.availableTimes)||void 0===a?void 0:a.message})})))),(!D||(null==W?void 0:W.length)<1)&&n.createElement("div",{className:"product-set-recurrence-icon-wrapper",role:"button",tabIndex:0,onClick:re,onKeyDown:re},n.createElement(o.default,{type:"plus-circle",height:"1rem",className:"product-set-recurrence-icon-add mr-2"}),ee("addDates")),n.createElement(a.Form.Control,r.__assign({type:"hidden"},M("menuRecurrences",{required:{value:!0,message:ee("Validation:fieldMinNumber",{attribute:ee("dates"),min:1})}}))),n.createElement("div",{className:"manual-form-error"},null===(q=w.menuRecurrences)||void 0===q?void 0:q.message))))},exports.sameWidthPopperModifier=x;
|
|
@@ -5,6 +5,7 @@ export interface ProductSetRecurrenceControlProps {
|
|
|
5
5
|
_id: string;
|
|
6
6
|
} & Partial<ProductSetRecurrence>;
|
|
7
7
|
onEdit?: (onEdit: Partial<ProductSetRecurrence>) => void;
|
|
8
|
+
errorMessage?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const ProductSetRecurrenceControl: ({ menuRecurrence, onEdit, }: ProductSetRecurrenceControlProps) => JSX.Element;
|
|
10
|
+
export declare const ProductSetRecurrenceControl: ({ menuRecurrence, onEdit, errorMessage, }: ProductSetRecurrenceControlProps) => JSX.Element;
|
|
10
11
|
//# sourceMappingURL=ProductSetRecurrenceControl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductSetRecurrenceControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/ProductSetRecurrenceControl.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAM7G,MAAM,WAAW,gCAAgC;IAC/C,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ProductSetRecurrenceControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/control/ProductSetRecurrenceControl.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uEAAuE,CAAC;AAM7G,MAAM,WAAW,gCAAgC;IAC/C,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACjE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,2BAA2B,8CAIrC,gCAAgC,gBAyElC,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
|
|
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=e(require("react")),n=require("react-i18next"),a=require("../../static/Icon.js");require("../../static/index.js");var l=require("@dnd-kit/sortable"),c=require("@dnd-kit/utilities"),i=e(require("rrule")),s=require("react-intl");exports.ProductSetRecurrenceControl=function(e){var o=e.menuRecurrence,u=e.onEdit,d=e.errorMessage,m=s.useIntl().formatDate,f=n.useTranslation("Design").t,p=l.useSortable({id:String(o._id)}),x=p.attributes,b=p.listeners,g=p.setNodeRef,E=p.transform,N=p.transition;return t.createElement("div",r.__assign({className:"sortable-tree-root flex-column",style:{transform:c.CSS.Translate.toString(E),transition:N}},x,b,{ref:g,role:"button",tabIndex:0}),t.createElement("div",{key:o.rrule,className:"product-set-recurrence d-flex flex-column mr-0 mb-3 p-3 px-4 flex-grow-1"},t.createElement("span",{className:"d-flex flex-row align-items-center"},t.createElement(a.default,{type:"calendar",height:"1rem",className:"product-set-recurrence-icon-calendar"}),t.createElement("span",{className:"product-set-recurrence-title d-flex flex-grow-1"},f("from")," ",m(o.startDate,{dateStyle:"medium"})," ",o.endDate&&t.createElement(t.Fragment,null,"- ",m(o.endDate,{dateStyle:"medium"}))),t.createElement("div",{className:"d-inline-flex",role:"button",tabIndex:0,onClick:function(){return u(o)},onKeyDown:function(){return u(o)}},t.createElement(a.default,{type:"ellipsis-h",height:"1rem",className:"product-set-recurrence-icon-more"}))),t.createElement("span",{className:"product-set-recurrence-description"},function(e){return i.fromString(e.rrule).toText()}(o))),t.createElement("div",{className:"manual-form-error ".concat(!d&&"d-none")},d))};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AE,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,eAqIrB"}
|
|
@@ -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"),
|
|
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"),u=require("../../modals/dialog/Dialog.js"),d=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,b=e.onSubmitNoRedirect,w=e.productGroupList,S=e.serverErrors,h=e.providerHasMap,C=void 0!==h&&h,T=e.venueMapSets,k=void 0===T?[]:T,q=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"]),A=n.useTranslation("Design").t,H=d.useDialogContext(),P=H.isShownDialog,F=H.onBeforeUnload,N=H.onPopState,B=H.onApproveDialog,_=H.onDeclineDialog,j=i.useForm({defaultValues:E,mode:"onChange"}),y=j.setError,R=j.reset,z=j.watch(),G=function(e){return function(t){c.checkAvailableTimesErrors({values:t,setError:y,t:A})||e(t)}};return o.useEffect((function(){E&&!l.isEqual(E,z)&&R(E)}),[E]),o.useEffect((function(){S&&s.handleServerErrors(S,y)}),[S,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:w,providerHasMap:C,venueMapSets:k,providerHasBookingManagement:q,zones:D},r.createElement(u.Dialog,{isActive:P,title:A("Design:leavePage"),content:A("Design:changesNotBeSaved"),onApprove:B,onDecline:_}),r.createElement(i.FormProvider,t.__assign({},j),r.createElement(a.Form,{onSubmit:j.handleSubmit(G(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:q})),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},b&&r.createElement(a.Button,{className:"product-set-save-btn mt-5 ml-5 d-no dne d-md-block",onClick:j.handleSubmit(G(b)),disabled:g||o||!z.name},A("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},A("saveAndClose")))))})))))};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/EmailTemplateDataMapper";
|
|
2
2
|
import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemplateDataMapper";
|
|
3
|
+
import { TFunction } from "i18next";
|
|
4
|
+
import { UseFormSetError } from "react-hook-form";
|
|
3
5
|
import { TemplateItem } from "../control/ProductSetControl";
|
|
6
|
+
import { ProductSetFormValues } from "../form/ProductSetForm";
|
|
7
|
+
interface CheckAvailableTimesErrors {
|
|
8
|
+
values: ProductSetFormValues;
|
|
9
|
+
setError: UseFormSetError<ProductSetFormValues>;
|
|
10
|
+
t: TFunction;
|
|
11
|
+
}
|
|
4
12
|
export declare const moveArrayElements: <T>(array: T[], prevIndex: number, nextIndex: number) => T[];
|
|
5
13
|
export declare const sortArrayByIndex: <T>(array: T[]) => (T & {
|
|
6
14
|
sort: number;
|
|
7
15
|
})[];
|
|
8
16
|
export declare const getFilteredTemplates: (templates?: EmailTemplate[] | SmsTemplate[], formTemplates?: TemplateItem[]) => TemplateItem[] | undefined;
|
|
17
|
+
export declare const checkAvailableTimesErrors: ({ values, setError, t, }: CheckAvailableTimesErrors) => boolean;
|
|
18
|
+
export {};
|
|
9
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/product-set/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,mEAAmE,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/product-set/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qEAAqE,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,mEAAmE,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,UAAU,yBAAyB;IACjC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,eAAe,CAAC,oBAAoB,CAAC,CAAC;IAChD,CAAC,EAAE,SAAS,CAAC;CACd;AAED,eAAO,MAAM,iBAAiB,6BAEjB,MAAM,aACN,MAAM,QAQlB,CAAC;AAEF,eAAO,MAAM,gBAAgB;;IAE5B,CAAC;AAEF,eAAO,MAAM,oBAAoB,eACnB,aAAa,EAAE,GAAG,WAAW,EAAE,kBAC3B,YAAY,EAAE,KAC7B,YAAY,EAAE,GAAG,SAmBnB,CAAC;AAEF,eAAO,MAAM,yBAAyB,6BAInC,yBAAyB,YAuB3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib");exports.checkAvailableTimesErrors=function(e){var i,n,r=e.values,t=e.setError,o=e.t,l=!1;return(null===(i=null==r?void 0:r.steps)||void 0===i?void 0:i.some((function(e){return!!(null==e?void 0:e.productCategories.some((function(e){return!!(null==e?void 0:e.zoneId)})))})))?(null===(n=null==r?void 0:r.menuRecurrences)||void 0===n||n.forEach((function(e,i){var n;(null===(n=null==e?void 0:e.availableTimes)||void 0===n?void 0:n.length)||(l=!0,t("menuRecurrences.".concat(i,".availableTimes"),{type:"validate",message:o("Validation:fieldMinNumber",{attribute:o("startTimes"),min:1})}))})),l):l},exports.getFilteredTemplates=function(e,i){var n;if(e)return null===(n=null==e?void 0:e.filter((function(e){return e.notification.isActive&&!(null==i?void 0:i.find((function(i){return i.value.notification.type===e.notification.type})))})))||void 0===n?void 0:n.map((function(e){var i;return{id:null==e?void 0:e.id,value:e,label:null===(i=null==e?void 0:e.notification)||void 0===i?void 0:i.name}}))},exports.moveArrayElements=function(i,n,r){var t=e.__spreadArray([],e.__read(i),!1);return t.splice(r,0,t.splice(n,1)[0]),t},exports.sortArrayByIndex=function(i){return i.map((function(i,n){return e.__assign(e.__assign({},i),{sort:n})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvailableTimesControl.d.ts","sourceRoot":"","sources":["../../../../src/zone/form/components/AvailableTimesControl.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,eAAe,EAAW,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,4DAA4D,CAAC;AAGtF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM;QA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+1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("tslib"),a=require("react"),t=(e=a)&&"object"==typeof e&&"default"in e?e.default:e,i=require("react-i18next"),o=require("react-bootstrap"),s=require("react-hook-form"),n=require("@react-aria/utils"),l=require("../utils/dates.js"),u=a.forwardRef((function(e,u){var c,m=e.isLoading,d=e.workHours,f=e.defaultValues,v=void 0===f?[]:f,g=e.errorMessage,b=e.clearErrorMessage,p=n.useId(),E=i.useTranslation(["Design","Validation"]).t,h=s.useForm({mode:"onChange"}),k=h.register,_=h.formState.errors,y=h.reset,C=h.trigger,T=h.getValues,q=h.setValue,F=h.watch,x=h.setError,V=F("availableTimes")||[],I=a.useMemo((function(){return l.getCheckboxesByWorkHours(d)}),[d]);a.useImperativeHandle(u,(function(){return{trigger:C,getValues:T,setError:x}}));return a.useEffect((function(){v&&y({availableTimes:v})}),[v]),t.createElement(o.Form.Group,{controlId:p},t.createElement(o.Form.Label,null,E("Design:startTimes")),t.createElement("div",{className:"zone-available-times"},I.map((function(e){return t.createElement(o.Form.Check,{key:e,inline:!0,custom:!0,id:e},t.createElement(o.Form.Check.Input,{type:"checkbox",value:e,checked:V.includes(e),onChange:function(){return function(e){var a=V.includes(e);g&&b(),q("availableTimes",a?V.filter((function(r){return r!==e})):r.__spreadArray(r.__spreadArray([],r.__read(V),!1),[e],!1))}(e)},disabled:m}),t.createElement(o.Form.Check.Label,null,e))}))),t.createElement(o.Form.Control,r.__assign({type:"hidden"},k("availableTimes"))),t.createElement("div",{className:"manual-form-error"},(null===(c=_.availableTimes)||void 0===c?void 0:c.message)||g))}));exports.AvailableTimesControl=u;
|
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ export function EventCard({
|
|
|
50
50
|
}: EventCardProps) {
|
|
51
51
|
const { t } = useTranslation("Design");
|
|
52
52
|
const { formatNumber, formatDate } = useIntl();
|
|
53
|
-
const { totalViews, ...statistics } = getStatisticInfo(eventStatistic
|
|
53
|
+
const { totalViews, ...statistics } = getStatisticInfo(eventStatistic);
|
|
54
54
|
const memoedContent = useMemo(
|
|
55
55
|
() => formatContentWithoutTags(description, EVENT_DESCRIPTION_SIZE),
|
|
56
56
|
[description]
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { DATE_FORMAT, DATE_TIME_FULL_FORMAT } from "@licklist/core/dist/Config";
|
|
2
1
|
import { EventStatistic } from "@licklist/core/dist/DataMapper/Provider/EventStatisticDataMapper";
|
|
3
|
-
import { DateTime } from "luxon";
|
|
4
2
|
|
|
5
3
|
export function formatContent(content, maxSymbols) {
|
|
6
4
|
if (!content) return "";
|
|
@@ -24,34 +22,27 @@ export const formatContentWithoutTags = (content, maxLength = 300) => {
|
|
|
24
22
|
|
|
25
23
|
export const EVENT_DESCRIPTION_SIZE = 300;
|
|
26
24
|
|
|
27
|
-
export const getStatisticInfo = (
|
|
28
|
-
eventStatistic: EventStatistic | null,
|
|
29
|
-
date: string
|
|
30
|
-
) => {
|
|
25
|
+
export const getStatisticInfo = (eventStatistic: EventStatistic | null) => {
|
|
31
26
|
let totalViews = 0;
|
|
32
27
|
let totalSold = 0;
|
|
33
28
|
let totalAmount = 0;
|
|
34
29
|
|
|
35
30
|
if (!eventStatistic) return { totalViews: 0, totalSold: 0, totalAmount: 0 };
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
.toFormat(DATE_TIME_FULL_FORMAT);
|
|
46
|
-
|
|
47
|
-
eventStatistic?.productCategorySummary?.[summaryFormattedDate]?.forEach(
|
|
48
|
-
({ totalPerCategory, productsSummary = [] }) => {
|
|
32
|
+
totalViews = Object.values(eventStatistic.views).reduce(
|
|
33
|
+
(accumulator, currentValue) => {
|
|
34
|
+
return accumulator + (currentValue.pageViews || 0);
|
|
35
|
+
},
|
|
36
|
+
0
|
|
37
|
+
);
|
|
38
|
+
Object.values(eventStatistic.productCategorySummary).forEach((summaries) =>
|
|
39
|
+
summaries.forEach(({ totalPerCategory, productsSummary = [] }) => {
|
|
49
40
|
totalAmount += totalPerCategory || 0;
|
|
50
41
|
|
|
51
42
|
productsSummary?.forEach(({ productsSold }) => {
|
|
52
43
|
totalSold += productsSold;
|
|
53
44
|
});
|
|
54
|
-
}
|
|
45
|
+
})
|
|
55
46
|
);
|
|
56
47
|
|
|
57
48
|
return { totalViews, totalSold, totalAmount };
|
|
@@ -234,6 +234,15 @@ export const DateAndRecurrenceInput = ({
|
|
|
234
234
|
isLoading={isLoading}
|
|
235
235
|
defaultValues={availableTimes}
|
|
236
236
|
ref={availableTimesFormRef}
|
|
237
|
+
errorMessage={
|
|
238
|
+
errors?.menuRecurrences?.[`${editState?.index}`]
|
|
239
|
+
?.availableTimes?.message
|
|
240
|
+
}
|
|
241
|
+
clearErrorMessage={() =>
|
|
242
|
+
clearErrors(
|
|
243
|
+
`menuRecurrences.${editState?.index}.availableTimes`
|
|
244
|
+
)
|
|
245
|
+
}
|
|
237
246
|
/>
|
|
238
247
|
)}
|
|
239
248
|
</RecurringDatePickerInput>
|
|
@@ -261,6 +270,10 @@ export const DateAndRecurrenceInput = ({
|
|
|
261
270
|
key={menuRecurrence._id}
|
|
262
271
|
menuRecurrence={menuRecurrence}
|
|
263
272
|
onEdit={() => handleOnEdit(menuRecurrence, index)}
|
|
273
|
+
errorMessage={
|
|
274
|
+
errors?.menuRecurrences?.[`${index}`]?.availableTimes
|
|
275
|
+
?.message
|
|
276
|
+
}
|
|
264
277
|
/>
|
|
265
278
|
))}
|
|
266
279
|
</SortableContext>
|
|
@@ -11,11 +11,13 @@ import { Icon } from "../../static";
|
|
|
11
11
|
export interface ProductSetRecurrenceControlProps {
|
|
12
12
|
menuRecurrence?: { _id: string } & Partial<ProductSetRecurrence>;
|
|
13
13
|
onEdit?: (onEdit: Partial<ProductSetRecurrence>) => void;
|
|
14
|
+
errorMessage?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const ProductSetRecurrenceControl = ({
|
|
17
18
|
menuRecurrence,
|
|
18
19
|
onEdit,
|
|
20
|
+
errorMessage,
|
|
19
21
|
}: ProductSetRecurrenceControlProps) => {
|
|
20
22
|
const { formatDate } = useIntl();
|
|
21
23
|
const { t } = useTranslation("Design");
|
|
@@ -30,7 +32,7 @@ export const ProductSetRecurrenceControl = ({
|
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
34
|
<div
|
|
33
|
-
className="sortable-tree-root"
|
|
35
|
+
className="sortable-tree-root flex-column"
|
|
34
36
|
style={{
|
|
35
37
|
transform: CSS.Translate.toString(transform),
|
|
36
38
|
transition,
|
|
@@ -84,6 +86,9 @@ export const ProductSetRecurrenceControl = ({
|
|
|
84
86
|
{getHumanReadableDate(menuRecurrence)}
|
|
85
87
|
</span>
|
|
86
88
|
</div>
|
|
89
|
+
<div className={`manual-form-error ${!errorMessage && "d-none"}`}>
|
|
90
|
+
{errorMessage}
|
|
91
|
+
</div>
|
|
87
92
|
</div>
|
|
88
93
|
);
|
|
89
94
|
};
|
|
@@ -23,13 +23,17 @@ export default {
|
|
|
23
23
|
export const Default: Story<ProductSetFormProps> = (args) => {
|
|
24
24
|
const providerHasMap = boolean("providerHasMap", true);
|
|
25
25
|
|
|
26
|
-
return
|
|
26
|
+
return (
|
|
27
|
+
<ProductSetForm {...args} providerHasMap={providerHasMap} isCreateAction />
|
|
28
|
+
);
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
export const Empty: Story<ProductSetFormProps> = (args) => {
|
|
30
32
|
const providerHasMap = boolean("providerHasMap", true);
|
|
31
33
|
|
|
32
|
-
return
|
|
34
|
+
return (
|
|
35
|
+
<ProductSetForm {...args} providerHasMap={providerHasMap} isCreateAction />
|
|
36
|
+
);
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
export const Valid: Story<ProductSetFormProps> = (args) => {
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
import { Step } from "../types";
|
|
22
22
|
import { ProductSetContextProvider, ProductSetLoadingContext } from "./context";
|
|
23
23
|
import { SelectItem } from "../../types/generic/SelectItem";
|
|
24
|
-
import { getFilteredTemplates } from "../utils";
|
|
24
|
+
import { checkAvailableTimesErrors, getFilteredTemplates } from "../utils";
|
|
25
25
|
|
|
26
26
|
export interface WithIsLoading {
|
|
27
27
|
isLoading: boolean;
|
|
@@ -86,6 +86,15 @@ export function ProductSetForm({
|
|
|
86
86
|
const { setError, reset } = form;
|
|
87
87
|
const formValues = form.watch();
|
|
88
88
|
|
|
89
|
+
const submitHandler = (onSubmit: (values: ProductSetFormValues) => void) => {
|
|
90
|
+
return (values: ProductSetFormValues) => {
|
|
91
|
+
if (checkAvailableTimesErrors({ values, setError, t })) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
onSubmit(values);
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
89
98
|
useEffect(() => {
|
|
90
99
|
if (!defaultValues || isEqual(defaultValues, formValues)) {
|
|
91
100
|
return;
|
|
@@ -130,7 +139,7 @@ export function ProductSetForm({
|
|
|
130
139
|
/>
|
|
131
140
|
|
|
132
141
|
<FormProvider {...form}>
|
|
133
|
-
<Form onSubmit={form.handleSubmit(onSubmitAndRedirect)}>
|
|
142
|
+
<Form onSubmit={form.handleSubmit(submitHandler(onSubmitAndRedirect))}>
|
|
134
143
|
<ProductSetLoadingContext.Consumer>
|
|
135
144
|
{({ isLoading: contextIsLoading }) => {
|
|
136
145
|
return (
|
|
@@ -163,7 +172,9 @@ export function ProductSetForm({
|
|
|
163
172
|
{onSubmitNoRedirect && (
|
|
164
173
|
<Button
|
|
165
174
|
className="product-set-save-btn mt-5 ml-5 d-no dne d-md-block"
|
|
166
|
-
onClick={form.handleSubmit(
|
|
175
|
+
onClick={form.handleSubmit(
|
|
176
|
+
submitHandler(onSubmitNoRedirect)
|
|
177
|
+
)}
|
|
167
178
|
disabled={
|
|
168
179
|
isLoading || contextIsLoading || !formValues.name
|
|
169
180
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { EmailTemplate } from "@licklist/core/dist/DataMapper/Notification/EmailTemplateDataMapper";
|
|
2
2
|
import { SmsTemplate } from "@licklist/core/dist/DataMapper/Notification/SmsTemplateDataMapper";
|
|
3
|
+
import { TFunction } from "i18next";
|
|
4
|
+
import { UseFormSetError } from "react-hook-form";
|
|
3
5
|
import { TemplateItem } from "../control/ProductSetControl";
|
|
6
|
+
import { ProductSetFormValues } from "../form/ProductSetForm";
|
|
7
|
+
|
|
8
|
+
interface CheckAvailableTimesErrors {
|
|
9
|
+
values: ProductSetFormValues;
|
|
10
|
+
setError: UseFormSetError<ProductSetFormValues>;
|
|
11
|
+
t: TFunction;
|
|
12
|
+
}
|
|
4
13
|
|
|
5
14
|
export const moveArrayElements = <T>(
|
|
6
15
|
array: T[],
|
|
@@ -42,3 +51,32 @@ export const getFilteredTemplates = (
|
|
|
42
51
|
label: template?.notification?.name,
|
|
43
52
|
}));
|
|
44
53
|
};
|
|
54
|
+
|
|
55
|
+
export const checkAvailableTimesErrors = ({
|
|
56
|
+
values,
|
|
57
|
+
setError,
|
|
58
|
+
t,
|
|
59
|
+
}: CheckAvailableTimesErrors) => {
|
|
60
|
+
let hasError = false;
|
|
61
|
+
|
|
62
|
+
const hasCategoryWithZone = values?.steps?.some(
|
|
63
|
+
(step) => !!step?.productCategories.some((category) => !!category?.zoneId)
|
|
64
|
+
);
|
|
65
|
+
if (!hasCategoryWithZone) {
|
|
66
|
+
return hasError;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
values?.menuRecurrences?.forEach((recurrence, index: number) => {
|
|
70
|
+
if (!recurrence?.availableTimes?.length) {
|
|
71
|
+
hasError = true;
|
|
72
|
+
setError(`menuRecurrences.${index}.availableTimes` as const, {
|
|
73
|
+
type: "validate",
|
|
74
|
+
message: t("Validation:fieldMinNumber", {
|
|
75
|
+
attribute: t("startTimes"),
|
|
76
|
+
min: 1,
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return hasError;
|
|
82
|
+
};
|
|
@@ -23,6 +23,8 @@ type AvailableTimesControlProps = {
|
|
|
23
23
|
defaultValues?: string[];
|
|
24
24
|
startTime?: string;
|
|
25
25
|
endTime?: string;
|
|
26
|
+
errorMessage?: string;
|
|
27
|
+
clearErrorMessage: () => void;
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
type AvailableTimesForm = { availableTimes: string[] };
|
|
@@ -30,91 +32,95 @@ type AvailableTimesForm = { availableTimes: string[] };
|
|
|
30
32
|
export const AvailableTimesControl = forwardRef<
|
|
31
33
|
AvailableTimesControlRef,
|
|
32
34
|
AvailableTimesControlProps
|
|
33
|
-
>(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
() => getCheckboxesByWorkHours(workHours),
|
|
52
|
-
[workHours]
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
useImperativeHandle(ref, () => {
|
|
56
|
-
return {
|
|
35
|
+
>(
|
|
36
|
+
(
|
|
37
|
+
{
|
|
38
|
+
isLoading,
|
|
39
|
+
workHours,
|
|
40
|
+
defaultValues = [],
|
|
41
|
+
errorMessage,
|
|
42
|
+
clearErrorMessage,
|
|
43
|
+
},
|
|
44
|
+
ref
|
|
45
|
+
) => {
|
|
46
|
+
const nameId = useId();
|
|
47
|
+
const { t } = useTranslation(["Design", "Validation"]);
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
register,
|
|
51
|
+
formState: { errors },
|
|
52
|
+
reset,
|
|
57
53
|
trigger,
|
|
58
54
|
getValues,
|
|
55
|
+
setValue,
|
|
56
|
+
watch,
|
|
59
57
|
setError,
|
|
58
|
+
} = useForm<AvailableTimesForm>({ mode: "onChange" });
|
|
59
|
+
|
|
60
|
+
const availableTimes = watch("availableTimes") || [];
|
|
61
|
+
|
|
62
|
+
const checkboxes = useMemo(
|
|
63
|
+
() => getCheckboxesByWorkHours(workHours),
|
|
64
|
+
[workHours]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
useImperativeHandle(ref, () => {
|
|
68
|
+
return {
|
|
69
|
+
trigger,
|
|
70
|
+
getValues,
|
|
71
|
+
setError,
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const onChange = (option: string) => {
|
|
76
|
+
const isAlreadyChecked = availableTimes.includes(option);
|
|
77
|
+
if (errorMessage) {
|
|
78
|
+
clearErrorMessage();
|
|
79
|
+
}
|
|
80
|
+
if (isAlreadyChecked) {
|
|
81
|
+
setValue(
|
|
82
|
+
"availableTimes",
|
|
83
|
+
availableTimes.filter((value) => value !== option)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setValue("availableTimes", [...availableTimes, option]);
|
|
60
90
|
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const onChange = (option: string) => {
|
|
64
|
-
const isAlreadyChecked = availableTimes.includes(option);
|
|
65
|
-
|
|
66
|
-
if (isAlreadyChecked) {
|
|
67
|
-
setValue(
|
|
68
|
-
"availableTimes",
|
|
69
|
-
availableTimes.filter((value) => value !== option)
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
setValue("availableTimes", [...availableTimes, option]);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (!defaultValues) return;
|
|
80
|
-
|
|
81
|
-
reset({ availableTimes: defaultValues });
|
|
82
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
-
}, [defaultValues]);
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<Form.Group controlId={nameId}>
|
|
87
|
-
<Form.Label>{t("Design:startTimes")}</Form.Label>
|
|
88
|
-
<div className="zone-available-times">
|
|
89
|
-
{checkboxes.map((option) => {
|
|
90
|
-
return (
|
|
91
|
-
<Form.Check key={option} inline custom id={option}>
|
|
92
|
-
<Form.Check.Input
|
|
93
|
-
type="checkbox"
|
|
94
|
-
value={option}
|
|
95
|
-
checked={availableTimes.includes(option)}
|
|
96
|
-
onChange={() => onChange(option)}
|
|
97
|
-
disabled={isLoading}
|
|
98
|
-
/>
|
|
99
|
-
<Form.Check.Label>{option}</Form.Check.Label>
|
|
100
|
-
</Form.Check>
|
|
101
|
-
);
|
|
102
|
-
})}
|
|
103
|
-
</div>
|
|
104
91
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!defaultValues) return;
|
|
94
|
+
|
|
95
|
+
reset({ availableTimes: defaultValues });
|
|
96
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
97
|
+
}, [defaultValues]);
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Form.Group controlId={nameId}>
|
|
101
|
+
<Form.Label>{t("Design:startTimes")}</Form.Label>
|
|
102
|
+
<div className="zone-available-times">
|
|
103
|
+
{checkboxes.map((option) => {
|
|
104
|
+
return (
|
|
105
|
+
<Form.Check key={option} inline custom id={option}>
|
|
106
|
+
<Form.Check.Input
|
|
107
|
+
type="checkbox"
|
|
108
|
+
value={option}
|
|
109
|
+
checked={availableTimes.includes(option)}
|
|
110
|
+
onChange={() => onChange(option)}
|
|
111
|
+
disabled={isLoading}
|
|
112
|
+
/>
|
|
113
|
+
<Form.Check.Label>{option}</Form.Check.Label>
|
|
114
|
+
</Form.Check>
|
|
115
|
+
);
|
|
116
|
+
})}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<Form.Control type="hidden" {...register("availableTimes")} />
|
|
120
|
+
<div className="manual-form-error">
|
|
121
|
+
{errors.availableTimes?.message || errorMessage}
|
|
122
|
+
</div>
|
|
123
|
+
</Form.Group>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
);
|