@teamco/ischeduler-antd 2.0.10 → 2.0.11
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["Scheduler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,YAAY,EAAmC,MAAM,MAAM,CAAC;AACjG,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,EAML,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAIjC,aAAK,eAAe,GAAG;IACrB,uDAAuD;IACvD,OAAO,EAAE,YAAY,CAAC;IACtB,4DAA4D;IAC5D,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4GAA4G;IAC5G,aAAa,EAAE,gBAAgB,CAAC;IAChC,iHAAiH;IACjH,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,aAAa,CAAC,EAAE,CAAC;IAC/C,2FAA2F;IAC3F,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,cAAc,CAAC,EAAE,CAAC;IAChD,uCAAuC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["Scheduler.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,YAAY,EAAmC,MAAM,MAAM,CAAC;AACjG,OAAO,KAAuC,MAAM,OAAO,CAAC;AAW5D,OAAO,EAML,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,yBAAyB,CAAC;AAIjC,aAAK,eAAe,GAAG;IACrB,uDAAuD;IACvD,OAAO,EAAE,YAAY,CAAC;IACtB,4DAA4D;IAC5D,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,0EAA0E;IAC1E,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4GAA4G;IAC5G,aAAa,EAAE,gBAAgB,CAAC;IAChC,iHAAiH;IACjH,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,aAAa,CAAC,EAAE,CAAC;IAC/C,2FAA2F;IAC3F,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,cAAc,CAAC,EAAE,CAAC;IAChD,uCAAuC;IACvC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoO/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulersList.d.ts","sourceRoot":"","sources":["SchedulersList.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAWjD,OAAO,EAML,gBAAgB,EAChB,SAAS,EAEV,MAAM,yBAAyB,CAAC;AAKjC,oBAAY,mBAAmB,GAAG;IAChC,0EAA0E;IAC1E,IAAI,EAAE,gBAAgB,CAAC;IACvB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,OAAO,SAAS,CAAC;IAClC,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,KAAG,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"SchedulersList.d.ts","sourceRoot":"","sources":["SchedulersList.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAWjD,OAAO,EAML,gBAAgB,EAChB,SAAS,EAEV,MAAM,yBAAyB,CAAC;AAKjC,oBAAY,mBAAmB,GAAG;IAChC,0EAA0E;IAC1E,IAAI,EAAE,gBAAgB,CAAC;IACvB,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,OAAO,SAAS,CAAC;IAClC,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,mBAAmB,KAAG,MAAM,GAAG,QAkMpE,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@teamco/ischeduler-core`),u=require(`antd`),d=require(`react`);d=c(d);let f=require(`react/jsx-runtime`),p=require(`@ant-design/icons`),m=require(`dayjs`);m=c(m);var h=e=>{let{t}=(0,l.useSchedulerContext)(),{min:n=1,label:r,disabled:i,durationTypes:a=[],required:o,prefix:s=[],exclude:c=[],namespace:d=l.CNsDuration,onTypeChange:p,onValueChange:m}=e;return(0,f.jsx)(u.Form.Item,{label:r,children:(0,f.jsxs)(u.Space.Compact,{style:{width:`100%`},children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(s,d,`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),o)],children:(0,f.jsx)(u.Select,{style:{width:150},disabled:i,onChange:p,options:a.filter(e=>!c.includes(e)).map((e,t)=>({key:`${e}-${t}`,value:e,label:l.EDurationTypes[e]}))})}),(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(s,d,`period`),tooltip:(0,l.requiredField)(r).message,rules:[(0,l.requiredField)(r,o)],children:(0,f.jsx)(u.InputNumber,{min:n,onChange:m,style:{width:`100%`},disabled:i,placeholder:r})})]})})},g=e=>{let{t}=(0,l.useSchedulerContext)(),{min:n=1,prefix:r=[],disabled:i=!1,required:a=!0}=e,o=t(`scheduler.occurrences`);return(0,f.jsx)(u.Form.Item,{label:o,name:(0,l.mergeNames)(r,`range`,`endReason`,`occurrences`),rules:[(0,l.requiredField)(o,a)],children:(0,f.jsx)(u.InputNumber,{min:n,style:{width:`calc(100% - 90px)`},disabled:i,placeholder:(0,l.placeholderField)(o)})})},_=c(o(((e,t)=>{(function(){"use strict";var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),v=`_checkboxWrapper_1kjv1_1`,y=`_ant-checkbox-wrapper-checked_1kjv1_21`,b=`_primary_1kjv1_25`,x=`_hide_1kjv1_33`,S={checkboxWrapper:v,"ant-checkbox-wrapper-checked":`_ant-checkbox-wrapper-checked_1kjv1_21`,antCheckboxWrapperChecked:y,primary:b,hide:x},C=e=>{let{loading:t,className:n,disabled:r,onChange:i,options:a=[],value:o=[],type:s=`primary`,behavior:c=`hide`}=e;return(0,f.jsx)(u.Checkbox.Group,{options:a,className:(0,_.default)(n,S.checkboxWrapper,S[s],S[c]),value:o,disabled:r||t,onChange:i})},w=`_scheduler_aqesn_1`,T=`_result_aqesn_4`,E=`_drawerContent_aqesn_10`,D=`_chipLabel_aqesn_13`,O=`_monthlyGridDay_aqesn_18`,k=`_monthlyGridWeek_aqesn_25`,A=`_monthsSeparator_aqesn_37`,j=`_monthWrapper_aqesn_45`,M=`_monthComponents_aqesn_50`,N=`_weekWrapper_aqesn_70`,P=`_ant-checkbox-wrapper-checked_aqesn_73`,F=`_weekDaysWrap_aqesn_88`,I=`_yearWrapper_aqesn_91`,L=`_monthsWrapper_aqesn_91`,R=`_tagsWrapper_aqesn_104`,z={scheduler:w,result:T,drawerContent:E,chipLabel:D,monthlyGridDay:O,monthlyGridWeek:k,monthsSeparator:A,monthWrapper:j,monthComponents:M,weekWrapper:N,"ant-checkbox-wrapper-checked":`_ant-checkbox-wrapper-checked_aqesn_73`,antCheckboxWrapperChecked:P,weekDaysWrap:F,yearWrapper:I,monthsWrapper:L,tagsWrapper:R},B=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{formRef:r,shortFormat:i=!0,isMultiple:a=!1,extendBy:o=[],namespaces:s=[`repeat`,`weekly`],prefix:c,disabled:p,setOccurs:m}=e,h=(0,l.mergeNames)([...c,...s],`days`),g=(0,d.useRef)([]);(0,d.useEffect)(()=>{let e=r.getFieldValue(h);Array.isArray(e)&&e.length&&(g.current=e,v())},[r]);let v=(0,d.useCallback)(()=>{let e=r.getFieldValue(c);e?.duration&&(0,l.handleDurationValueChange)({type:e.duration.type,period:e.duration.period},e,m,t)},[r,c,m,t]),y=(0,d.useMemo)(()=>Object.keys(l.EDays).map(e=>t(`scheduler.weekdays.${l.EDays[e].toLowerCase()}`)),[t]),b=(0,d.useMemo)(()=>Object.keys(l.EDays).map(e=>t(`scheduler.weekdays.short.${l.EDays[e].toLowerCase()}`)),[t]),x=e=>e.map((t,n)=>e[(n+l.CFirstDayIdx)%7]),S=x(b),w=x(y),T=(i?S:w).map((e,t)=>{let n=w[t],r=(0,l.getKeyFromEnum)(l.EDays,n);return{key:`${e}-${t}`,label:i?(0,f.jsx)(u.Tooltip,{title:w[t],children:e}):e,value:r}}),E;o.length&&(T=[...T,...o],E=z.weekDaysWrap);let D=(0,d.useCallback)(e=>{if(a)g.current=e;else{let t=g.current,n=e.filter(e=>!t.includes(e)),i=n.length?n:e;r.setFieldValue(h,i),g.current=i}v()},[a,r,h,v]);return(0,f.jsx)(`div`,{className:(0,_.default)(z.weekWrapper,E),children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.days`),name:h,rules:[(0,l.requiredField)(t(`scheduler.days`))],children:(0,f.jsx)(C,{loading:n,disabled:p,options:T,onChange:D})})})},V=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{min:r=1,max:i=31,prefix:a,disabled:o=!1,namespaces:s=[`repeat`,`monthly`],formRef:c,setOccurs:m}=e,[h,g]=(0,d.useState)(`DAY`),_=u.Form.useWatch((0,l.mergeNames)([...a,...s],`weekDay`),c),v=t(`scheduler.day`),y=(0,d.useCallback)(e=>{if(g(e),e===`DAY`){let e=c.getFieldValue(a);(0,l.handleSelectWeeklyDay)(e.duration.period,e,m,t)}},[c,a,m,g,t]);(0,d.useEffect)(()=>{let e=(0,l.mergeNames)([...a,...s],`type`);y(c.getFieldValue(e))},[c,y,a,s]);let b=(0,d.useCallback)(()=>{let e=()=>{let e=c.getFieldValue(a);(0,l.handleDurationValueChange)({type:e.duration.type,period:e.duration.period},e,m,t)};if(h!==`PERIOD`)return null;let r=[[`First`,`scheduler.day.first`],[`Second`,`scheduler.day.second`],[`Third`,`scheduler.day.third`],[`Fourth`,`scheduler.day.fourth`],[`Last`,`scheduler.day.last`]].map(([e,n])=>{let r=(0,l.getKeyFromEnum)(l.EWeekDays,e);return{value:r,label:t(n),icon:_===r?(0,f.jsx)(p.CalendarTwoTone,{}):(0,f.jsx)(p.CalendarTwoTone,{twoToneColor:`gray`})}});return(0,f.jsxs)(u.Col,{span:24,className:z.monthlyGridWeek,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`weekDay`),rules:[(0,l.requiredField)(t(`scheduler.weekday`))],children:(0,f.jsx)(u.Segmented,{disabled:n||o,onChange:e,options:r.map(({value:e,label:t,icon:r})=>({label:t,value:e,icon:r,disabled:o||n}))})}),(0,f.jsx)(B,{formRef:c,prefix:a,isMultiple:!0,disabled:o||n,extendBy:[{key:`extend-day`,label:t(`scheduler.day`),value:`DAY`},{key:`extend-weekday`,label:t(`scheduler.weekday`),value:`WEEKDAY`},{key:`extend-weekend`,label:t(`scheduler.weekend`),value:`WEEKEND`}],setOccurs:m})]})},[_,o,c,n,h,s,a,m,t]),x=()=>h===`DAY`?(0,f.jsx)(u.Col,{span:12,className:z.monthlyGridDay,children:(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`monthDay`),hasFeedback:!0,rules:[(0,l.requiredField)(t(`scheduler.days`))],children:(0,f.jsx)(u.InputNumber,{style:{width:120},min:r,max:i,onChange:e=>{let n=c.getFieldValue(a);e&&(0,l.handleSelectWeeklyDay)(e,n,m,t)},disabled:o||n,placeholder:v})})}):null;return(0,f.jsxs)(`div`,{className:z.monthWrapper,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.period`))],children:(0,f.jsx)(u.Segmented,{disabled:o||n,onChange:e=>{y(e)},options:[{value:`DAY`,icon:h===`DAY`?(0,f.jsx)(p.CalendarTwoTone,{}):(0,f.jsx)(p.CalendarTwoTone,{twoToneColor:`gray`}),label:t(`scheduler.day`)},{value:`PERIOD`,icon:h===`PERIOD`?(0,f.jsx)(p.ControlTwoTone,{}):(0,f.jsx)(p.ControlTwoTone,{twoToneColor:`gray`}),label:t(`scheduler.meta.period`)}]})}),(0,f.jsxs)(u.Row,{className:z.monthComponents,children:[x(),b()]})]})},H=e=>{let{disabled:t,prefix:n}=e,{t:r}=(0,l.useSchedulerContext)(),i=u.Form.useWatch((0,l.mergeNames)(n,`range`,`startedAt`)),a={format:l.DEFAULT_DATE_TIME_FORMAT,showTime:!0,disabledDate:e=>{if(!i)return(0,l.getDisabledDate)(e);let t=(0,m.default)(i).add(1,`day`).startOf(`day`);return e&&e.isBefore(t)},disabled:t||!i},o=r(`scheduler.duration.endDate`);return(0,f.jsx)(u.Form.Item,{label:o,name:(0,l.mergeNames)(n,`range`,`endReason`,`expiredAt`),rules:[(0,l.requiredField)(o,!0)],children:(0,f.jsx)(u.DatePicker,{...a})})},U=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{shortFormat:r=!0,isMultiple:i=!1,setOccurs:a,formRef:o,prefix:s,namespaces:c=[`repeat`,`yearly`],disabled:p}=e,[m,h]=(0,d.useState)([]),g=(0,l.mergeNames)([...s,...c],`months`),_=(0,d.useMemo)(()=>Object.keys(l.EMonths).map(e=>t(`scheduler.months.${l.EMonths[e].toLowerCase()}`)),[t]),v=(0,d.useMemo)(()=>Object.keys(l.EMonths).map(e=>t(`scheduler.months.short.${l.EMonths[e].toLowerCase()}`)),[t]);(0,d.useEffect)(()=>{let e=o.getFieldValue(g);e&&b(e)},[o]);let y=Object.keys(l.EMonths).map((e,t)=>({key:`${e}-${t}`,label:r?(0,f.jsx)(u.Tooltip,{title:_[t],children:v[t]}):_[t],value:e})),b=e=>{let n=[...e];n.length?i||(n=e.filter(e=>!m.includes(e))):n=m,h(n),(0,l.setNestedDynamicFields)(o,g.join(`.`),n);let r=o.getFieldValue(s);(0,l.handleDurationValueChange)({type:r.duration.type,period:r.duration.period},r,a,t)};return(0,f.jsxs)(`div`,{className:z.yearWrapper,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:g,rules:[(0,l.requiredField)(t(`scheduler.months`))],children:(0,f.jsx)(C,{options:y,disabled:p,className:z.monthsWrapper,loading:n,onChange:b,value:m})}),(0,f.jsx)(V,{formRef:o,prefix:s,disabled:p,setOccurs:a})]})},W=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{formRef:r,prefix:i,entity:a,onFinish:o,setDirty:s,disabled:c=!1,durationTypes:p=[],discountTypes:m=[],readOnlyFields:_=[],schedulerType:v}=e,[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(null),[C,w]=(0,d.useState)(null),[T,E]=(0,d.useState)(null),[D,O]=(0,d.useState)(`0`),k=r.getFieldValue(i),A=v===l.ESchedulerPrefix.SALE?l.DEFAULT_SALE_SCHEDULER:l.DEFAULT_DISCOUNT_SCHEDULER;(0,d.useEffect)(()=>{r.resetFields()},[r]),(0,d.useEffect)(()=>{if(a&&a.id!==T){let e={},t=e;for(let e=0;e<i.length-1;e++)t[i[e]]={},t=t[i[e]];t[i[i.length-1]]=a,r.setFieldsValue(e),E(a.id??null)}},[a,r,T,i]),(0,d.useEffect)(()=>{let e=r.getFieldValue((0,l.mergeNames)(i,l.CNsDuration,`type`)),n=r.getFieldValue((0,l.mergeNames)(i,l.CNsDuration,`period`)),o=r.getFieldValue((0,l.mergeNames)(i,`range`,`startedAt`));o&&(0,l.handleChangeStartDate)(o,w),S(e),e&&n&&(0,l.handleDurationValueChange)({type:e,period:n},a??A,O,t),b(r.getFieldValue((0,l.mergeNames)(i,`range`,`endReason`,`type`)))},[A,a,r,i,t]);let j=(0,d.useMemo)(()=>{let e={},t=e;for(let e=0;e<i.length-1;e++)t[i[e]]={},t=t[i[e]];return t[i[i.length-1]]=A,e},[A,i]);return(0,f.jsx)(u.Space,{children:(0,f.jsxs)(u.Form,{layout:`vertical`,autoComplete:`off`,form:r,className:z.scheduler,onFinish:o,onFieldsChange:()=>s(!0),initialValues:j,children:[[l.ESchedulerPrefix.DISCOUNT,l.ESchedulerPrefix.TRIAL_DISCOUNT].includes(v)&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.meta.duration`),children:(0,f.jsxs)(u.Space.Compact,{children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(i,l.CNsDiscount,`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),!0)],children:(0,f.jsx)(u.Select,{style:{width:150},disabled:c||n,options:m.sort().map((e,t)=>({key:t,label:l.EDiscountType[e],value:e}))})}),(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(i,l.CNsDiscount,`value`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),!0)],children:(0,f.jsx)(u.InputNumber,{min:1,style:{width:`100%`},readOnly:(0,l.isReadOnlyField)((0,l.mergeNames)(null,l.CNsDiscount,`value`).join(`.`),_),disabled:c||n})})]})})})}),(0,f.jsxs)(u.Row,{gutter:[24,24],children:[(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(h,{label:t(`scheduler.duration`),disabled:c||n,onTypeChange:e=>{S(e);let n=k?.duration?.period;n!=null&&(0,l.handleDurationValueChange)({type:e,period:n},k,O,t)},onValueChange:e=>{let n=k?.duration?.type;e&&n&&(0,l.handleDurationValueChange)({type:n,period:e},k,O,t)},prefix:i,namespace:l.CNsDuration,required:!0,durationTypes:p})}),(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.startedAt`),name:(0,l.mergeNames)(i,`range`,`startedAt`),rules:[(0,l.requiredField)(t(`scheduler.startedAt`))],children:(0,f.jsx)(u.DatePicker,{onChange:e=>e&&(0,l.handleChangeStartDate)(e,w),showTime:!0,format:l.DEFAULT_DATE_TIME_FORMAT,disabledDate:e=>(0,l.getDisabledDate)(e),disabled:c||n})})})]}),x===`WEEK`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(B,{prefix:i,isMultiple:!0,formRef:r,setOccurs:O,disabled:c})})}),x===`MONTH`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(V,{formRef:r,prefix:i,disabled:c,setOccurs:O})})}),x===`YEAR`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(U,{formRef:r,prefix:i,disabled:c,setOccurs:O})})}),(0,f.jsxs)(u.Row,{gutter:[24,24],children:[(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.duration.end`),name:(0,l.mergeNames)(i,`range`,`endReason`,`type`),rules:[(0,l.requiredField)(t(`scheduler.duration.end`))],children:(0,f.jsx)(u.Select,{disabled:c,onChange:e=>b(e),options:[t(`scheduler.duration.end.day`),t(`scheduler.duration.end.after`),t(`scheduler.duration.end.no`)].map((e,t)=>({key:t,label:e,value:l.CEndReasonTypes[t]}))})})}),(0,f.jsxs)(u.Col,{span:12,children:[y===l.CEndReasonTypes[0]&&(0,f.jsx)(H,{prefix:i,disabled:c}),y===l.CEndReasonTypes[1]&&(0,f.jsx)(g,{prefix:i,disabled:c})]})]}),(0,f.jsx)(`span`,{className:z.result,dangerouslySetInnerHTML:{__html:t(`scheduler.result`,{occurs:D,startAt:C??``})}})]})})},G=e=>{let{t,permissions:n}=(0,l.useSchedulerContext)(),{formRef:r,loading:i,className:a,isEdit:o,disabled:s,size:c=`small`,color:d=`primary`,icon:m=(0,f.jsx)(p.SaveOutlined,{}),htmlType:h=`submit`,variant:g=`solid`,onClick:_,danger:v=!1}=e;return(o?n.canUpdate:n.canCreate)?(0,f.jsx)(u.Button,{size:c,variant:g,htmlType:h,className:a,disabled:s,loading:i,icon:m,danger:v,onClick:e=>{e.preventDefault(),r&&h===`submit`&&r.submit(),_?.()},color:d,children:t(o?`actions.update`:`actions.save`)}):null},K=({schedulerType:e,disabled:t,onSuccess:n,setDirty:r,dirty:i,isCreating:a,setIsCreating:o,buttonProps:s})=>{let{t:c,loading:m,permissions:h,onCreate:g}=(0,l.useSchedulerContext)(),[_]=u.Form.useForm(),[v,y]=(0,d.useState)(!1),b=(0,d.useMemo)(()=>[l.CScheduler,e],[e]),x=(0,d.useMemo)(()=>Object.keys(l.EDurationTypes),[]),S=(0,d.useMemo)(()=>Object.keys(l.EDiscountType),[]);if(!h.canCreate)return null;let C=async()=>{try{o(!0),await _.validateFields();let t=_.getFieldValue(b),i={id:`new-${Date.now()}`,...t,type:e,[l.CNsDiscount]:e===l.ESchedulerPrefix.SALE?null:t?.[l.CNsDiscount]};g&&await g(e,i),n?.(i),y(!1),r(!1),_.resetFields()}catch{}finally{o(!1)}};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.Button,{style:{padding:0},color:`default`,variant:`link`,...s,disabled:t||m,onClick:e=>{e.preventDefault(),e.stopPropagation(),y(!0)},children:(0,f.jsx)(u.Tooltip,{title:t?c(`scheduler.limited`,{limit:l.DEFAULT_SCHEDULERS_LIMIT}):void 0,children:c(`scheduler`)})}),(0,f.jsx)(u.Drawer,{title:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,f.jsx)(p.ScheduleTwoTone,{}),c(`scheduler`)]}),size:600,open:v,onClose:()=>y(!1),extra:(0,f.jsx)(G,{size:`small`,loading:m||a,disabled:t||!i,onClick:C}),children:(0,f.jsx)(W,{setDirty:r,formRef:_,prefix:b,schedulerType:e,durationTypes:x,discountTypes:S,disabled:t})})]})},q=e=>{let{t}=(0,l.useSchedulerContext)(),{selectedColumns:n=[],columnsList:r=[],onChange:i}=e;if(!r?.length)return(0,f.jsx)(f.Fragment,{});let a=t(`table.hideColumns`),o={mode:`multiple`,style:{minWidth:250},options:[{label:(0,f.jsx)(`span`,{children:a}),title:a,options:r}],placeholder:a,maxTagCount:`responsive`},s=e=>{e.length<1||i?.(e)};return(0,f.jsx)(u.Select,{...o,value:n,onChange:s})},J=e=>{let{loading:t,t:n}=(0,l.useSchedulerContext)(),{children:r,items:i=[],size:a=`middle`,onRefresh:o}=e,s=o?[{key:`refresh`,label:n(`toolbar.refresh`),icon:(0,f.jsx)(p.ReloadOutlined,{}),onClick:o}]:[];return i?.length&&(s=i.concat([{type:`divider`},...s])),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:8},children:[r||null,(0,f.jsx)(u.Dropdown,{menu:{items:s},trigger:[`click`],children:(0,f.jsx)(u.Button,{loading:t,size:a,color:`default`,variant:`filled`,icon:(0,f.jsx)(p.MoreOutlined,{}),type:`primary`})})]})},Y=e=>{let{t,loading:n,permissions:r}=(0,l.useSchedulerContext)(),{entity:i,icon:a,type:o=`primary`,showLabel:s=!1,disabled:c,onDelete:d}=e;return!i||!r.canDelete?null:(0,f.jsx)(u.Popconfirm,{title:t(`actions.confirm.delete`),onConfirm:()=>d?.(i),okText:t(`actions.delete`),cancelText:t(`actions.cancel`),children:(0,f.jsx)(u.Tooltip,{title:t(`actions.delete`),children:(0,f.jsx)(u.Button,{disabled:c||!r.canDelete,loading:n,danger:!0,type:o,icon:a||(0,f.jsx)(p.DeleteTwoTone,{twoToneColor:`#eb2f96`}),children:s&&t(`actions.delete`)})})})},X=e=>{let{t,loading:n,permissions:r}=(0,l.useSchedulerContext)(),{entity:i,type:a=`primary`,showLabel:o=!1,onEdit:s}=e;return!i||!r.canUpdate?null:(0,f.jsx)(u.Button,{disabled:!r.canUpdate,loading:n,type:a,icon:(0,f.jsx)(p.EditTwoTone,{twoToneColor:l.COLORS.success}),onClick:()=>s?.(i),children:o&&t(`actions.edit`)})},ee=e=>(0,f.jsx)(`div`,{className:z.tagsWrapper,children:e?.days.map((e,t)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.volcano,children:e},t))}),Z=(e,t)=>e?.type===`PERIOD`?(0,f.jsx)(`div`,{className:z.tagsWrapper,children:t?.days.map((t,n)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.cyan,children:`${e.weekDay} ${t}`},n))}):(0,f.jsx)(`div`,{className:z.tagsWrapper,children:(0,f.jsx)(u.Tag,{color:l.COLORS.tags.gold,children:e?.monthDay},`monthDay`)}),te=(e,t,n)=>(0,f.jsxs)(f.Fragment,{children:[Z(t,n),(0,f.jsx)(`div`,{className:z.tagsWrapper,children:e?.months?.map((e,t)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.magenta,children:e},t))})]}),ne=({status:e})=>{switch(e){case l.EStatus.ACTIVE:return(0,f.jsx)(u.Tag,{color:`success`,icon:(0,f.jsx)(p.CheckCircleOutlined,{}),children:e});case l.EStatus.PROCESSING:return(0,f.jsx)(u.Tag,{color:`processing`,icon:(0,f.jsx)(p.SyncOutlined,{spin:!0}),children:e});case l.EStatus.DEACTIVATED:return(0,f.jsx)(u.Tag,{color:`default`,icon:(0,f.jsx)(p.MinusCircleOutlined,{}),children:e});default:return(0,f.jsx)(u.Tag,{color:`default`,children:e})}},Q=e=>e.map((e,t)=>({...e,idx:t+1,key:e.id})),$={key:`idx`,title:(0,f.jsx)(p.FieldNumberOutlined,{}),dataIndex:`idx`,rowScope:`row`,width:70,fixed:`left`,align:`center`},re=(e=100,t=`Actions`)=>({title:t,key:`operation`,fixed:`right`,align:`center`,width:e}),ie=(e,t=[])=>{let{disabled:n,schedulerType:r,currency:i,t:a,onEdit:o,onDelete:s}=e,c=o||s?{title:a(`table.actions`),key:`operation`,fixed:`right`,align:`center`,width:100,render:(e,t)=>(0,f.jsxs)(`div`,{children:[o&&(0,f.jsx)(X,{onEdit:o,disabled:n,type:`text`,entity:t}),s&&(0,f.jsx)(Y,{onDelete:s,icon:(0,f.jsx)(p.DeleteTwoTone,{twoToneColor:`#eb2f96`}),type:`text`,entity:t,disabled:n})]})}:null,u=[l.ESchedulerPrefix.DISCOUNT,l.ESchedulerPrefix.TRIAL_DISCOUNT].includes(r)?{title:a(`scheduler.meta.duration`),dataIndex:`discount`,key:`discount`,width:150,render(e){return e?e.type===`PERCENT`?`${e.value}${l.CDiscountTypeValues[e.type]}`:(0,l.numberToCurrency)(e.value,i??`USD`):`—`}}:null,d=[$,{title:a(`scheduler.meta.duration`),dataIndex:`duration`,key:`duration`,width:150,render(e){return`${e?.period} (${e?.type})`}},{title:a(`scheduler.duration`),key:`repeat`,render(e,t){let{duration:n,repeat:r}=t,{weekly:i,monthly:a,yearly:o}=r;switch(n?.type){case`WEEK`:return ee(i);case`MONTH`:return Z(a,i);case`YEAR`:return te(o,a,i);default:return(0,f.jsx)(f.Fragment,{})}}},u,{title:a(`scheduler.status`),dataIndex:`status`,key:`status`,width:150,align:`center`,concealable:!0,render:e=>(0,f.jsx)(ne,{status:e})},{title:a(`scheduler.updatedAt`),width:200,dataIndex:`metadata`,align:`center`,key:`metadata.updatedAt`,concealable:!0,render:e=>(0,f.jsx)(`div`,{children:e?.updatedAt?(0,l.tsToLocaleDateTime)(e.updatedAt):`—`})},c].filter(Boolean);return t.length?d.filter(e=>t.includes(e?.dataIndex)||e.dataIndex===`idx`):d},ae=e=>{let{type:t,title:n,disabled:r,readOnlyFields:i=[],currency:a,onRefresh:o}=e,{schedulers:s,loading:c,disabled:m,t:h,permissions:g,onUpdate:_,onDelete:v}=(0,l.useSchedulerContext)(),y=r??m,b=s[t]??[],[x,S]=(0,d.useState)(new Set),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(!1),D=(0,d.useMemo)(()=>x.size===0?b:b.filter(e=>!e.id||!x.has(e.id)),[b,x]),O=D.length>=l.DEFAULT_SCHEDULERS_LIMIT,[k]=u.Form.useForm(),[A,j]=(0,d.useState)(!1),[M,N]=(0,d.useState)(null),P=(0,d.useMemo)(()=>[l.CScheduler,t],[t]),F=(0,d.useMemo)(()=>Object.keys(l.EDurationTypes),[]),I=(0,d.useMemo)(()=>Object.keys(l.EDiscountType),[]),L=e=>{N(e),j(!0)},R=async()=>{try{await k.validateFields();let e=k.getFieldValue(P),n={...M,...e,type:t,[l.CNsDiscount]:t===l.ESchedulerPrefix.SALE?null:e?.[l.CNsDiscount]};_&&await _(t,n),j(!1),N(null),w(!1),k.resetFields(),o?.()}catch{}},{filteredColumns:B,columnsList:V,selectedColumns:H,setSelectedColumns:U}=(0,l.useColumnsToggle)(ie({disabled:y,schedulerType:t,entities:D,currency:a,t:h,onEdit:g.canUpdate?L:void 0,onDelete:g.canDelete?async e=>{if(e.id?.startsWith(`new-`)){S(t=>{let n=new Set(t);return e.id&&n.add(e.id),n});return}v&&e.id?(await v(t,e.id),o?.()):console.warn(`No onDelete handler provided`)}:void 0}));return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.Table,{columns:B,loading:c,scroll:{x:1e3},bordered:!0,className:z.gridList,dataSource:Q(D),rowKey:e=>e.id??`row-${Math.random()}`,title:()=>(0,f.jsx)(`div`,{className:z.gridHeader,children:(0,f.jsx)(J,{onRefresh:o,items:g.canCreate&&!O?[{label:(0,f.jsx)(K,{setDirty:w,dirty:C,isCreating:T,setIsCreating:E,schedulerType:t,disabled:y||c||O||T,onSuccess:()=>o?.()}),icon:(0,f.jsx)(p.PlusOutlined,{})}]:[],children:(0,f.jsx)(q,{columnsList:V,selectedColumns:H,onChange:U})})}),footer:()=>(0,f.jsx)(`div`,{className:z.gridFooter,children:`Total ${D.length} items`})}),(0,f.jsx)(u.Drawer,{title:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,f.jsx)(p.ScheduleTwoTone,{}),n??h(`scheduler`)]}),size:600,open:A,onClose:()=>{j(!1),N(null)},extra:(0,f.jsx)(G,{size:`small`,isEdit:!!M,loading:c,disabled:y||!C||T,onClick:R}),children:A&&(0,f.jsx)(W,{setDirty:w,formRef:k,prefix:P,entity:M,schedulerType:t,durationTypes:F,discountTypes:I,disabled:y,readOnlyFields:i})})]})};exports.Scheduler=W,exports.SchedulerDrawerButton=K,exports.SchedulersList=ae,exports.actionField=re,exports.indexColumn=$,exports.indexable=Q,Object.keys(l).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return l[e]}})});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@teamco/ischeduler-core`),u=require(`antd`),d=require(`react`);d=c(d);let f=require(`react/jsx-runtime`),p=require(`@ant-design/icons`),m=require(`dayjs`);m=c(m);var h=e=>{let{t}=(0,l.useSchedulerContext)(),{min:n=1,label:r,disabled:i,durationTypes:a=[],required:o,prefix:s=[],exclude:c=[],namespace:d=l.CNsDuration,onTypeChange:p,onValueChange:m}=e;return(0,f.jsx)(u.Form.Item,{label:r,children:(0,f.jsxs)(u.Space.Compact,{style:{width:`100%`},children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(s,d,`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),o)],children:(0,f.jsx)(u.Select,{style:{width:150},disabled:i,onChange:p,options:a.filter(e=>!c.includes(e)).map((e,t)=>({key:`${e}-${t}`,value:e,label:l.EDurationTypes[e]}))})}),(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(s,d,`period`),tooltip:(0,l.requiredField)(r).message,rules:[(0,l.requiredField)(r,o)],children:(0,f.jsx)(u.InputNumber,{min:n,onChange:m,style:{width:`100%`},disabled:i,placeholder:r})})]})})},g=e=>{let{t}=(0,l.useSchedulerContext)(),{min:n=1,prefix:r=[],disabled:i=!1,required:a=!0}=e,o=t(`scheduler.occurrences`);return(0,f.jsx)(u.Form.Item,{label:o,name:(0,l.mergeNames)(r,`range`,`endReason`,`occurrences`),rules:[(0,l.requiredField)(o,a)],children:(0,f.jsx)(u.InputNumber,{min:n,style:{width:`calc(100% - 90px)`},disabled:i,placeholder:(0,l.placeholderField)(o)})})},_=c(o(((e,t)=>{(function(){"use strict";var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),v=`_checkboxWrapper_1kjv1_1`,y=`_ant-checkbox-wrapper-checked_1kjv1_21`,b=`_primary_1kjv1_25`,x=`_hide_1kjv1_33`,S={checkboxWrapper:v,"ant-checkbox-wrapper-checked":`_ant-checkbox-wrapper-checked_1kjv1_21`,antCheckboxWrapperChecked:y,primary:b,hide:x},C=e=>{let{loading:t,className:n,disabled:r,onChange:i,options:a=[],value:o=[],type:s=`primary`,behavior:c=`hide`}=e;return(0,f.jsx)(u.Checkbox.Group,{options:a,className:(0,_.default)(n,S.checkboxWrapper,S[s],S[c]),value:o,disabled:r||t,onChange:i})},w=`_scheduler_aqesn_1`,T=`_result_aqesn_4`,E=`_drawerContent_aqesn_10`,D=`_chipLabel_aqesn_13`,O=`_monthlyGridDay_aqesn_18`,k=`_monthlyGridWeek_aqesn_25`,A=`_monthsSeparator_aqesn_37`,j=`_monthWrapper_aqesn_45`,M=`_monthComponents_aqesn_50`,N=`_weekWrapper_aqesn_70`,P=`_ant-checkbox-wrapper-checked_aqesn_73`,F=`_weekDaysWrap_aqesn_88`,I=`_yearWrapper_aqesn_91`,L=`_monthsWrapper_aqesn_91`,R=`_tagsWrapper_aqesn_104`,z={scheduler:w,result:T,drawerContent:E,chipLabel:D,monthlyGridDay:O,monthlyGridWeek:k,monthsSeparator:A,monthWrapper:j,monthComponents:M,weekWrapper:N,"ant-checkbox-wrapper-checked":`_ant-checkbox-wrapper-checked_aqesn_73`,antCheckboxWrapperChecked:P,weekDaysWrap:F,yearWrapper:I,monthsWrapper:L,tagsWrapper:R},B=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{formRef:r,shortFormat:i=!0,isMultiple:a=!1,extendBy:o=[],namespaces:s=[`repeat`,`weekly`],prefix:c,disabled:p,setOccurs:m}=e,h=(0,l.mergeNames)([...c,...s],`days`),g=(0,d.useRef)([]);(0,d.useEffect)(()=>{let e=r.getFieldValue(h);Array.isArray(e)&&e.length&&(g.current=e,v())},[r]);let v=(0,d.useCallback)(()=>{let e=r.getFieldValue(c);e?.duration&&(0,l.handleDurationValueChange)({type:e.duration.type,period:e.duration.period},e,m,t)},[r,c,m,t]),y=(0,d.useMemo)(()=>Object.keys(l.EDays).map(e=>t(`scheduler.weekdays.${l.EDays[e].toLowerCase()}`)),[t]),b=(0,d.useMemo)(()=>Object.keys(l.EDays).map(e=>t(`scheduler.weekdays.short.${l.EDays[e].toLowerCase()}`)),[t]),x=e=>e.map((t,n)=>e[(n+l.CFirstDayIdx)%7]),S=x(b),w=x(y),T=(i?S:w).map((e,t)=>{let n=w[t],r=(0,l.getKeyFromEnum)(l.EDays,n);return{key:`${e}-${t}`,label:i?(0,f.jsx)(u.Tooltip,{title:w[t],children:e}):e,value:r}}),E;o.length&&(T=[...T,...o],E=z.weekDaysWrap);let D=(0,d.useCallback)(e=>{if(a)g.current=e;else{let t=g.current,n=e.filter(e=>!t.includes(e)),i=n.length?n:e;r.setFieldValue(h,i),g.current=i}v()},[a,r,h,v]);return(0,f.jsx)(`div`,{className:(0,_.default)(z.weekWrapper,E),children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.days`),name:h,rules:[(0,l.requiredField)(t(`scheduler.days`))],children:(0,f.jsx)(C,{loading:n,disabled:p,options:T,onChange:D})})})},V=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{min:r=1,max:i=31,prefix:a,disabled:o=!1,namespaces:s=[`repeat`,`monthly`],formRef:c,setOccurs:m}=e,[h,g]=(0,d.useState)(`DAY`),_=u.Form.useWatch((0,l.mergeNames)([...a,...s],`weekDay`),c),v=t(`scheduler.day`),y=(0,d.useCallback)(e=>{if(g(e),e===`DAY`){let e=c.getFieldValue(a);(0,l.handleSelectWeeklyDay)(e.duration.period,e,m,t)}},[c,a,m,g,t]);(0,d.useEffect)(()=>{let e=(0,l.mergeNames)([...a,...s],`type`);y(c.getFieldValue(e))},[c,y,a,s]);let b=(0,d.useCallback)(()=>{let e=()=>{let e=c.getFieldValue(a);(0,l.handleDurationValueChange)({type:e.duration.type,period:e.duration.period},e,m,t)};if(h!==`PERIOD`)return null;let r=[[`First`,`scheduler.day.first`],[`Second`,`scheduler.day.second`],[`Third`,`scheduler.day.third`],[`Fourth`,`scheduler.day.fourth`],[`Last`,`scheduler.day.last`]].map(([e,n])=>{let r=(0,l.getKeyFromEnum)(l.EWeekDays,e);return{value:r,label:t(n),icon:_===r?(0,f.jsx)(p.CalendarTwoTone,{}):(0,f.jsx)(p.CalendarTwoTone,{twoToneColor:`gray`})}});return(0,f.jsxs)(u.Col,{span:24,className:z.monthlyGridWeek,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`weekDay`),rules:[(0,l.requiredField)(t(`scheduler.weekday`))],children:(0,f.jsx)(u.Segmented,{disabled:n||o,onChange:e,options:r.map(({value:e,label:t,icon:r})=>({label:t,value:e,icon:r,disabled:o||n}))})}),(0,f.jsx)(B,{formRef:c,prefix:a,isMultiple:!0,disabled:o||n,extendBy:[{key:`extend-day`,label:t(`scheduler.day`),value:`DAY`},{key:`extend-weekday`,label:t(`scheduler.weekday`),value:`WEEKDAY`},{key:`extend-weekend`,label:t(`scheduler.weekend`),value:`WEEKEND`}],setOccurs:m})]})},[_,o,c,n,h,s,a,m,t]),x=()=>h===`DAY`?(0,f.jsx)(u.Col,{span:12,className:z.monthlyGridDay,children:(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`monthDay`),hasFeedback:!0,rules:[(0,l.requiredField)(t(`scheduler.days`))],children:(0,f.jsx)(u.InputNumber,{style:{width:120},min:r,max:i,onChange:e=>{let n=c.getFieldValue(a);e&&(0,l.handleSelectWeeklyDay)(e,n,m,t)},disabled:o||n,placeholder:v})})}):null;return(0,f.jsxs)(`div`,{className:z.monthWrapper,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)([...a,...s],`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.period`))],children:(0,f.jsx)(u.Segmented,{disabled:o||n,onChange:e=>{y(e)},options:[{value:`DAY`,icon:h===`DAY`?(0,f.jsx)(p.CalendarTwoTone,{}):(0,f.jsx)(p.CalendarTwoTone,{twoToneColor:`gray`}),label:t(`scheduler.day`)},{value:`PERIOD`,icon:h===`PERIOD`?(0,f.jsx)(p.ControlTwoTone,{}):(0,f.jsx)(p.ControlTwoTone,{twoToneColor:`gray`}),label:t(`scheduler.meta.period`)}]})}),(0,f.jsxs)(u.Row,{className:z.monthComponents,children:[x(),b()]})]})},H=e=>{let{disabled:t,prefix:n}=e,{t:r}=(0,l.useSchedulerContext)(),i=u.Form.useWatch((0,l.mergeNames)(n,`range`,`startedAt`)),a={format:l.DEFAULT_DATE_TIME_FORMAT,showTime:!0,disabledDate:e=>{if(!i)return(0,l.getDisabledDate)(e);let t=(0,m.default)(i).add(1,`day`).startOf(`day`);return e&&e.isBefore(t)},disabled:t||!i},o=r(`scheduler.duration.endDate`);return(0,f.jsx)(u.Form.Item,{label:o,name:(0,l.mergeNames)(n,`range`,`endReason`,`expiredAt`),rules:[(0,l.requiredField)(o,!0)],children:(0,f.jsx)(u.DatePicker,{...a})})},U=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{shortFormat:r=!0,isMultiple:i=!1,setOccurs:a,formRef:o,prefix:s,namespaces:c=[`repeat`,`yearly`],disabled:p}=e,[m,h]=(0,d.useState)([]),g=(0,l.mergeNames)([...s,...c],`months`),_=(0,d.useMemo)(()=>Object.keys(l.EMonths).map(e=>t(`scheduler.months.${l.EMonths[e].toLowerCase()}`)),[t]),v=(0,d.useMemo)(()=>Object.keys(l.EMonths).map(e=>t(`scheduler.months.short.${l.EMonths[e].toLowerCase()}`)),[t]);(0,d.useEffect)(()=>{let e=o.getFieldValue(g);e&&b(e)},[o]);let y=Object.keys(l.EMonths).map((e,t)=>({key:`${e}-${t}`,label:r?(0,f.jsx)(u.Tooltip,{title:_[t],children:v[t]}):_[t],value:e})),b=e=>{let n=[...e];n.length?i||(n=e.filter(e=>!m.includes(e))):n=m,h(n),(0,l.setNestedDynamicFields)(o,g.join(`.`),n);let r=o.getFieldValue(s);(0,l.handleDurationValueChange)({type:r.duration.type,period:r.duration.period},r,a,t)};return(0,f.jsxs)(`div`,{className:z.yearWrapper,children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:g,rules:[(0,l.requiredField)(t(`scheduler.months`))],children:(0,f.jsx)(C,{options:y,disabled:p,className:z.monthsWrapper,loading:n,onChange:b,value:m})}),(0,f.jsx)(V,{formRef:o,prefix:s,disabled:p,setOccurs:a})]})},W=e=>{let{t,loading:n}=(0,l.useSchedulerContext)(),{formRef:r,prefix:i,entity:a,onFinish:o,setDirty:s,disabled:c=!1,durationTypes:p=[],discountTypes:m=[],readOnlyFields:_=[],schedulerType:v}=e,[y,b]=(0,d.useState)(null),[x,S]=(0,d.useState)(`0`),C=u.Form.useWatch(i,r),w=v===l.ESchedulerPrefix.SALE?l.DEFAULT_SALE_SCHEDULER:l.DEFAULT_DISCOUNT_SCHEDULER;(0,d.useEffect)(()=>{if(a){let e={},t=e;for(let e=0;e<i.length-1;e++)t[i[e]]={},t=t[i[e]];t[i[i.length-1]]=a,r.setFieldsValue(e)}else r.resetFields()},[a,r,i]),(0,d.useEffect)(()=>{if(!C)return;let e=C.range?.startedAt;e&&(0,l.handleChangeStartDate)(e,b);let n=C.duration;n?.type&&n?.period&&(0,l.handleDurationValueChange)(n,C,S,t)},[C,t]);let T=C?.range?.endReason?.type,E=C?.duration?.type,D=(0,d.useMemo)(()=>{let e={},t=e;for(let e=0;e<i.length-1;e++)t[i[e]]={},t=t[i[e]];return t[i[i.length-1]]=w,e},[w,i]);return(0,f.jsx)(u.Space,{orientation:`vertical`,style:{width:`100%`},children:(0,f.jsxs)(u.Form,{layout:`vertical`,autoComplete:`off`,form:r,className:z.scheduler,onFinish:o,onFieldsChange:()=>s(!0),initialValues:D,children:[[l.ESchedulerPrefix.DISCOUNT,l.ESchedulerPrefix.TRIAL_DISCOUNT].includes(v)&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.meta.duration`),children:(0,f.jsxs)(u.Space.Compact,{children:[(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(i,l.CNsDiscount,`type`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),!0)],children:(0,f.jsx)(u.Select,{style:{width:150},disabled:c||n,options:m.sort().map((e,t)=>({key:t,label:l.EDiscountType[e],value:e}))})}),(0,f.jsx)(u.Form.Item,{noStyle:!0,name:(0,l.mergeNames)(i,l.CNsDiscount,`value`),rules:[(0,l.requiredField)(t(`scheduler.meta.duration`),!0)],children:(0,f.jsx)(u.InputNumber,{min:1,style:{width:`100%`},readOnly:(0,l.isReadOnlyField)((0,l.mergeNames)(null,l.CNsDiscount,`value`).join(`.`),_),disabled:c||n})})]})})})}),(0,f.jsxs)(u.Row,{gutter:[24,24],children:[(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(h,{label:t(`scheduler.duration`),disabled:c||n,prefix:i,namespace:l.CNsDuration,required:!0,durationTypes:p})}),(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.startedAt`),name:(0,l.mergeNames)(i,`range`,`startedAt`),rules:[(0,l.requiredField)(t(`scheduler.startedAt`))],children:(0,f.jsx)(u.DatePicker,{showTime:!0,format:l.DEFAULT_DATE_TIME_FORMAT,disabledDate:e=>(0,l.getDisabledDate)(e),disabled:c||n,style:{width:`100%`}})})})]}),E===`WEEK`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(B,{prefix:i,isMultiple:!0,formRef:r,setOccurs:S,disabled:c})})}),E===`MONTH`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(V,{formRef:r,prefix:i,disabled:c,setOccurs:S})})}),E===`YEAR`&&(0,f.jsx)(u.Row,{gutter:[24,24],children:(0,f.jsx)(u.Col,{span:24,children:(0,f.jsx)(U,{formRef:r,prefix:i,disabled:c,setOccurs:S})})}),(0,f.jsxs)(u.Row,{gutter:[24,24],children:[(0,f.jsx)(u.Col,{span:12,children:(0,f.jsx)(u.Form.Item,{label:t(`scheduler.duration.end`),name:(0,l.mergeNames)(i,`range`,`endReason`,`type`),rules:[(0,l.requiredField)(t(`scheduler.duration.end`))],children:(0,f.jsx)(u.Select,{disabled:c,options:[t(`scheduler.duration.end.day`),t(`scheduler.duration.end.after`),t(`scheduler.duration.end.no`)].map((e,t)=>({key:t,label:e,value:l.CEndReasonTypes[t]}))})})}),(0,f.jsxs)(u.Col,{span:12,children:[T===l.CEndReasonTypes[0]&&(0,f.jsx)(H,{prefix:i,disabled:c}),T===l.CEndReasonTypes[1]&&(0,f.jsx)(g,{prefix:i,disabled:c})]})]}),(0,f.jsx)(`span`,{className:z.result,dangerouslySetInnerHTML:{__html:t(`scheduler.result`,{occurs:x,startAt:y??``})}})]})})},G=e=>{let{t,permissions:n}=(0,l.useSchedulerContext)(),{formRef:r,loading:i,className:a,isEdit:o,disabled:s,size:c=`small`,color:d=`primary`,icon:m=(0,f.jsx)(p.SaveOutlined,{}),htmlType:h=`submit`,variant:g=`solid`,onClick:_,danger:v=!1}=e;return(o?n.canUpdate:n.canCreate)?(0,f.jsx)(u.Button,{size:c,variant:g,htmlType:h,className:a,disabled:s,loading:i,icon:m,danger:v,onClick:e=>{e.preventDefault(),r&&h===`submit`&&r.submit(),_?.()},color:d,children:t(o?`actions.update`:`actions.save`)}):null},K=({schedulerType:e,disabled:t,onSuccess:n,setDirty:r,dirty:i,isCreating:a,setIsCreating:o,buttonProps:s})=>{let{t:c,loading:m,permissions:h,onCreate:g}=(0,l.useSchedulerContext)(),[_]=u.Form.useForm(),[v,y]=(0,d.useState)(!1),b=(0,d.useMemo)(()=>[l.CScheduler,e],[e]),x=(0,d.useMemo)(()=>Object.keys(l.EDurationTypes),[]),S=(0,d.useMemo)(()=>Object.keys(l.EDiscountType),[]);if(!h.canCreate)return null;let C=async()=>{try{o(!0),await _.validateFields();let t=_.getFieldValue(b),i={id:`new-${Date.now()}`,...t,type:e,[l.CNsDiscount]:e===l.ESchedulerPrefix.SALE?null:t?.[l.CNsDiscount]};g&&await g(e,i),n?.(i),y(!1),r(!1),_.resetFields()}catch{}finally{o(!1)}};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.Button,{style:{padding:0},color:`default`,variant:`link`,...s,disabled:t||m,onClick:e=>{e.preventDefault(),e.stopPropagation(),y(!0)},children:(0,f.jsx)(u.Tooltip,{title:t?c(`scheduler.limited`,{limit:l.DEFAULT_SCHEDULERS_LIMIT}):void 0,children:c(`scheduler`)})}),(0,f.jsx)(u.Drawer,{title:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,f.jsx)(p.ScheduleTwoTone,{}),c(`scheduler`)]}),size:600,open:v,onClose:()=>y(!1),extra:(0,f.jsx)(G,{size:`small`,loading:m||a,disabled:t||!i,onClick:C}),children:(0,f.jsx)(W,{setDirty:r,formRef:_,prefix:b,schedulerType:e,durationTypes:x,discountTypes:S,disabled:t})})]})},q=e=>{let{t}=(0,l.useSchedulerContext)(),{selectedColumns:n=[],columnsList:r=[],onChange:i}=e;if(!r?.length)return(0,f.jsx)(f.Fragment,{});let a=t(`table.hideColumns`),o={mode:`multiple`,style:{minWidth:250},options:[{label:(0,f.jsx)(`span`,{children:a}),title:a,options:r}],placeholder:a,maxTagCount:`responsive`},s=e=>{e.length<1||i?.(e)};return(0,f.jsx)(u.Select,{...o,value:n,onChange:s})},J=e=>{let{loading:t,t:n}=(0,l.useSchedulerContext)(),{children:r,items:i=[],size:a=`middle`,onRefresh:o}=e,s=o?[{key:`refresh`,label:n(`toolbar.refresh`),icon:(0,f.jsx)(p.ReloadOutlined,{}),onClick:o}]:[];return i?.length&&(s=i.concat([{type:`divider`},...s])),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:8},children:[r||null,(0,f.jsx)(u.Dropdown,{menu:{items:s},trigger:[`click`],children:(0,f.jsx)(u.Button,{loading:t,size:a,color:`default`,variant:`filled`,icon:(0,f.jsx)(p.MoreOutlined,{}),type:`primary`})})]})},Y=e=>{let{t,loading:n,permissions:r}=(0,l.useSchedulerContext)(),{entity:i,icon:a,type:o=`primary`,showLabel:s=!1,disabled:c,onDelete:d}=e;return!i||!r.canDelete?null:(0,f.jsx)(u.Popconfirm,{title:t(`actions.confirm.delete`),onConfirm:()=>d?.(i),okText:t(`actions.delete`),cancelText:t(`actions.cancel`),children:(0,f.jsx)(u.Tooltip,{title:t(`actions.delete`),children:(0,f.jsx)(u.Button,{disabled:c||!r.canDelete,loading:n,danger:!0,type:o,icon:a||(0,f.jsx)(p.DeleteTwoTone,{twoToneColor:`#eb2f96`}),children:s&&t(`actions.delete`)})})})},X=e=>{let{t,loading:n,permissions:r}=(0,l.useSchedulerContext)(),{entity:i,type:a=`primary`,showLabel:o=!1,onEdit:s}=e;return!i||!r.canUpdate?null:(0,f.jsx)(u.Button,{disabled:!r.canUpdate,loading:n,type:a,icon:(0,f.jsx)(p.EditTwoTone,{twoToneColor:l.COLORS.success}),onClick:()=>s?.(i),children:o&&t(`actions.edit`)})},ee=e=>(0,f.jsx)(`div`,{className:z.tagsWrapper,children:e?.days.map((e,t)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.volcano,children:e},t))}),Z=(e,t)=>e?.type===`PERIOD`?(0,f.jsx)(`div`,{className:z.tagsWrapper,children:t?.days.map((t,n)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.cyan,children:`${e.weekDay} ${t}`},n))}):(0,f.jsx)(`div`,{className:z.tagsWrapper,children:(0,f.jsx)(u.Tag,{color:l.COLORS.tags.gold,children:e?.monthDay},`monthDay`)}),te=(e,t,n)=>(0,f.jsxs)(f.Fragment,{children:[Z(t,n),(0,f.jsx)(`div`,{className:z.tagsWrapper,children:e?.months?.map((e,t)=>(0,f.jsx)(u.Tag,{color:l.COLORS.tags.magenta,children:e},t))})]}),ne=({status:e})=>{switch(e){case l.EStatus.ACTIVE:return(0,f.jsx)(u.Tag,{color:`success`,icon:(0,f.jsx)(p.CheckCircleOutlined,{}),children:e});case l.EStatus.PROCESSING:return(0,f.jsx)(u.Tag,{color:`processing`,icon:(0,f.jsx)(p.SyncOutlined,{spin:!0}),children:e});case l.EStatus.DEACTIVATED:return(0,f.jsx)(u.Tag,{color:`default`,icon:(0,f.jsx)(p.MinusCircleOutlined,{}),children:e});default:return(0,f.jsx)(u.Tag,{color:`default`,children:e})}},Q=e=>e.map((e,t)=>({...e,idx:t+1,key:e.id})),$={key:`idx`,title:(0,f.jsx)(p.FieldNumberOutlined,{}),dataIndex:`idx`,rowScope:`row`,width:70,fixed:`left`,align:`center`},re=(e=100,t=`Actions`)=>({title:t,key:`operation`,fixed:`right`,align:`center`,width:e}),ie=(e,t=[])=>{let{disabled:n,schedulerType:r,currency:i,t:a,onEdit:o,onDelete:s}=e,c=o||s?{title:a(`table.actions`),key:`operation`,fixed:`right`,align:`center`,width:100,render:(e,t)=>(0,f.jsxs)(`div`,{children:[o&&(0,f.jsx)(X,{onEdit:o,disabled:n,type:`text`,entity:t}),s&&(0,f.jsx)(Y,{onDelete:s,icon:(0,f.jsx)(p.DeleteTwoTone,{twoToneColor:`#eb2f96`}),type:`text`,entity:t,disabled:n})]})}:null,u=[l.ESchedulerPrefix.DISCOUNT,l.ESchedulerPrefix.TRIAL_DISCOUNT].includes(r)?{title:a(`scheduler.meta.duration`),dataIndex:`discount`,key:`discount`,width:150,render(e){return e?e.type===`PERCENT`?`${e.value}${l.CDiscountTypeValues[e.type]}`:(0,l.numberToCurrency)(e.value,i??`USD`):`—`}}:null,d=[$,{title:a(`scheduler.meta.duration`),dataIndex:`duration`,key:`duration`,width:150,render(e){return`${e?.period} (${e?.type})`}},{title:a(`scheduler.duration`),key:`repeat`,render(e,t){let{duration:n,repeat:r}=t,{weekly:i,monthly:a,yearly:o}=r;switch(n?.type){case`WEEK`:return ee(i);case`MONTH`:return Z(a,i);case`YEAR`:return te(o,a,i);default:return(0,f.jsx)(f.Fragment,{})}}},u,{title:a(`scheduler.status`),dataIndex:`status`,key:`status`,width:150,align:`center`,concealable:!0,render:e=>(0,f.jsx)(ne,{status:e})},{title:a(`scheduler.updatedAt`),width:200,dataIndex:`metadata`,align:`center`,key:`metadata.updatedAt`,concealable:!0,render:e=>(0,f.jsx)(`div`,{children:e?.updatedAt?(0,l.tsToLocaleDateTime)(e.updatedAt):`—`})},c].filter(Boolean);return t.length?d.filter(e=>t.includes(e?.dataIndex)||e.dataIndex===`idx`):d},ae=e=>{let{type:t,title:n,disabled:r,readOnlyFields:i=[],currency:a,onRefresh:o}=e,{schedulers:s,loading:c,disabled:m,t:h,permissions:g,onUpdate:_,onDelete:v}=(0,l.useSchedulerContext)(),y=r??m,b=s[t]??[],[x,S]=(0,d.useState)(new Set),[C,w]=(0,d.useState)(!1),[T,E]=(0,d.useState)(!1),D=(0,d.useMemo)(()=>x.size===0?b:b.filter(e=>!e.id||!x.has(e.id)),[b,x]),O=D.length>=l.DEFAULT_SCHEDULERS_LIMIT,[k]=u.Form.useForm(),[A,j]=(0,d.useState)(!1),[M,N]=(0,d.useState)(null),P=(0,d.useMemo)(()=>[l.CScheduler,t],[t]),F=(0,d.useMemo)(()=>Object.keys(l.EDurationTypes),[]),I=(0,d.useMemo)(()=>Object.keys(l.EDiscountType),[]),L=e=>{N(e),j(!0)},R=async()=>{try{await k.validateFields();let e=k.getFieldValue(P),n={...M,...e,type:t,[l.CNsDiscount]:t===l.ESchedulerPrefix.SALE?null:e?.[l.CNsDiscount]};_&&await _(t,n),j(!1),N(null),w(!1),k.resetFields(),o?.()}catch{}},{filteredColumns:B,columnsList:V,selectedColumns:H,setSelectedColumns:U}=(0,l.useColumnsToggle)(ie({disabled:y,schedulerType:t,entities:D,currency:a,t:h,onEdit:g.canUpdate?L:void 0,onDelete:g.canDelete?async e=>{if(e.id?.startsWith(`new-`)){S(t=>{let n=new Set(t);return e.id&&n.add(e.id),n});return}v&&e.id?(await v(t,e.id),o?.()):console.warn(`No onDelete handler provided`)}:void 0}));return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.Table,{columns:B,loading:c,scroll:{x:1e3},bordered:!0,className:z.gridList,dataSource:Q(D),rowKey:e=>e.id??`row-${Math.random()}`,title:()=>(0,f.jsx)(`div`,{className:z.gridHeader,children:(0,f.jsx)(J,{onRefresh:o,items:g.canCreate&&!O?[{label:(0,f.jsx)(K,{setDirty:w,dirty:C,isCreating:T,setIsCreating:E,schedulerType:t,disabled:y||c||O||T,onSuccess:()=>o?.()}),icon:(0,f.jsx)(p.PlusOutlined,{})}]:[],children:(0,f.jsx)(q,{columnsList:V,selectedColumns:H,onChange:U})})}),footer:()=>(0,f.jsx)(`div`,{className:z.gridFooter,children:`Total ${D.length} items`})}),(0,f.jsx)(u.Drawer,{title:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,f.jsx)(p.ScheduleTwoTone,{}),n??h(`scheduler`)]}),size:600,open:A,onClose:()=>{w(!1),j(!1),N(null)},extra:(0,f.jsx)(G,{size:`small`,isEdit:!!M,loading:c,disabled:y||!C||T,onClick:R}),children:A&&(0,f.jsx)(W,{setDirty:w,formRef:k,prefix:P,entity:M,schedulerType:t,durationTypes:F,discountTypes:I,disabled:y,readOnlyFields:i})})]})};exports.Scheduler=W,exports.SchedulerDrawerButton=K,exports.SchedulersList=ae,exports.actionField=re,exports.indexColumn=$,exports.indexable=Q,Object.keys(l).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return l[e]}})});
|
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CDiscountTypeValues as e, CEndReasonTypes as t, CFirstDayIdx as n, CNsDiscount as r, CNsDuration as i, COLORS as a, CScheduler as o, DEFAULT_DATE_TIME_FORMAT as s, DEFAULT_DISCOUNT_SCHEDULER as c, DEFAULT_SALE_SCHEDULER as l, DEFAULT_SCHEDULERS_LIMIT as u, EDays as d, EDiscountType as f, EDurationTypes as p, EMonths as m, ESchedulerPrefix as h, EStatus as g, EWeekDays as _, getDisabledDate as v, getKeyFromEnum as y, handleChangeStartDate as b, handleDurationValueChange as x, handleSelectWeeklyDay as S, isReadOnlyField as C, mergeNames as w, numberToCurrency as T, placeholderField as E, requiredField as D, setNestedDynamicFields as O, tsToLocaleDateTime as k, useColumnsToggle as
|
|
2
|
-
import { Button as
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { CalendarTwoTone as
|
|
1
|
+
import { CDiscountTypeValues as e, CEndReasonTypes as t, CFirstDayIdx as n, CNsDiscount as r, CNsDuration as i, COLORS as a, CScheduler as o, DEFAULT_DATE_TIME_FORMAT as s, DEFAULT_DISCOUNT_SCHEDULER as c, DEFAULT_SALE_SCHEDULER as l, DEFAULT_SCHEDULERS_LIMIT as u, EDays as d, EDiscountType as f, EDurationTypes as p, EMonths as m, ESchedulerPrefix as h, EStatus as g, EWeekDays as _, getDisabledDate as v, getKeyFromEnum as y, handleChangeStartDate as b, handleDurationValueChange as x, handleSelectWeeklyDay as S, isReadOnlyField as C, mergeNames as w, numberToCurrency as T, placeholderField as E, requiredField as D, setNestedDynamicFields as O, tsToLocaleDateTime as k, useColumnsToggle as A, useSchedulerContext as j } from "@teamco/ischeduler-core";
|
|
2
|
+
import { Button as M, Checkbox as N, Col as P, DatePicker as F, Drawer as I, Dropdown as L, Form as R, InputNumber as z, Popconfirm as ee, Row as B, Segmented as te, Select as V, Space as H, Table as ne, Tag as U, Tooltip as W } from "antd";
|
|
3
|
+
import { useCallback as G, useEffect as K, useMemo as q, useRef as re, useState as J } from "react";
|
|
4
|
+
import { Fragment as Y, jsx as X, jsxs as Z } from "react/jsx-runtime";
|
|
5
|
+
import { CalendarTwoTone as Q, CheckCircleOutlined as ie, ControlTwoTone as ae, DeleteTwoTone as oe, EditTwoTone as se, FieldNumberOutlined as ce, MinusCircleOutlined as le, MoreOutlined as ue, PlusOutlined as de, ReloadOutlined as fe, SaveOutlined as pe, ScheduleTwoTone as me, SyncOutlined as he } from "@ant-design/icons";
|
|
6
6
|
import ge from "dayjs";
|
|
7
7
|
export * from "@teamco/ischeduler-core";
|
|
8
8
|
//#region \0rolldown/runtime.js
|
|
@@ -16,16 +16,16 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
16
16
|
value: e,
|
|
17
17
|
enumerable: !0
|
|
18
18
|
}) : n, e)), Ee = (e) => {
|
|
19
|
-
let { t } =
|
|
20
|
-
return /* @__PURE__ */
|
|
19
|
+
let { t } = j(), { min: n = 1, label: r, disabled: a, durationTypes: o = [], required: s, prefix: c = [], exclude: l = [], namespace: u = i, onTypeChange: d, onValueChange: f } = e;
|
|
20
|
+
return /* @__PURE__ */ X(R.Item, {
|
|
21
21
|
label: r,
|
|
22
|
-
children: /* @__PURE__ */
|
|
22
|
+
children: /* @__PURE__ */ Z(H.Compact, {
|
|
23
23
|
style: { width: "100%" },
|
|
24
|
-
children: [/* @__PURE__ */
|
|
24
|
+
children: [/* @__PURE__ */ X(R.Item, {
|
|
25
25
|
noStyle: !0,
|
|
26
26
|
name: w(c, u, "type"),
|
|
27
27
|
rules: [D(t("scheduler.meta.duration"), s)],
|
|
28
|
-
children: /* @__PURE__ */
|
|
28
|
+
children: /* @__PURE__ */ X(V, {
|
|
29
29
|
style: { width: 150 },
|
|
30
30
|
disabled: a,
|
|
31
31
|
onChange: d,
|
|
@@ -35,12 +35,12 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
35
35
|
label: p[e]
|
|
36
36
|
}))
|
|
37
37
|
})
|
|
38
|
-
}), /* @__PURE__ */
|
|
38
|
+
}), /* @__PURE__ */ X(R.Item, {
|
|
39
39
|
noStyle: !0,
|
|
40
40
|
name: w(c, u, "period"),
|
|
41
41
|
tooltip: D(r).message,
|
|
42
42
|
rules: [D(r, s)],
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ X(z, {
|
|
44
44
|
min: n,
|
|
45
45
|
onChange: f,
|
|
46
46
|
style: { width: "100%" },
|
|
@@ -51,12 +51,12 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
51
51
|
})
|
|
52
52
|
});
|
|
53
53
|
}, De = (e) => {
|
|
54
|
-
let { t } =
|
|
55
|
-
return /* @__PURE__ */
|
|
54
|
+
let { t } = j(), { min: n = 1, prefix: r = [], disabled: i = !1, required: a = !0 } = e, o = t("scheduler.occurrences");
|
|
55
|
+
return /* @__PURE__ */ X(R.Item, {
|
|
56
56
|
label: o,
|
|
57
57
|
name: w(r, "range", "endReason", "occurrences"),
|
|
58
58
|
rules: [D(o, a)],
|
|
59
|
-
children: /* @__PURE__ */
|
|
59
|
+
children: /* @__PURE__ */ X(z, {
|
|
60
60
|
min: n,
|
|
61
61
|
style: { width: "calc(100% - 90px)" },
|
|
62
62
|
disabled: i,
|
|
@@ -97,7 +97,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
97
97
|
hide: Me
|
|
98
98
|
}, Pe = (e) => {
|
|
99
99
|
let { loading: t, className: n, disabled: r, onChange: i, options: a = [], value: o = [], type: s = "primary", behavior: c = "hide" } = e;
|
|
100
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ X(N.Group, {
|
|
101
101
|
options: a,
|
|
102
102
|
className: (0, Oe.default)(n, Ne.checkboxWrapper, Ne[s], Ne[c]),
|
|
103
103
|
value: o,
|
|
@@ -122,12 +122,12 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
122
122
|
monthsWrapper: Je,
|
|
123
123
|
tagsWrapper: Ye
|
|
124
124
|
}, Xe = (e) => {
|
|
125
|
-
let { t, loading: r } =
|
|
126
|
-
|
|
125
|
+
let { t, loading: r } = j(), { formRef: i, shortFormat: a = !0, isMultiple: o = !1, extendBy: s = [], namespaces: c = ["repeat", "weekly"], prefix: l, disabled: u, setOccurs: f } = e, p = w([...l, ...c], "days"), m = re([]);
|
|
126
|
+
K(() => {
|
|
127
127
|
let e = i.getFieldValue(p);
|
|
128
128
|
Array.isArray(e) && e.length && (m.current = e, h());
|
|
129
129
|
}, [i]);
|
|
130
|
-
let h =
|
|
130
|
+
let h = G(() => {
|
|
131
131
|
let e = i.getFieldValue(l);
|
|
132
132
|
e?.duration && x({
|
|
133
133
|
type: e.duration.type,
|
|
@@ -138,11 +138,11 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
138
138
|
l,
|
|
139
139
|
f,
|
|
140
140
|
t
|
|
141
|
-
]), g =
|
|
141
|
+
]), g = q(() => Object.keys(d).map((e) => t(`scheduler.weekdays.${d[e].toLowerCase()}`)), [t]), _ = q(() => Object.keys(d).map((e) => t(`scheduler.weekdays.short.${d[e].toLowerCase()}`)), [t]), v = (e) => e.map((t, r) => e[(r + n) % 7]), b = v(_), S = v(g), C = (a ? b : S).map((e, t) => {
|
|
142
142
|
let n = S[t], r = y(d, n);
|
|
143
143
|
return {
|
|
144
144
|
key: `${e}-${t}`,
|
|
145
|
-
label: a ? /* @__PURE__ */
|
|
145
|
+
label: a ? /* @__PURE__ */ X(W, {
|
|
146
146
|
title: S[t],
|
|
147
147
|
children: e
|
|
148
148
|
}) : e,
|
|
@@ -150,7 +150,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
150
150
|
};
|
|
151
151
|
}), T;
|
|
152
152
|
s.length && (C = [...C, ...s], T = $.weekDaysWrap);
|
|
153
|
-
let E =
|
|
153
|
+
let E = G((e) => {
|
|
154
154
|
if (o) m.current = e;
|
|
155
155
|
else {
|
|
156
156
|
let t = m.current, n = e.filter((e) => !t.includes(e)), r = n.length ? n : e;
|
|
@@ -163,13 +163,13 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
163
163
|
p,
|
|
164
164
|
h
|
|
165
165
|
]);
|
|
166
|
-
return /* @__PURE__ */
|
|
166
|
+
return /* @__PURE__ */ X("div", {
|
|
167
167
|
className: (0, Oe.default)($.weekWrapper, T),
|
|
168
|
-
children: /* @__PURE__ */
|
|
168
|
+
children: /* @__PURE__ */ X(R.Item, {
|
|
169
169
|
label: t("scheduler.days"),
|
|
170
170
|
name: p,
|
|
171
171
|
rules: [D(t("scheduler.days"))],
|
|
172
|
-
children: /* @__PURE__ */
|
|
172
|
+
children: /* @__PURE__ */ X(Pe, {
|
|
173
173
|
loading: r,
|
|
174
174
|
disabled: u,
|
|
175
175
|
options: C,
|
|
@@ -178,7 +178,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
178
178
|
})
|
|
179
179
|
});
|
|
180
180
|
}, Ze = (e) => {
|
|
181
|
-
let { t, loading: n } =
|
|
181
|
+
let { t, loading: n } = j(), { min: r = 1, max: i = 31, prefix: a, disabled: o = !1, namespaces: s = ["repeat", "monthly"], formRef: c, setOccurs: l } = e, [u, d] = J("DAY"), f = R.useWatch(w([...a, ...s], "weekDay"), c), p = t("scheduler.day"), m = G((e) => {
|
|
182
182
|
if (d(e), e === "DAY") {
|
|
183
183
|
let e = c.getFieldValue(a);
|
|
184
184
|
S(e.duration.period, e, l, t);
|
|
@@ -190,7 +190,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
190
190
|
d,
|
|
191
191
|
t
|
|
192
192
|
]);
|
|
193
|
-
|
|
193
|
+
K(() => {
|
|
194
194
|
let e = w([...a, ...s], "type");
|
|
195
195
|
m(c.getFieldValue(e));
|
|
196
196
|
}, [
|
|
@@ -199,7 +199,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
199
199
|
a,
|
|
200
200
|
s
|
|
201
201
|
]);
|
|
202
|
-
let h =
|
|
202
|
+
let h = G(() => {
|
|
203
203
|
let e = () => {
|
|
204
204
|
let e = c.getFieldValue(a);
|
|
205
205
|
x({
|
|
@@ -219,17 +219,17 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
219
219
|
return {
|
|
220
220
|
value: r,
|
|
221
221
|
label: t(n),
|
|
222
|
-
icon: f === r ? /* @__PURE__ */
|
|
222
|
+
icon: f === r ? /* @__PURE__ */ X(Q, {}) : /* @__PURE__ */ X(Q, { twoToneColor: "gray" })
|
|
223
223
|
};
|
|
224
224
|
});
|
|
225
|
-
return /* @__PURE__ */
|
|
225
|
+
return /* @__PURE__ */ Z(P, {
|
|
226
226
|
span: 24,
|
|
227
227
|
className: $.monthlyGridWeek,
|
|
228
|
-
children: [/* @__PURE__ */
|
|
228
|
+
children: [/* @__PURE__ */ X(R.Item, {
|
|
229
229
|
noStyle: !0,
|
|
230
230
|
name: w([...a, ...s], "weekDay"),
|
|
231
231
|
rules: [D(t("scheduler.weekday"))],
|
|
232
|
-
children: /* @__PURE__ */
|
|
232
|
+
children: /* @__PURE__ */ X(te, {
|
|
233
233
|
disabled: n || o,
|
|
234
234
|
onChange: e,
|
|
235
235
|
options: r.map(({ value: e, label: t, icon: r }) => ({
|
|
@@ -239,7 +239,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
239
239
|
disabled: o || n
|
|
240
240
|
}))
|
|
241
241
|
})
|
|
242
|
-
}), /* @__PURE__ */
|
|
242
|
+
}), /* @__PURE__ */ X(Xe, {
|
|
243
243
|
formRef: c,
|
|
244
244
|
prefix: a,
|
|
245
245
|
isMultiple: !0,
|
|
@@ -274,15 +274,15 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
274
274
|
a,
|
|
275
275
|
l,
|
|
276
276
|
t
|
|
277
|
-
]), g = () => u === "DAY" ? /* @__PURE__ */
|
|
277
|
+
]), g = () => u === "DAY" ? /* @__PURE__ */ X(P, {
|
|
278
278
|
span: 12,
|
|
279
279
|
className: $.monthlyGridDay,
|
|
280
|
-
children: /* @__PURE__ */
|
|
280
|
+
children: /* @__PURE__ */ X(R.Item, {
|
|
281
281
|
noStyle: !0,
|
|
282
282
|
name: w([...a, ...s], "monthDay"),
|
|
283
283
|
hasFeedback: !0,
|
|
284
284
|
rules: [D(t("scheduler.days"))],
|
|
285
|
-
children: /* @__PURE__ */
|
|
285
|
+
children: /* @__PURE__ */ X(z, {
|
|
286
286
|
style: { width: 120 },
|
|
287
287
|
min: r,
|
|
288
288
|
max: i,
|
|
@@ -295,34 +295,34 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
295
295
|
})
|
|
296
296
|
})
|
|
297
297
|
}) : null;
|
|
298
|
-
return /* @__PURE__ */
|
|
298
|
+
return /* @__PURE__ */ Z("div", {
|
|
299
299
|
className: $.monthWrapper,
|
|
300
|
-
children: [/* @__PURE__ */
|
|
300
|
+
children: [/* @__PURE__ */ X(R.Item, {
|
|
301
301
|
noStyle: !0,
|
|
302
302
|
name: w([...a, ...s], "type"),
|
|
303
303
|
rules: [D(t("scheduler.meta.period"))],
|
|
304
|
-
children: /* @__PURE__ */
|
|
304
|
+
children: /* @__PURE__ */ X(te, {
|
|
305
305
|
disabled: o || n,
|
|
306
306
|
onChange: (e) => {
|
|
307
307
|
m(e);
|
|
308
308
|
},
|
|
309
309
|
options: [{
|
|
310
310
|
value: "DAY",
|
|
311
|
-
icon: u === "DAY" ? /* @__PURE__ */
|
|
311
|
+
icon: u === "DAY" ? /* @__PURE__ */ X(Q, {}) : /* @__PURE__ */ X(Q, { twoToneColor: "gray" }),
|
|
312
312
|
label: t("scheduler.day")
|
|
313
313
|
}, {
|
|
314
314
|
value: "PERIOD",
|
|
315
|
-
icon: u === "PERIOD" ? /* @__PURE__ */
|
|
315
|
+
icon: u === "PERIOD" ? /* @__PURE__ */ X(ae, {}) : /* @__PURE__ */ X(ae, { twoToneColor: "gray" }),
|
|
316
316
|
label: t("scheduler.meta.period")
|
|
317
317
|
}]
|
|
318
318
|
})
|
|
319
|
-
}), /* @__PURE__ */
|
|
319
|
+
}), /* @__PURE__ */ Z(B, {
|
|
320
320
|
className: $.monthComponents,
|
|
321
321
|
children: [g(), h()]
|
|
322
322
|
})]
|
|
323
323
|
});
|
|
324
324
|
}, Qe = (e) => {
|
|
325
|
-
let { disabled: t, prefix: n } = e, { t: r } =
|
|
325
|
+
let { disabled: t, prefix: n } = e, { t: r } = j(), i = R.useWatch(w(n, "range", "startedAt")), a = {
|
|
326
326
|
format: s,
|
|
327
327
|
showTime: !0,
|
|
328
328
|
disabledDate: (e) => {
|
|
@@ -332,21 +332,21 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
332
332
|
},
|
|
333
333
|
disabled: t || !i
|
|
334
334
|
}, o = r("scheduler.duration.endDate");
|
|
335
|
-
return /* @__PURE__ */
|
|
335
|
+
return /* @__PURE__ */ X(R.Item, {
|
|
336
336
|
label: o,
|
|
337
337
|
name: w(n, "range", "endReason", "expiredAt"),
|
|
338
338
|
rules: [D(o, !0)],
|
|
339
|
-
children: /* @__PURE__ */
|
|
339
|
+
children: /* @__PURE__ */ X(F, { ...a })
|
|
340
340
|
});
|
|
341
341
|
}, $e = (e) => {
|
|
342
|
-
let { t, loading: n } =
|
|
343
|
-
|
|
342
|
+
let { t, loading: n } = j(), { shortFormat: r = !0, isMultiple: i = !1, setOccurs: a, formRef: o, prefix: s, namespaces: c = ["repeat", "yearly"], disabled: l } = e, [u, d] = J([]), f = w([...s, ...c], "months"), p = q(() => Object.keys(m).map((e) => t(`scheduler.months.${m[e].toLowerCase()}`)), [t]), h = q(() => Object.keys(m).map((e) => t(`scheduler.months.short.${m[e].toLowerCase()}`)), [t]);
|
|
343
|
+
K(() => {
|
|
344
344
|
let e = o.getFieldValue(f);
|
|
345
345
|
e && _(e);
|
|
346
346
|
}, [o]);
|
|
347
347
|
let g = Object.keys(m).map((e, t) => ({
|
|
348
348
|
key: `${e}-${t}`,
|
|
349
|
-
label: r ? /* @__PURE__ */
|
|
349
|
+
label: r ? /* @__PURE__ */ X(W, {
|
|
350
350
|
title: p[t],
|
|
351
351
|
children: h[t]
|
|
352
352
|
}) : p[t],
|
|
@@ -360,13 +360,13 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
360
360
|
period: r.duration.period
|
|
361
361
|
}, r, a, t);
|
|
362
362
|
};
|
|
363
|
-
return /* @__PURE__ */
|
|
363
|
+
return /* @__PURE__ */ Z("div", {
|
|
364
364
|
className: $.yearWrapper,
|
|
365
|
-
children: [/* @__PURE__ */
|
|
365
|
+
children: [/* @__PURE__ */ X(R.Item, {
|
|
366
366
|
noStyle: !0,
|
|
367
367
|
name: f,
|
|
368
368
|
rules: [D(t("scheduler.months"))],
|
|
369
|
-
children: /* @__PURE__ */
|
|
369
|
+
children: /* @__PURE__ */ X(Pe, {
|
|
370
370
|
options: g,
|
|
371
371
|
disabled: l,
|
|
372
372
|
className: $.monthsWrapper,
|
|
@@ -374,7 +374,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
374
374
|
onChange: _,
|
|
375
375
|
value: u
|
|
376
376
|
})
|
|
377
|
-
}), /* @__PURE__ */
|
|
377
|
+
}), /* @__PURE__ */ X(Ze, {
|
|
378
378
|
formRef: o,
|
|
379
379
|
prefix: s,
|
|
380
380
|
disabled: l,
|
|
@@ -382,205 +382,184 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
382
382
|
})]
|
|
383
383
|
});
|
|
384
384
|
}, et = (e) => {
|
|
385
|
-
let { t: n, loading: a } =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}, [o]), q(() => {
|
|
389
|
-
if (d && d.id !== F) {
|
|
385
|
+
let { t: n, loading: a } = j(), { formRef: o, prefix: u, entity: d, onFinish: p, setDirty: m, disabled: g = !1, durationTypes: _ = [], discountTypes: y = [], readOnlyFields: S = [], schedulerType: T } = e, [E, O] = J(null), [k, A] = J("0"), M = R.useWatch(u, o), N = T === h.SALE ? l : c;
|
|
386
|
+
K(() => {
|
|
387
|
+
if (d) {
|
|
390
388
|
let e = {}, t = e;
|
|
391
389
|
for (let e = 0; e < u.length - 1; e++) t[u[e]] = {}, t = t[u[e]];
|
|
392
|
-
t[u[u.length - 1]] = d, o.setFieldsValue(e)
|
|
393
|
-
}
|
|
390
|
+
t[u[u.length - 1]] = d, o.setFieldsValue(e);
|
|
391
|
+
} else o.resetFields();
|
|
394
392
|
}, [
|
|
395
393
|
d,
|
|
396
394
|
o,
|
|
397
|
-
F,
|
|
398
395
|
u
|
|
399
|
-
]),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}, [
|
|
406
|
-
|
|
407
|
-
d,
|
|
408
|
-
o,
|
|
409
|
-
u,
|
|
410
|
-
n
|
|
411
|
-
]);
|
|
412
|
-
let G = J(() => {
|
|
396
|
+
]), K(() => {
|
|
397
|
+
if (!M) return;
|
|
398
|
+
let e = M.range?.startedAt;
|
|
399
|
+
e && b(e, O);
|
|
400
|
+
let t = M.duration;
|
|
401
|
+
t?.type && t?.period && x(t, M, A, n);
|
|
402
|
+
}, [M, n]);
|
|
403
|
+
let I = M?.range?.endReason?.type, L = M?.duration?.type, ee = q(() => {
|
|
413
404
|
let e = {}, t = e;
|
|
414
405
|
for (let e = 0; e < u.length - 1; e++) t[u[e]] = {}, t = t[u[e]];
|
|
415
|
-
return t[u[u.length - 1]] =
|
|
416
|
-
}, [
|
|
417
|
-
return /* @__PURE__ */
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
406
|
+
return t[u[u.length - 1]] = N, e;
|
|
407
|
+
}, [N, u]);
|
|
408
|
+
return /* @__PURE__ */ X(H, {
|
|
409
|
+
orientation: "vertical",
|
|
410
|
+
style: { width: "100%" },
|
|
411
|
+
children: /* @__PURE__ */ Z(R, {
|
|
412
|
+
layout: "vertical",
|
|
413
|
+
autoComplete: "off",
|
|
414
|
+
form: o,
|
|
415
|
+
className: $.scheduler,
|
|
416
|
+
onFinish: p,
|
|
417
|
+
onFieldsChange: () => m(!0),
|
|
418
|
+
initialValues: ee,
|
|
419
|
+
children: [
|
|
420
|
+
[h.DISCOUNT, h.TRIAL_DISCOUNT].includes(T) && /* @__PURE__ */ X(B, {
|
|
421
|
+
gutter: [24, 24],
|
|
422
|
+
children: /* @__PURE__ */ X(P, {
|
|
423
|
+
span: 12,
|
|
424
|
+
children: /* @__PURE__ */ X(R.Item, {
|
|
425
|
+
label: n("scheduler.meta.duration"),
|
|
426
|
+
children: /* @__PURE__ */ Z(H.Compact, { children: [/* @__PURE__ */ X(R.Item, {
|
|
427
|
+
noStyle: !0,
|
|
428
|
+
name: w(u, r, "type"),
|
|
429
|
+
rules: [D(n("scheduler.meta.duration"), !0)],
|
|
430
|
+
children: /* @__PURE__ */ X(V, {
|
|
431
|
+
style: { width: 150 },
|
|
432
|
+
disabled: g || a,
|
|
433
|
+
options: y.sort().map((e, t) => ({
|
|
434
|
+
key: t,
|
|
435
|
+
label: f[e],
|
|
436
|
+
value: e
|
|
437
|
+
}))
|
|
438
|
+
})
|
|
439
|
+
}), /* @__PURE__ */ X(R.Item, {
|
|
440
|
+
noStyle: !0,
|
|
441
|
+
name: w(u, r, "value"),
|
|
442
|
+
rules: [D(n("scheduler.meta.duration"), !0)],
|
|
443
|
+
children: /* @__PURE__ */ X(z, {
|
|
444
|
+
min: 1,
|
|
445
|
+
style: { width: "100%" },
|
|
446
|
+
readOnly: C(w(null, r, "value").join("."), S),
|
|
447
|
+
disabled: g || a
|
|
448
|
+
})
|
|
449
|
+
})] })
|
|
450
|
+
})
|
|
451
|
+
})
|
|
452
|
+
}),
|
|
453
|
+
/* @__PURE__ */ Z(B, {
|
|
454
|
+
gutter: [24, 24],
|
|
455
|
+
children: [/* @__PURE__ */ X(P, {
|
|
456
|
+
span: 12,
|
|
457
|
+
children: /* @__PURE__ */ X(Ee, {
|
|
458
|
+
label: n("scheduler.duration"),
|
|
459
|
+
disabled: g || a,
|
|
460
|
+
prefix: u,
|
|
461
|
+
namespace: i,
|
|
462
|
+
required: !0,
|
|
463
|
+
durationTypes: _
|
|
464
|
+
})
|
|
465
|
+
}), /* @__PURE__ */ X(P, {
|
|
466
|
+
span: 12,
|
|
467
|
+
children: /* @__PURE__ */ X(R.Item, {
|
|
468
|
+
label: n("scheduler.startedAt"),
|
|
469
|
+
name: w(u, "range", "startedAt"),
|
|
470
|
+
rules: [D(n("scheduler.startedAt"))],
|
|
471
|
+
children: /* @__PURE__ */ X(F, {
|
|
472
|
+
showTime: !0,
|
|
473
|
+
format: s,
|
|
474
|
+
disabledDate: (e) => v(e),
|
|
438
475
|
disabled: g || a,
|
|
439
|
-
|
|
440
|
-
key: t,
|
|
441
|
-
label: f[e],
|
|
442
|
-
value: e
|
|
443
|
-
}))
|
|
444
|
-
})
|
|
445
|
-
}), /* @__PURE__ */ Z(L.Item, {
|
|
446
|
-
noStyle: !0,
|
|
447
|
-
name: w(u, r, "value"),
|
|
448
|
-
rules: [D(n("scheduler.meta.duration"), !0)],
|
|
449
|
-
children: /* @__PURE__ */ Z(R, {
|
|
450
|
-
min: 1,
|
|
451
|
-
style: { width: "100%" },
|
|
452
|
-
readOnly: C(w(null, r, "value").join("."), S),
|
|
453
|
-
disabled: g || a
|
|
476
|
+
style: { width: "100%" }
|
|
454
477
|
})
|
|
455
|
-
})
|
|
456
|
-
})
|
|
457
|
-
})
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
let t = U?.duration?.period;
|
|
469
|
-
t != null && x({
|
|
470
|
-
type: e,
|
|
471
|
-
period: t
|
|
472
|
-
}, U, B, n);
|
|
473
|
-
},
|
|
474
|
-
onValueChange: (e) => {
|
|
475
|
-
let t = U?.duration?.type;
|
|
476
|
-
e && t && x({
|
|
477
|
-
type: t,
|
|
478
|
-
period: e
|
|
479
|
-
}, U, B, n);
|
|
480
|
-
},
|
|
481
|
-
prefix: u,
|
|
482
|
-
namespace: i,
|
|
483
|
-
required: !0,
|
|
484
|
-
durationTypes: _
|
|
485
|
-
})
|
|
486
|
-
}), /* @__PURE__ */ Z(N, {
|
|
487
|
-
span: 12,
|
|
488
|
-
children: /* @__PURE__ */ Z(L.Item, {
|
|
489
|
-
label: n("scheduler.startedAt"),
|
|
490
|
-
name: w(u, "range", "startedAt"),
|
|
491
|
-
rules: [D(n("scheduler.startedAt"))],
|
|
492
|
-
children: /* @__PURE__ */ Z(P, {
|
|
493
|
-
onChange: (e) => e && b(e, M),
|
|
494
|
-
showTime: !0,
|
|
495
|
-
format: s,
|
|
496
|
-
disabledDate: (e) => v(e),
|
|
497
|
-
disabled: g || a
|
|
478
|
+
})
|
|
479
|
+
})]
|
|
480
|
+
}),
|
|
481
|
+
L === "WEEK" && /* @__PURE__ */ X(B, {
|
|
482
|
+
gutter: [24, 24],
|
|
483
|
+
children: /* @__PURE__ */ X(P, {
|
|
484
|
+
span: 24,
|
|
485
|
+
children: /* @__PURE__ */ X(Xe, {
|
|
486
|
+
prefix: u,
|
|
487
|
+
isMultiple: !0,
|
|
488
|
+
formRef: o,
|
|
489
|
+
setOccurs: A,
|
|
490
|
+
disabled: g
|
|
498
491
|
})
|
|
499
492
|
})
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
disabled: g
|
|
512
|
-
})
|
|
513
|
-
})
|
|
514
|
-
}),
|
|
515
|
-
k === "MONTH" && /* @__PURE__ */ Z(z, {
|
|
516
|
-
gutter: [24, 24],
|
|
517
|
-
children: /* @__PURE__ */ Z(N, {
|
|
518
|
-
span: 24,
|
|
519
|
-
children: /* @__PURE__ */ Z(Ze, {
|
|
520
|
-
formRef: o,
|
|
521
|
-
prefix: u,
|
|
522
|
-
disabled: g,
|
|
523
|
-
setOccurs: B
|
|
524
|
-
})
|
|
525
|
-
})
|
|
526
|
-
}),
|
|
527
|
-
k === "YEAR" && /* @__PURE__ */ Z(z, {
|
|
528
|
-
gutter: [24, 24],
|
|
529
|
-
children: /* @__PURE__ */ Z(N, {
|
|
530
|
-
span: 24,
|
|
531
|
-
children: /* @__PURE__ */ Z($e, {
|
|
532
|
-
formRef: o,
|
|
533
|
-
prefix: u,
|
|
534
|
-
disabled: g,
|
|
535
|
-
setOccurs: B
|
|
493
|
+
}),
|
|
494
|
+
L === "MONTH" && /* @__PURE__ */ X(B, {
|
|
495
|
+
gutter: [24, 24],
|
|
496
|
+
children: /* @__PURE__ */ X(P, {
|
|
497
|
+
span: 24,
|
|
498
|
+
children: /* @__PURE__ */ X(Ze, {
|
|
499
|
+
formRef: o,
|
|
500
|
+
prefix: u,
|
|
501
|
+
disabled: g,
|
|
502
|
+
setOccurs: A
|
|
503
|
+
})
|
|
536
504
|
})
|
|
537
|
-
})
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
name: w(u, "range", "endReason", "type"),
|
|
546
|
-
rules: [D(n("scheduler.duration.end"))],
|
|
547
|
-
children: /* @__PURE__ */ Z(V, {
|
|
505
|
+
}),
|
|
506
|
+
L === "YEAR" && /* @__PURE__ */ X(B, {
|
|
507
|
+
gutter: [24, 24],
|
|
508
|
+
children: /* @__PURE__ */ X(P, {
|
|
509
|
+
span: 24,
|
|
510
|
+
children: /* @__PURE__ */ X($e, {
|
|
511
|
+
formRef: o,
|
|
512
|
+
prefix: u,
|
|
548
513
|
disabled: g,
|
|
549
|
-
|
|
550
|
-
options: [
|
|
551
|
-
n("scheduler.duration.end.day"),
|
|
552
|
-
n("scheduler.duration.end.after"),
|
|
553
|
-
n("scheduler.duration.end.no")
|
|
554
|
-
].map((e, n) => ({
|
|
555
|
-
key: n,
|
|
556
|
-
label: e,
|
|
557
|
-
value: t[n]
|
|
558
|
-
}))
|
|
514
|
+
setOccurs: A
|
|
559
515
|
})
|
|
560
516
|
})
|
|
561
|
-
}),
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
517
|
+
}),
|
|
518
|
+
/* @__PURE__ */ Z(B, {
|
|
519
|
+
gutter: [24, 24],
|
|
520
|
+
children: [/* @__PURE__ */ X(P, {
|
|
521
|
+
span: 12,
|
|
522
|
+
children: /* @__PURE__ */ X(R.Item, {
|
|
523
|
+
label: n("scheduler.duration.end"),
|
|
524
|
+
name: w(u, "range", "endReason", "type"),
|
|
525
|
+
rules: [D(n("scheduler.duration.end"))],
|
|
526
|
+
children: /* @__PURE__ */ X(V, {
|
|
527
|
+
disabled: g,
|
|
528
|
+
options: [
|
|
529
|
+
n("scheduler.duration.end.day"),
|
|
530
|
+
n("scheduler.duration.end.after"),
|
|
531
|
+
n("scheduler.duration.end.no")
|
|
532
|
+
].map((e, n) => ({
|
|
533
|
+
key: n,
|
|
534
|
+
label: e,
|
|
535
|
+
value: t[n]
|
|
536
|
+
}))
|
|
537
|
+
})
|
|
538
|
+
})
|
|
539
|
+
}), /* @__PURE__ */ Z(P, {
|
|
540
|
+
span: 12,
|
|
541
|
+
children: [I === t[0] && /* @__PURE__ */ X(Qe, {
|
|
542
|
+
prefix: u,
|
|
543
|
+
disabled: g
|
|
544
|
+
}), I === t[1] && /* @__PURE__ */ X(De, {
|
|
545
|
+
prefix: u,
|
|
546
|
+
disabled: g
|
|
547
|
+
})]
|
|
569
548
|
})]
|
|
570
|
-
})
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
})
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
})
|
|
549
|
+
}),
|
|
550
|
+
/* @__PURE__ */ X("span", {
|
|
551
|
+
className: $.result,
|
|
552
|
+
dangerouslySetInnerHTML: { __html: n("scheduler.result", {
|
|
553
|
+
occurs: k,
|
|
554
|
+
startAt: E ?? ""
|
|
555
|
+
}) }
|
|
556
|
+
})
|
|
557
|
+
]
|
|
558
|
+
})
|
|
559
|
+
});
|
|
581
560
|
}, tt = (e) => {
|
|
582
|
-
let { t, permissions: n } =
|
|
583
|
-
return (o ? n.canUpdate : n.canCreate) ? /* @__PURE__ */
|
|
561
|
+
let { t, permissions: n } = j(), { formRef: r, loading: i, className: a, isEdit: o, disabled: s, size: c = "small", color: l = "primary", icon: u = /* @__PURE__ */ X(pe, {}), htmlType: d = "submit", variant: f = "solid", onClick: p, danger: m = !1 } = e;
|
|
562
|
+
return (o ? n.canUpdate : n.canCreate) ? /* @__PURE__ */ X(M, {
|
|
584
563
|
size: c,
|
|
585
564
|
variant: f,
|
|
586
565
|
htmlType: d,
|
|
@@ -596,7 +575,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
596
575
|
children: t(o ? "actions.update" : "actions.save")
|
|
597
576
|
}) : null;
|
|
598
577
|
}, nt = ({ schedulerType: e, disabled: t, onSuccess: n, setDirty: i, dirty: a, isCreating: s, setIsCreating: c, buttonProps: l }) => {
|
|
599
|
-
let { t: d, loading: m, permissions: g, onCreate: _ } =
|
|
578
|
+
let { t: d, loading: m, permissions: g, onCreate: _ } = j(), [v] = R.useForm(), [y, b] = J(!1), x = q(() => [o, e], [e]), S = q(() => Object.keys(p), []), C = q(() => Object.keys(f), []);
|
|
600
579
|
if (!g.canCreate) return null;
|
|
601
580
|
let w = async () => {
|
|
602
581
|
try {
|
|
@@ -612,7 +591,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
612
591
|
c(!1);
|
|
613
592
|
}
|
|
614
593
|
};
|
|
615
|
-
return /* @__PURE__ */
|
|
594
|
+
return /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(M, {
|
|
616
595
|
style: { padding: 0 },
|
|
617
596
|
color: "default",
|
|
618
597
|
variant: "link",
|
|
@@ -621,29 +600,29 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
621
600
|
onClick: (e) => {
|
|
622
601
|
e.preventDefault(), e.stopPropagation(), b(!0);
|
|
623
602
|
},
|
|
624
|
-
children: /* @__PURE__ */
|
|
603
|
+
children: /* @__PURE__ */ X(W, {
|
|
625
604
|
title: t ? d("scheduler.limited", { limit: u }) : void 0,
|
|
626
605
|
children: d("scheduler")
|
|
627
606
|
})
|
|
628
|
-
}), /* @__PURE__ */
|
|
629
|
-
title: /* @__PURE__ */
|
|
607
|
+
}), /* @__PURE__ */ X(I, {
|
|
608
|
+
title: /* @__PURE__ */ Z("div", {
|
|
630
609
|
style: {
|
|
631
610
|
display: "flex",
|
|
632
611
|
alignItems: "center",
|
|
633
612
|
gap: 8
|
|
634
613
|
},
|
|
635
|
-
children: [/* @__PURE__ */
|
|
614
|
+
children: [/* @__PURE__ */ X(me, {}), d("scheduler")]
|
|
636
615
|
}),
|
|
637
616
|
size: 600,
|
|
638
617
|
open: y,
|
|
639
618
|
onClose: () => b(!1),
|
|
640
|
-
extra: /* @__PURE__ */
|
|
619
|
+
extra: /* @__PURE__ */ X(tt, {
|
|
641
620
|
size: "small",
|
|
642
621
|
loading: m || s,
|
|
643
622
|
disabled: t || !a,
|
|
644
623
|
onClick: w
|
|
645
624
|
}),
|
|
646
|
-
children: /* @__PURE__ */
|
|
625
|
+
children: /* @__PURE__ */ X(et, {
|
|
647
626
|
setDirty: i,
|
|
648
627
|
formRef: v,
|
|
649
628
|
prefix: x,
|
|
@@ -654,13 +633,13 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
654
633
|
})
|
|
655
634
|
})] });
|
|
656
635
|
}, rt = (e) => {
|
|
657
|
-
let { t } =
|
|
658
|
-
if (!r?.length) return /* @__PURE__ */
|
|
636
|
+
let { t } = j(), { selectedColumns: n = [], columnsList: r = [], onChange: i } = e;
|
|
637
|
+
if (!r?.length) return /* @__PURE__ */ X(Y, {});
|
|
659
638
|
let a = t("table.hideColumns"), o = {
|
|
660
639
|
mode: "multiple",
|
|
661
640
|
style: { minWidth: 250 },
|
|
662
641
|
options: [{
|
|
663
|
-
label: /* @__PURE__ */
|
|
642
|
+
label: /* @__PURE__ */ X("span", { children: a }),
|
|
664
643
|
title: a,
|
|
665
644
|
options: r
|
|
666
645
|
}],
|
|
@@ -669,109 +648,109 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
669
648
|
}, s = (e) => {
|
|
670
649
|
e.length < 1 || i?.(e);
|
|
671
650
|
};
|
|
672
|
-
return /* @__PURE__ */
|
|
651
|
+
return /* @__PURE__ */ X(V, {
|
|
673
652
|
...o,
|
|
674
653
|
value: n,
|
|
675
654
|
onChange: s
|
|
676
655
|
});
|
|
677
656
|
}, it = (e) => {
|
|
678
|
-
let { loading: t, t: n } =
|
|
657
|
+
let { loading: t, t: n } = j(), { children: r, items: i = [], size: a = "middle", onRefresh: o } = e, s = o ? [{
|
|
679
658
|
key: "refresh",
|
|
680
659
|
label: n("toolbar.refresh"),
|
|
681
|
-
icon: /* @__PURE__ */
|
|
660
|
+
icon: /* @__PURE__ */ X(fe, {}),
|
|
682
661
|
onClick: o
|
|
683
662
|
}] : [];
|
|
684
|
-
return i?.length && (s = i.concat([{ type: "divider" }, ...s])), /* @__PURE__ */
|
|
663
|
+
return i?.length && (s = i.concat([{ type: "divider" }, ...s])), /* @__PURE__ */ Z("div", {
|
|
685
664
|
style: {
|
|
686
665
|
display: "flex",
|
|
687
666
|
alignItems: "center",
|
|
688
667
|
justifyContent: "flex-end",
|
|
689
668
|
gap: 8
|
|
690
669
|
},
|
|
691
|
-
children: [r || null, /* @__PURE__ */
|
|
670
|
+
children: [r || null, /* @__PURE__ */ X(L, {
|
|
692
671
|
menu: { items: s },
|
|
693
672
|
trigger: ["click"],
|
|
694
|
-
children: /* @__PURE__ */
|
|
673
|
+
children: /* @__PURE__ */ X(M, {
|
|
695
674
|
loading: t,
|
|
696
675
|
size: a,
|
|
697
676
|
color: "default",
|
|
698
677
|
variant: "filled",
|
|
699
|
-
icon: /* @__PURE__ */
|
|
678
|
+
icon: /* @__PURE__ */ X(ue, {}),
|
|
700
679
|
type: "primary"
|
|
701
680
|
})
|
|
702
681
|
})]
|
|
703
682
|
});
|
|
704
683
|
}, at = (e) => {
|
|
705
|
-
let { t, loading: n, permissions: r } =
|
|
706
|
-
return !i || !r.canDelete ? null : /* @__PURE__ */
|
|
684
|
+
let { t, loading: n, permissions: r } = j(), { entity: i, icon: a, type: o = "primary", showLabel: s = !1, disabled: c, onDelete: l } = e;
|
|
685
|
+
return !i || !r.canDelete ? null : /* @__PURE__ */ X(ee, {
|
|
707
686
|
title: t("actions.confirm.delete"),
|
|
708
687
|
onConfirm: () => l?.(i),
|
|
709
688
|
okText: t("actions.delete"),
|
|
710
689
|
cancelText: t("actions.cancel"),
|
|
711
|
-
children: /* @__PURE__ */
|
|
690
|
+
children: /* @__PURE__ */ X(W, {
|
|
712
691
|
title: t("actions.delete"),
|
|
713
|
-
children: /* @__PURE__ */
|
|
692
|
+
children: /* @__PURE__ */ X(M, {
|
|
714
693
|
disabled: c || !r.canDelete,
|
|
715
694
|
loading: n,
|
|
716
695
|
danger: !0,
|
|
717
696
|
type: o,
|
|
718
|
-
icon: a || /* @__PURE__ */
|
|
697
|
+
icon: a || /* @__PURE__ */ X(oe, { twoToneColor: "#eb2f96" }),
|
|
719
698
|
children: s && t("actions.delete")
|
|
720
699
|
})
|
|
721
700
|
})
|
|
722
701
|
});
|
|
723
702
|
}, ot = (e) => {
|
|
724
|
-
let { t, loading: n, permissions: r } =
|
|
725
|
-
return !i || !r.canUpdate ? null : /* @__PURE__ */
|
|
703
|
+
let { t, loading: n, permissions: r } = j(), { entity: i, type: o = "primary", showLabel: s = !1, onEdit: c } = e;
|
|
704
|
+
return !i || !r.canUpdate ? null : /* @__PURE__ */ X(M, {
|
|
726
705
|
disabled: !r.canUpdate,
|
|
727
706
|
loading: n,
|
|
728
707
|
type: o,
|
|
729
|
-
icon: /* @__PURE__ */
|
|
708
|
+
icon: /* @__PURE__ */ X(se, { twoToneColor: a.success }),
|
|
730
709
|
onClick: () => c?.(i),
|
|
731
710
|
children: s && t("actions.edit")
|
|
732
711
|
});
|
|
733
|
-
}, st = (e) => /* @__PURE__ */
|
|
712
|
+
}, st = (e) => /* @__PURE__ */ X("div", {
|
|
734
713
|
className: $.tagsWrapper,
|
|
735
|
-
children: e?.days.map((e, t) => /* @__PURE__ */
|
|
714
|
+
children: e?.days.map((e, t) => /* @__PURE__ */ X(U, {
|
|
736
715
|
color: a.tags.volcano,
|
|
737
716
|
children: e
|
|
738
717
|
}, t))
|
|
739
|
-
}), ct = (e, t) => e?.type === "PERIOD" ? /* @__PURE__ */
|
|
718
|
+
}), ct = (e, t) => e?.type === "PERIOD" ? /* @__PURE__ */ X("div", {
|
|
740
719
|
className: $.tagsWrapper,
|
|
741
|
-
children: t?.days.map((t, n) => /* @__PURE__ */
|
|
720
|
+
children: t?.days.map((t, n) => /* @__PURE__ */ X(U, {
|
|
742
721
|
color: a.tags.cyan,
|
|
743
722
|
children: `${e.weekDay} ${t}`
|
|
744
723
|
}, n))
|
|
745
|
-
}) : /* @__PURE__ */
|
|
724
|
+
}) : /* @__PURE__ */ X("div", {
|
|
746
725
|
className: $.tagsWrapper,
|
|
747
|
-
children: /* @__PURE__ */
|
|
726
|
+
children: /* @__PURE__ */ X(U, {
|
|
748
727
|
color: a.tags.gold,
|
|
749
728
|
children: e?.monthDay
|
|
750
729
|
}, "monthDay")
|
|
751
|
-
}), lt = (e, t, n) => /* @__PURE__ */
|
|
730
|
+
}), lt = (e, t, n) => /* @__PURE__ */ Z(Y, { children: [ct(t, n), /* @__PURE__ */ X("div", {
|
|
752
731
|
className: $.tagsWrapper,
|
|
753
|
-
children: e?.months?.map((e, t) => /* @__PURE__ */
|
|
732
|
+
children: e?.months?.map((e, t) => /* @__PURE__ */ X(U, {
|
|
754
733
|
color: a.tags.magenta,
|
|
755
734
|
children: e
|
|
756
735
|
}, t))
|
|
757
736
|
})] }), ut = ({ status: e }) => {
|
|
758
737
|
switch (e) {
|
|
759
|
-
case g.ACTIVE: return /* @__PURE__ */
|
|
738
|
+
case g.ACTIVE: return /* @__PURE__ */ X(U, {
|
|
760
739
|
color: "success",
|
|
761
|
-
icon: /* @__PURE__ */
|
|
740
|
+
icon: /* @__PURE__ */ X(ie, {}),
|
|
762
741
|
children: e
|
|
763
742
|
});
|
|
764
|
-
case g.PROCESSING: return /* @__PURE__ */
|
|
743
|
+
case g.PROCESSING: return /* @__PURE__ */ X(U, {
|
|
765
744
|
color: "processing",
|
|
766
|
-
icon: /* @__PURE__ */
|
|
745
|
+
icon: /* @__PURE__ */ X(he, { spin: !0 }),
|
|
767
746
|
children: e
|
|
768
747
|
});
|
|
769
|
-
case g.DEACTIVATED: return /* @__PURE__ */
|
|
748
|
+
case g.DEACTIVATED: return /* @__PURE__ */ X(U, {
|
|
770
749
|
color: "default",
|
|
771
|
-
icon: /* @__PURE__ */
|
|
750
|
+
icon: /* @__PURE__ */ X(le, {}),
|
|
772
751
|
children: e
|
|
773
752
|
});
|
|
774
|
-
default: return /* @__PURE__ */
|
|
753
|
+
default: return /* @__PURE__ */ X(U, {
|
|
775
754
|
color: "default",
|
|
776
755
|
children: e
|
|
777
756
|
});
|
|
@@ -782,7 +761,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
782
761
|
key: e.id
|
|
783
762
|
})), ft = {
|
|
784
763
|
key: "idx",
|
|
785
|
-
title: /* @__PURE__ */
|
|
764
|
+
title: /* @__PURE__ */ X(ce, {}),
|
|
786
765
|
dataIndex: "idx",
|
|
787
766
|
rowScope: "row",
|
|
788
767
|
width: 70,
|
|
@@ -801,14 +780,14 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
801
780
|
fixed: "right",
|
|
802
781
|
align: "center",
|
|
803
782
|
width: 100,
|
|
804
|
-
render: (e, t) => /* @__PURE__ */
|
|
783
|
+
render: (e, t) => /* @__PURE__ */ Z("div", { children: [s && /* @__PURE__ */ X(ot, {
|
|
805
784
|
onEdit: s,
|
|
806
785
|
disabled: r,
|
|
807
786
|
type: "text",
|
|
808
787
|
entity: t
|
|
809
|
-
}), c && /* @__PURE__ */
|
|
788
|
+
}), c && /* @__PURE__ */ X(at, {
|
|
810
789
|
onDelete: c,
|
|
811
|
-
icon: /* @__PURE__ */
|
|
790
|
+
icon: /* @__PURE__ */ X(oe, { twoToneColor: "#eb2f96" }),
|
|
812
791
|
type: "text",
|
|
813
792
|
entity: t,
|
|
814
793
|
disabled: r
|
|
@@ -841,7 +820,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
841
820
|
case "WEEK": return st(i);
|
|
842
821
|
case "MONTH": return ct(a, i);
|
|
843
822
|
case "YEAR": return lt(o, a, i);
|
|
844
|
-
default: return /* @__PURE__ */
|
|
823
|
+
default: return /* @__PURE__ */ X(Y, {});
|
|
845
824
|
}
|
|
846
825
|
}
|
|
847
826
|
},
|
|
@@ -853,7 +832,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
853
832
|
width: 150,
|
|
854
833
|
align: "center",
|
|
855
834
|
concealable: !0,
|
|
856
|
-
render: (e) => /* @__PURE__ */
|
|
835
|
+
render: (e) => /* @__PURE__ */ X(ut, { status: e })
|
|
857
836
|
},
|
|
858
837
|
{
|
|
859
838
|
title: o("scheduler.updatedAt"),
|
|
@@ -862,32 +841,32 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
862
841
|
align: "center",
|
|
863
842
|
key: "metadata.updatedAt",
|
|
864
843
|
concealable: !0,
|
|
865
|
-
render: (e) => /* @__PURE__ */
|
|
844
|
+
render: (e) => /* @__PURE__ */ X("div", { children: e?.updatedAt ? k(e.updatedAt) : "—" })
|
|
866
845
|
},
|
|
867
846
|
l
|
|
868
847
|
].filter(Boolean);
|
|
869
848
|
return n.length ? d.filter((e) => n.includes(e?.dataIndex) || e.dataIndex === "idx") : d;
|
|
870
849
|
}, ht = (e) => {
|
|
871
|
-
let { type: t, title: n, disabled: i, readOnlyFields: a = [], currency: s, onRefresh: c } = e, { schedulers: l, loading: d, disabled: m, t: g, permissions: _, onUpdate: v, onDelete: y } =
|
|
872
|
-
|
|
850
|
+
let { type: t, title: n, disabled: i, readOnlyFields: a = [], currency: s, onRefresh: c } = e, { schedulers: l, loading: d, disabled: m, t: g, permissions: _, onUpdate: v, onDelete: y } = j(), b = i ?? m, x = l[t] ?? [], [S, C] = J(/* @__PURE__ */ new Set()), [w, T] = J(!1), [E, D] = J(!1), O = q(() => S.size === 0 ? x : x.filter((e) => !e.id || !S.has(e.id)), [x, S]), k = O.length >= u, [M] = R.useForm(), [N, P] = J(!1), [F, L] = J(null), z = q(() => [o, t], [t]), ee = q(() => Object.keys(p), []), B = q(() => Object.keys(f), []), te = (e) => {
|
|
851
|
+
L(e), P(!0);
|
|
873
852
|
}, V = async () => {
|
|
874
853
|
try {
|
|
875
|
-
await
|
|
876
|
-
let e =
|
|
877
|
-
...
|
|
854
|
+
await M.validateFields();
|
|
855
|
+
let e = M.getFieldValue(z), n = {
|
|
856
|
+
...F,
|
|
878
857
|
...e,
|
|
879
858
|
type: t,
|
|
880
859
|
[r]: t === h.SALE ? null : e?.[r]
|
|
881
860
|
};
|
|
882
|
-
v && await v(t, n),
|
|
861
|
+
v && await v(t, n), P(!1), L(null), T(!1), M.resetFields(), c?.();
|
|
883
862
|
} catch {}
|
|
884
|
-
}, { filteredColumns: H, columnsList:
|
|
863
|
+
}, { filteredColumns: H, columnsList: U, selectedColumns: W, setSelectedColumns: G } = A(mt({
|
|
885
864
|
disabled: b,
|
|
886
865
|
schedulerType: t,
|
|
887
866
|
entities: O,
|
|
888
867
|
currency: s,
|
|
889
868
|
t: g,
|
|
890
|
-
onEdit: _.canUpdate ?
|
|
869
|
+
onEdit: _.canUpdate ? te : void 0,
|
|
891
870
|
onDelete: _.canDelete ? async (e) => {
|
|
892
871
|
if (e.id?.startsWith("new-")) {
|
|
893
872
|
C((t) => {
|
|
@@ -899,7 +878,7 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
899
878
|
y && e.id ? (await y(t, e.id), c?.()) : console.warn("No onDelete handler provided");
|
|
900
879
|
} : void 0
|
|
901
880
|
}));
|
|
902
|
-
return /* @__PURE__ */
|
|
881
|
+
return /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(ne, {
|
|
903
882
|
columns: H,
|
|
904
883
|
loading: d,
|
|
905
884
|
scroll: { x: 1e3 },
|
|
@@ -907,12 +886,12 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
907
886
|
className: $.gridList,
|
|
908
887
|
dataSource: dt(O),
|
|
909
888
|
rowKey: (e) => e.id ?? `row-${Math.random()}`,
|
|
910
|
-
title: () => /* @__PURE__ */
|
|
889
|
+
title: () => /* @__PURE__ */ X("div", {
|
|
911
890
|
className: $.gridHeader,
|
|
912
|
-
children: /* @__PURE__ */
|
|
891
|
+
children: /* @__PURE__ */ X(it, {
|
|
913
892
|
onRefresh: c,
|
|
914
893
|
items: _.canCreate && !k ? [{
|
|
915
|
-
label: /* @__PURE__ */
|
|
894
|
+
label: /* @__PURE__ */ X(nt, {
|
|
916
895
|
setDirty: T,
|
|
917
896
|
dirty: w,
|
|
918
897
|
isCreating: E,
|
|
@@ -921,48 +900,48 @@ var _e = Object.create, ve = Object.defineProperty, ye = Object.getOwnPropertyDe
|
|
|
921
900
|
disabled: b || d || k || E,
|
|
922
901
|
onSuccess: () => c?.()
|
|
923
902
|
}),
|
|
924
|
-
icon: /* @__PURE__ */
|
|
903
|
+
icon: /* @__PURE__ */ X(de, {})
|
|
925
904
|
}] : [],
|
|
926
|
-
children: /* @__PURE__ */
|
|
927
|
-
columnsList:
|
|
928
|
-
selectedColumns:
|
|
929
|
-
onChange:
|
|
905
|
+
children: /* @__PURE__ */ X(rt, {
|
|
906
|
+
columnsList: U,
|
|
907
|
+
selectedColumns: W,
|
|
908
|
+
onChange: G
|
|
930
909
|
})
|
|
931
910
|
})
|
|
932
911
|
}),
|
|
933
|
-
footer: () => /* @__PURE__ */
|
|
912
|
+
footer: () => /* @__PURE__ */ X("div", {
|
|
934
913
|
className: $.gridFooter,
|
|
935
914
|
children: `Total ${O.length} items`
|
|
936
915
|
})
|
|
937
|
-
}), /* @__PURE__ */
|
|
938
|
-
title: /* @__PURE__ */
|
|
916
|
+
}), /* @__PURE__ */ X(I, {
|
|
917
|
+
title: /* @__PURE__ */ Z("div", {
|
|
939
918
|
style: {
|
|
940
919
|
display: "flex",
|
|
941
920
|
alignItems: "center",
|
|
942
921
|
gap: 8
|
|
943
922
|
},
|
|
944
|
-
children: [/* @__PURE__ */
|
|
923
|
+
children: [/* @__PURE__ */ X(me, {}), n ?? g("scheduler")]
|
|
945
924
|
}),
|
|
946
925
|
size: 600,
|
|
947
|
-
open:
|
|
926
|
+
open: N,
|
|
948
927
|
onClose: () => {
|
|
949
|
-
|
|
928
|
+
T(!1), P(!1), L(null);
|
|
950
929
|
},
|
|
951
|
-
extra: /* @__PURE__ */
|
|
930
|
+
extra: /* @__PURE__ */ X(tt, {
|
|
952
931
|
size: "small",
|
|
953
|
-
isEdit: !!
|
|
932
|
+
isEdit: !!F,
|
|
954
933
|
loading: d,
|
|
955
934
|
disabled: b || !w || E,
|
|
956
935
|
onClick: V
|
|
957
936
|
}),
|
|
958
|
-
children:
|
|
937
|
+
children: N && /* @__PURE__ */ X(et, {
|
|
959
938
|
setDirty: T,
|
|
960
|
-
formRef:
|
|
961
|
-
prefix:
|
|
962
|
-
entity:
|
|
939
|
+
formRef: M,
|
|
940
|
+
prefix: z,
|
|
941
|
+
entity: F,
|
|
963
942
|
schedulerType: t,
|
|
964
|
-
durationTypes:
|
|
965
|
-
discountTypes:
|
|
943
|
+
durationTypes: ee,
|
|
944
|
+
discountTypes: B,
|
|
966
945
|
disabled: b,
|
|
967
946
|
readOnlyFields: a
|
|
968
947
|
})
|