@teamco/ischeduler-mui 2.0.11 → 2.0.12
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/index.cjs.js +1 -1
- package/dist/index.es.js +152 -152
- package/dist/mui/src/components/Scheduler.d.ts.map +1 -1
- package/dist/mui/src/components/SchedulerDrawerButton.d.ts.map +1 -1
- package/dist/mui/src/components/SchedulersList.d.ts +1 -1
- package/dist/mui/src/components/SchedulersList.d.ts.map +1 -1
- package/package.json +1 -1
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,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},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@teamco/ischeduler-core`),l=require(`react`);l=s(l);let u=require(`@mui/material`),d=require(`@mui/x-date-pickers/DateTimePicker`),f=require(`@mui/x-date-pickers/LocalizationProvider`),p=require(`@mui/x-date-pickers/AdapterDayjs`),m=require(`dayjs`);m=s(m);let h=require(`react/jsx-runtime`),g=require(`@mui/icons-material/CalendarMonth`);g=s(g);let _=require(`@mui/icons-material/Settings`);_=s(_);let v=require(`@mui/icons-material/Add`);v=s(v);let y=require(`@mui/icons-material/DateRange`);y=s(y);let b=require(`@mui/icons-material/Close`);b=s(b);let x=require(`@mui/icons-material/Save`);x=s(x);let S=require(`@mui/icons-material/MoreVert`);S=s(S);let C=require(`@mui/icons-material/Refresh`);C=s(C);let w=require(`@mui/icons-material/Delete`);w=s(w);let T=require(`@mui/icons-material/Edit`);T=s(T);var E=e=>{let{t}=(0,c.useSchedulerContext)(),{min:n=1,label:r,disabled:i,durationTypes:a=[],exclude:o=[],typeValue:s,periodValue:l,onTypeChange:d,onValueChange:f}=e;return(0,h.jsxs)(u.Box,{sx:{display:`flex`,gap:1,width:`100%`},children:[(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{id:`duration-type-label`,children:t(`scheduler.meta.period`)}),(0,h.jsx)(u.Select,{labelId:`duration-type-label`,value:s||``,label:t(`scheduler.meta.period`),disabled:i,onChange:e=>d?.(e.target.value),children:a.filter(e=>!o.includes(e)).map(e=>(0,h.jsx)(u.MenuItem,{value:e,children:c.EDurationTypes[e]},String(e)))})]}),(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:r,value:l??``,disabled:i,slotProps:{htmlInput:{min:n}},onChange:e=>f?.(parseInt(e.target.value,10))})]})},D=e=>{let{options:t,value:n=[],onChange:r,disabled:i,loading:a,label:o,error:s,helperText:c}=e;return(0,h.jsxs)(u.Box,{children:[o&&(0,h.jsx)(u.Typography,{variant:`caption`,color:s?`error`:`textSecondary`,sx:{mb:.5,display:`block`},children:o}),(0,h.jsx)(u.ToggleButtonGroup,{value:n,onChange:(e,t)=>{r?.(t??[])},disabled:i||a,size:`small`,exclusive:!1,sx:{flexWrap:`wrap`,gap:.5,"& .MuiToggleButtonGroup-grouped":{margin:0,border:`1px solid rgba(0, 0, 0, 0.12) !important`,borderRadius:`4px !important`}},children:t.map(e=>(0,h.jsx)(u.ToggleButton,{value:e.value,sx:{minWidth:40,px:1},children:e.label},e.key))}),c&&(0,h.jsx)(u.FormHelperText,{error:s,children:c})]})},O=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r=[],onChange:i,disabled:a,setOccurs:o,scheduler:s}=e,d=(0,l.useRef)(s);(0,l.useEffect)(()=>{d.current=s},[s]);let f=(0,l.useMemo)(()=>Object.keys(c.EDays).map(e=>t(`scheduler.weekdays.short.${c.EDays[e].toLowerCase()}`)),[t]),p=(0,l.useMemo)(()=>Object.keys(c.EDays).map(e=>t(`scheduler.weekdays.${c.EDays[e].toLowerCase()}`)),[t]),m=e=>e.map((t,n)=>e[(n+c.CFirstDayIdx)%7]),g=m(f),_=m(p),v=g.map((e,t)=>{let n=_[t],r=(0,c.getKeyFromEnum)(c.EDays,n);return{key:`${e}-${t}`,label:e,value:r}}),y=(0,l.useCallback)(e=>{if(i){let n=e;i(n);let r=d.current,a={...r,repeat:{...r.repeat,weekly:{days:n}}};(0,c.handleDurationValueChange)(a.duration,a,o,t)}},[i,o,t]);return(0,h.jsx)(u.Box,{children:(0,h.jsx)(D,{label:t(`scheduler.days`),options:v,value:r,onChange:y,disabled:a,loading:n})})},k=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,onWeeklyChange:a,disabled:o,setOccurs:s,scheduler:d}=e,f=(0,l.useRef)(d);(0,l.useEffect)(()=>{f.current=d},[d]);let p=r?.type||`DAY`,m=(e,n)=>{if(n!==null&&i){let e={...r,type:n,...n===`PERIOD`&&!r?.weekDay?{weekDay:`FIRST`}:{}};i(e);let a=f.current,o={...a,repeat:{...a.repeat,monthly:e}};n===`DAY`?(0,c.handleSelectWeeklyDay)(o.duration.period,o,s,t):(0,c.handleDurationValueChange)(o.duration,o,s,t)}},v=e=>{if(i){let n={...r,monthDay:e};i(n);let a=f.current;(0,c.handleSelectWeeklyDay)(e,{...a,repeat:{...a.repeat,monthly:n}},s,t)}},y=(e,n)=>{if(n!==null&&i){let e={...r,weekDay:n};i(e);let a=f.current,o={...a,repeat:{...a.repeat,monthly:e}};(0,c.handleDurationValueChange)(o.duration,o,s,t)}},b=[{value:`FIRST`,label:t(`scheduler.day.first`)},{value:`SECOND`,label:t(`scheduler.day.second`)},{value:`THIRD`,label:t(`scheduler.day.third`)},{value:`FOURTH`,label:t(`scheduler.day.fourth`)},{value:`LAST`,label:t(`scheduler.day.last`)}];return(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,h.jsxs)(u.ToggleButtonGroup,{value:p,exclusive:!0,onChange:m,disabled:o||n,size:`small`,children:[(0,h.jsxs)(u.ToggleButton,{value:`DAY`,"aria-label":`day`,children:[(0,h.jsx)(g.default,{fontSize:`small`,sx:{mr:1}}),t(`scheduler.day`)]}),(0,h.jsxs)(u.ToggleButton,{value:`PERIOD`,"aria-label":`period`,children:[(0,h.jsx)(_.default,{fontSize:`small`,sx:{mr:1}}),t(`scheduler.meta.period`)]})]}),p===`DAY`?(0,h.jsx)(u.TextField,{label:t(`scheduler.day`),type:`number`,size:`small`,value:r?.monthDay??``,disabled:o||n,slotProps:{htmlInput:{min:1,max:31}},onChange:e=>v(parseInt(e.target.value,10)),sx:{width:120}}):(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,h.jsx)(u.ToggleButtonGroup,{value:r?.weekDay||``,exclusive:!0,onChange:y,disabled:o||n,size:`small`,sx:{flexWrap:`wrap`},children:b.map(e=>(0,h.jsx)(u.ToggleButton,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(O,{value:d.repeat?.weekly?.days,onChange:e=>{a?.(e)},disabled:o,setOccurs:s,scheduler:d})]})]})},A=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,disabled:a,setOccurs:o,scheduler:s,repeatMonthly:d,onMonthlyChange:f,onWeeklyChange:p}=e,m=(0,l.useRef)(s);(0,l.useEffect)(()=>{m.current=s},[s]);let g=(0,l.useMemo)(()=>Object.keys(c.EMonths).map(e=>t(`scheduler.months.${c.EMonths[e].toLowerCase()}`)),[t]),_=(0,l.useMemo)(()=>Object.keys(c.EMonths).map(e=>t(`scheduler.months.short.${c.EMonths[e].toLowerCase()}`)),[t]),v=Object.keys(c.EMonths).map((e,t)=>({key:`${e}-${t}`,label:(0,h.jsx)(u.Tooltip,{title:g[t],children:(0,h.jsx)(`span`,{children:_[t]})}),value:e}));return(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,h.jsx)(D,{label:t(`scheduler.months`),options:v,value:r?.months||[],onChange:e=>{if(i){let n=e,a={...r,months:n};i(a);let s=m.current,l={...s,repeat:{...s.repeat,yearly:a}};(0,c.handleDurationValueChange)(l.duration,l,o,t)}},disabled:a,loading:n}),(0,h.jsx)(k,{value:d,onChange:f,onWeeklyChange:p,disabled:a,setOccurs:o,scheduler:s})]})},j=e=>{let{disabled:t,value:n,startedAt:r,onChange:i}=e,{t:a}=(0,c.useSchedulerContext)(),o=r?(0,m.default)(r).add(1,`day`):(0,m.default)();return(0,h.jsx)(d.DateTimePicker,{label:a(`scheduler.duration.endDate`),value:n??null,onChange:i,disabled:t||!r,minDateTime:o,slotProps:{textField:{size:`small`,fullWidth:!0}}})},M=e=>{let{t}=(0,c.useSchedulerContext)(),{min:n=1,value:r,onChange:i,disabled:a=!1}=e;return(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:t(`scheduler.occurrences`),value:r??``,disabled:a,slotProps:{htmlInput:{min:n}},onChange:e=>i?.(parseInt(e.target.value,10))})},N=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,disabled:a=!1,durationTypes:o=Object.keys(c.EDurationTypes),discountTypes:s=Object.keys(c.EDiscountType),schedulerType:g}=e,_=g===c.ESchedulerPrefix.SALE?c.DEFAULT_SALE_SCHEDULER:c.DEFAULT_DISCOUNT_SCHEDULER,[v,y]=(0,l.useState)(()=>_),b=r??v,[x,S]=(0,l.useState)(`0`),[C,w]=(0,l.useState)(null);(0,l.useEffect)(()=>{b.range?.startedAt&&(0,c.handleChangeStartDate)((0,m.default)(b.range.startedAt),w),b.duration&&(0,c.handleDurationValueChange)(b.duration,b,S,t)},[r,t]);let T=(e,t)=>{let n=e.split(`.`),r=(e,t,n)=>{if(t.length===1)return{...e,[t[0]]:n};let[i,...a]=t;return{...e,[i]:r(e[i]??{},a,n)}},a=r(b,n,t);y(a),i?.(a)};return(0,h.jsx)(f.LocalizationProvider,{dateAdapter:p.AdapterDayjs,children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:3,py:2},children:[[c.ESchedulerPrefix.DISCOUNT,c.ESchedulerPrefix.TRIAL_DISCOUNT].includes(g)&&(0,h.jsx)(u.Grid2,{container:!0,spacing:2,children:(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,gap:1},children:[(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{children:t(`scheduler.meta.duration`)}),(0,h.jsx)(u.Select,{value:b.discount?.type||``,label:t(`scheduler.meta.duration`),disabled:a||n,onChange:e=>T(`discount.type`,e.target.value),children:s.map(e=>(0,h.jsx)(u.MenuItem,{value:e,children:c.EDiscountType[e]},String(e)))})]}),(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:t(`scheduler.meta.duration`),value:b.discount?.value||``,disabled:a||n,onChange:e=>T(`discount.value`,parseInt(e.target.value,10))})]})})}),(0,h.jsxs)(u.Grid2,{container:!0,spacing:2,children:[(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsx)(E,{label:t(`scheduler.duration`),disabled:a||n,typeValue:b.duration?.type,periodValue:b.duration?.period,durationTypes:o,required:!0,onTypeChange:e=>T(`duration.type`,e),onValueChange:e=>T(`duration.period`,e)})}),(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsx)(d.DateTimePicker,{label:t(`scheduler.startedAt`),value:(0,m.default)(b.range?.startedAt),onChange:e=>T(`range.startedAt`,e),disabled:a||n,slotProps:{textField:{size:`small`,fullWidth:!0}}})})]}),b.duration?.type===`WEEK`&&(0,h.jsx)(O,{value:b.repeat?.weekly?.days,onChange:e=>T(`repeat.weekly.days`,e),disabled:a,setOccurs:S,scheduler:b}),b.duration?.type===`MONTH`&&(0,h.jsx)(k,{value:b.repeat?.monthly,onChange:e=>T(`repeat.monthly`,e),onWeeklyChange:e=>T(`repeat.weekly.days`,e),disabled:a,setOccurs:S,scheduler:b}),b.duration?.type===`YEAR`&&(0,h.jsx)(A,{value:b.repeat?.yearly,onChange:e=>T(`repeat.yearly`,e),disabled:a,setOccurs:S,scheduler:b,repeatMonthly:b.repeat?.monthly,onMonthlyChange:e=>T(`repeat.monthly`,e),onWeeklyChange:e=>T(`repeat.weekly.days`,e)}),(0,h.jsxs)(u.Grid2,{container:!0,spacing:2,children:[(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{children:t(`scheduler.duration.end`)}),(0,h.jsx)(u.Select,{value:b.range?.endReason?.type||``,label:t(`scheduler.duration.end`),disabled:a,onChange:e=>T(`range.endReason.type`,e.target.value),children:[{label:t(`scheduler.duration.end.day`),value:c.CEndReasonTypes[0]},{label:t(`scheduler.duration.end.after`),value:c.CEndReasonTypes[1]},{label:t(`scheduler.duration.end.no`),value:c.CEndReasonTypes[2]}].map(e=>(0,h.jsx)(u.MenuItem,{value:e.value,children:e.label},e.value))})]})}),(0,h.jsxs)(u.Grid2,{size:{xs:12,sm:6},children:[b.range?.endReason?.type===c.CEndReasonTypes[0]&&(0,h.jsx)(j,{value:(0,m.default)(b.range?.endReason?.expiredAt),startedAt:(0,m.default)(b.range?.startedAt),onChange:e=>T(`range.endReason.expiredAt`,e),disabled:a}),b.range?.endReason?.type===c.CEndReasonTypes[1]&&(0,h.jsx)(M,{value:b.range?.endReason?.occurrences,onChange:e=>T(`range.endReason.occurrences`,e),disabled:a})]})]}),(0,h.jsx)(u.Typography,{variant:`body2`,sx:{fontStyle:`italic`,color:`text.secondary`},dangerouslySetInnerHTML:{__html:t(`scheduler.result`,{occurs:x,startAt:C??``})}})]})})},P=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{loading:r,className:i,isEdit:a,disabled:o,size:s=`small`,color:l=`primary`,icon:d=(0,h.jsx)(x.default,{fontSize:`small`}),type:f=`button`,variant:p=`contained`,onClick:m}=e;if(!(a?n.canUpdate:n.canCreate))return null;let g=t(a?`actions.update`:`actions.save`);return(0,h.jsx)(u.Button,{type:f,size:s,variant:p,className:i,disabled:o||r,startIcon:r?(0,h.jsx)(u.CircularProgress,{size:16,color:`inherit`}):d,onClick:m,color:l,children:g})},F=({schedulerType:e,disabled:t,onSuccess:n,setDirty:r,dirty:i,isCreating:a,setIsCreating:o,buttonProps:s,open:d,onOpenChange:f,showButton:p=!0})=>{let{t:m,loading:g,permissions:_,onCreate:v}=(0,c.useSchedulerContext)(),[x,S]=(0,l.useState)(!1),C=d===void 0?x:d,w=e=>{f?f(e):S(e)},T=(0,l.useMemo)(()=>e===c.ESchedulerPrefix.SALE?c.DEFAULT_SALE_SCHEDULER:c.DEFAULT_DISCOUNT_SCHEDULER,[e]),[E,D]=(0,l.useState)(T);if((0,l.useEffect)(()=>{C&&D(T)},[C,T]),!_.canCreate)return null;let O=()=>{w(!0)},k=()=>{w(!1),r(!1)},A=async()=>{try{o(!0);let t={id:`new-${Date.now()}`,...E,type:e,[c.CNsDiscount]:e===c.ESchedulerPrefix.SALE?null:E?.[c.CNsDiscount]};v&&await v(e,t),n?.(t),w(!1),r(!1)}catch(e){console.error(`Failed to save scheduler:`,e)}finally{o(!1)}};return(0,h.jsxs)(h.Fragment,{children:[p&&(0,h.jsx)(u.Tooltip,{title:t?m(`scheduler.limited`,{limit:c.DEFAULT_SCHEDULERS_LIMIT}):``,children:(0,h.jsx)(`span`,{children:(0,h.jsx)(u.Button,{variant:`text`,size:`small`,...s,disabled:t||g,onClick:O,sx:{textTransform:`none`,p:0,minWidth:`auto`,...s?.sx},children:m(`scheduler`)})})}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:C,onClose:k,slotProps:{paper:{sx:{width:{xs:`100%`,sm:600},p:0}}},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,h.jsxs)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(y.default,{color:`primary`}),(0,h.jsx)(u.Typography,{variant:`h6`,children:m(`scheduler`)})]}),(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(P,{loading:g||a,disabled:t||!i,onClick:A}),(0,h.jsx)(u.IconButton,{onClick:k,size:`small`,children:(0,h.jsx)(b.default,{})})]})]}),(0,h.jsx)(u.Divider,{}),(0,h.jsx)(u.Box,{sx:{p:3,flexGrow:1,overflowY:`auto`},children:(0,h.jsx)(N,{schedulerType:e,value:E,onChange:e=>{D(e),r(!0)},disabled:t})})]})})]})},I=e=>{let{t}=(0,c.useSchedulerContext)(),{selectedColumns:n=[],columnsList:r=[],onChange:i}=e;if(!r?.length)return(0,h.jsx)(h.Fragment,{});let a=t(`table.hideColumns`);return(0,h.jsxs)(u.FormControl,{sx:{m:1,minWidth:250},size:`small`,children:[(0,h.jsx)(u.InputLabel,{id:`hide-columns-label`,children:a}),(0,h.jsx)(u.Select,{labelId:`hide-columns-label`,id:`hide-columns-select`,multiple:!0,value:n,onChange:e=>{let t=e.target.value,n=typeof t==`string`?t.split(`,`):t;n.length<1||i?.(n)},input:(0,h.jsx)(u.OutlinedInput,{label:a}),renderValue:e=>e.map(e=>r.find(t=>t.value===e)?.label??e).join(`, `),sx:{maxHeight:40},children:r.map(e=>(0,h.jsxs)(u.MenuItem,{value:e.value,children:[(0,h.jsx)(u.Checkbox,{checked:n.indexOf(e.value)>-1,size:`small`}),(0,h.jsx)(u.ListItemText,{primary:e.label})]},e.value))})]})},L=e=>{let{loading:t,t:n}=(0,c.useSchedulerContext)(),{children:r,items:i=[],onRefresh:a}=e,[o,s]=(0,l.useState)(null),d=!!o,f=e=>{s(e.currentTarget)},p=()=>{s(null)};return(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:1,mb:1},children:[r,(0,h.jsx)(u.IconButton,{"aria-label":`more`,id:`toolbar-button`,"aria-controls":d?`toolbar-menu`:void 0,"aria-expanded":d?`true`:void 0,"aria-haspopup":`true`,onClick:f,size:`small`,children:t?(0,h.jsx)(u.CircularProgress,{size:20}):(0,h.jsx)(S.default,{})}),(0,h.jsxs)(u.Menu,{id:`toolbar-menu`,anchorEl:o,open:d,onClose:p,slotProps:{list:{"aria-labelledby":`toolbar-button`}},children:[i.map((e,t)=>(0,h.jsxs)(u.MenuItem,{onClick:()=>{e.onClick&&e.onClick(),p()},children:[e.icon&&(0,h.jsx)(u.ListItemIcon,{children:e.icon}),typeof e.label==`string`?(0,h.jsx)(u.ListItemText,{children:e.label}):(0,h.jsx)(u.Box,{sx:{flexGrow:1,display:`flex`},children:e.label})]},t)),i.length>0&&a&&(0,h.jsx)(u.Divider,{}),a&&(0,h.jsxs)(u.MenuItem,{onClick:()=>{a(),p()},children:[(0,h.jsx)(u.ListItemIcon,{children:(0,h.jsx)(C.default,{fontSize:`small`})}),(0,h.jsx)(u.ListItemText,{children:n(`toolbar.refresh`)})]})]})]})},R={ACTIVE:`success`,DEACTIVATED:`default`,DELETED:`error`,PROCESSING:`info`,PENDING:`warning`,APPROVED:`success`,PUBLISHED:`primary`},z=({status:e})=>(0,h.jsx)(u.Chip,{label:String(e),size:`small`,color:R[e]||`default`,variant:`outlined`}),B=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{entity:r,disabled:i,onDelete:a,showLabel:o=!1}=e,[s,d]=(0,l.useState)(!1);if(!r||!n.canDelete)return null;let f=e=>{e.stopPropagation(),d(!0)},p=e=>{e.stopPropagation(),d(!1)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.Tooltip,{title:t(`actions.delete`),children:(0,h.jsx)(`span`,{children:(0,h.jsxs)(u.IconButton,{color:`error`,size:`small`,onClick:f,disabled:i,children:[(0,h.jsx)(w.default,{fontSize:`small`}),o&&t(`actions.delete`)]})})}),(0,h.jsxs)(u.Dialog,{open:s,onClose:p,onClick:e=>e.stopPropagation(),children:[(0,h.jsx)(u.DialogTitle,{children:t(`actions.delete`)}),(0,h.jsx)(u.DialogContent,{children:(0,h.jsx)(u.DialogContentText,{children:t(`actions.confirm.delete`)})}),(0,h.jsxs)(u.DialogActions,{children:[(0,h.jsx)(u.Button,{onClick:p,size:`small`,children:t(`actions.cancel`)}),(0,h.jsx)(u.Button,{onClick:e=>{e.stopPropagation(),a?.(r),d(!1)},color:`error`,variant:`contained`,size:`small`,autoFocus:!0,children:t(`actions.delete`)})]})]})]})},V=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{entity:r,disabled:i,onEdit:a,showLabel:o=!1}=e;return!r||!n.canUpdate?null:(0,h.jsx)(u.Tooltip,{title:t(`actions.edit`),children:(0,h.jsx)(`span`,{children:(0,h.jsxs)(u.IconButton,{color:`primary`,size:`small`,onClick:e=>{e.stopPropagation(),a?.(r)},disabled:i,children:[(0,h.jsx)(T.default,{fontSize:`small`}),o&&t(`actions.edit`)]})})})},H=e=>(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:e?.days.map((e,t)=>(0,h.jsx)(u.Chip,{label:e,size:`small`,variant:`outlined`,color:`primary`},t))}),U=(e,t)=>e?.type===`PERIOD`?(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:t?.days.map((t,n)=>(0,h.jsx)(u.Chip,{label:`${e.weekDay} ${t}`,size:`small`,variant:`outlined`,color:`secondary`},n))}):(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:(0,h.jsx)(u.Chip,{label:e?.monthDay?.toString(),size:`small`,variant:`outlined`,color:`info`},`monthDay`)}),W=(e,t,n)=>(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:.5},children:[U(t,n),(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:e?.months?.map((e,t)=>(0,h.jsx)(u.Chip,{label:e,size:`small`,variant:`outlined`,color:`warning`},t))})]}),G=e=>{let{disabled:t,schedulerType:n,currency:r,t:i,onEdit:a,onDelete:o}=e;return[{id:`index`,key:`index`,label:`#`,minWidth:50},{id:`duration`,key:`duration`,label:i(`scheduler.meta.duration`),minWidth:120,format:e=>{let t=e;return`${t?.period} (${t?.type})`}},{id:`repeat`,key:`repeat`,label:i(`scheduler.duration`),minWidth:200,format:(e,t)=>{let{duration:n,repeat:r}=t,{weekly:i,monthly:a,yearly:o}=r;switch(n?.type){case`WEEK`:return H(i);case`MONTH`:return U(a,i);case`YEAR`:return W(o,a,i);default:return null}}},[c.ESchedulerPrefix.DISCOUNT,c.ESchedulerPrefix.TRIAL_DISCOUNT].includes(n)?{id:`discount`,key:`discount`,label:i(`scheduler.meta.duration`),minWidth:120,format:e=>{let t=e;return t?t.type===`PERCENT`?`${t.value}${c.CDiscountTypeValues[t.type]}`:(0,c.numberToCurrency)(t.value,r??`USD`):`—`}}:null,{id:`status`,key:`status`,label:i(`scheduler.status`),minWidth:120,align:`center`,concealable:!0,format:e=>(0,h.jsx)(z,{status:e})},{id:`updatedAt`,key:`updatedAt`,label:i(`scheduler.updatedAt`),minWidth:180,align:`center`,concealable:!0,format:e=>{let t=e;return(0,h.jsx)(`span`,{children:t?.updatedAt?(0,c.tsToLocaleDateTime)((0,m.default)(t.updatedAt).toDate()):`—`})}},a||o?{id:`actions`,key:`actions`,label:i(`table.actions`),minWidth:100,align:`center`,format:(e,n)=>(0,h.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`center`,gap:.5},children:[a&&(0,h.jsx)(V,{onEdit:a,disabled:t,entity:n}),o&&(0,h.jsx)(B,{onDelete:o,entity:n,disabled:t})]})}:null].filter(Boolean)},K=e=>e.map((e,t)=>({...e,key:e.id||t.toString(),index:t+1})),q=()=>({title:`#`,dataIndex:`index`,key:`index`,width:50}),J=e=>({title:e(`table.actions`),key:`actions`,width:100}),Y=e=>{let{type:t,title:n,disabled:r,readOnlyFields:i=[],currency:a,onRefresh:o}=e,{schedulers:s,loading:d,disabled:f,t:p,permissions:m,onUpdate:g,onDelete:_}=(0,c.useSchedulerContext)(),x=r??f,[S,C]=(0,l.useState)(new Set),[w,T]=(0,l.useState)(!1),[E,D]=(0,l.useState)(!1),[O,k]=(0,l.useState)(!1),[A,j]=(0,l.useState)(!1),[M,R]=(0,l.useState)(!1),[z,B]=(0,l.useState)(null),[V,H]=(0,l.useState)(0),[U,W]=(0,l.useState)(10),q=(0,l.useMemo)(()=>{let e=s[t]??[];return S.size>0&&(e=e.filter(e=>!e.id||!S.has(e.id))),K(e)},[s,t,S]),J=q.length>=c.DEFAULT_SCHEDULERS_LIMIT,Y=(0,l.useCallback)(e=>{B(JSON.parse(JSON.stringify(e))),R(!0),D(!1)},[]),X=async()=>{if(!(!z||!g))try{await g(t,z),R(!1),B(null),D(!1),o?.()}catch(e){console.error(`Failed to update scheduler:`,e)}},Z=(0,l.useCallback)(async e=>{if(e.id?.startsWith(`new-`)){C(t=>{let n=new Set(t);return e.id&&n.add(e.id),n});return}_&&e.id&&(await _(t,e.id),o?.())},[_,t,o]),{filteredColumns:Q,columnsList:ee,selectedColumns:te,setSelectedColumns:ne}=(0,c.useColumnsToggle)((0,l.useMemo)(()=>G({disabled:x,schedulerType:t,entities:q,currency:a,t:p,onEdit:m.canUpdate?Y:void 0,onDelete:m.canDelete?Z:void 0}),[x,t,q,a,p,m,Y,Z])),re=(e,t)=>{H(t)},ie=e=>{W(parseInt(e.target.value,10)),H(0)},$=q.slice(V*U,V*U+U);return(0,h.jsxs)(u.Paper,{sx:{width:`100%`,overflow:`hidden`,mb:2},children:[(0,h.jsx)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:2},children:(0,h.jsx)(L,{onRefresh:o,items:m.canCreate&&!J?[{label:p(`scheduler`),icon:(0,h.jsx)(v.default,{}),onClick:()=>j(!0)}]:[],children:(0,h.jsx)(I,{columnsList:ee,selectedColumns:te,onChange:ne})})}),(0,h.jsx)(F,{open:A,onOpenChange:j,showButton:!1,schedulerType:t,setDirty:T,dirty:w,isCreating:O,setIsCreating:k,onSuccess:()=>o?.()}),(0,h.jsx)(u.TableContainer,{sx:{maxHeight:440},children:(0,h.jsxs)(u.Table,{stickyHeader:!0,"aria-label":`schedulers table`,size:`small`,children:[(0,h.jsx)(u.TableHead,{children:(0,h.jsx)(u.TableRow,{children:Q.filter(e=>!e.hidden).map(e=>(0,h.jsx)(u.TableCell,{align:e.align,style:{minWidth:e.minWidth},children:e.label},e.id))})}),(0,h.jsxs)(u.TableBody,{children:[$.map(e=>(0,h.jsx)(u.TableRow,{hover:!0,role:`checkbox`,tabIndex:-1,children:Q.filter(e=>!e.hidden).map(t=>{let n=t.id.includes(`.`)?t.id.split(`.`).reduce((e,t)=>e?.[t],e):e[t.id];return(0,h.jsx)(u.TableCell,{align:t.align,children:t.format?t.format(n,e):n},t.id)})},e.key)),$.length===0&&(0,h.jsx)(u.TableRow,{children:(0,h.jsx)(u.TableCell,{colSpan:Q.length,align:`center`,sx:{py:3},children:(0,h.jsx)(u.Typography,{variant:`body2`,color:`text.secondary`,children:`No items found`})})})]})]})}),(0,h.jsx)(u.TablePagination,{rowsPerPageOptions:[5,10,25,100],component:`div`,count:q.length,rowsPerPage:U,page:V,onPageChange:re,onRowsPerPageChange:ie}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:M,onClose:()=>{R(!1),B(null)},slotProps:{paper:{sx:{width:{xs:`100%`,sm:600},p:0}}},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,h.jsxs)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(y.default,{color:`primary`}),(0,h.jsx)(u.Typography,{variant:`h6`,children:n??p(`scheduler`)})]}),(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(P,{isEdit:!0,loading:d,disabled:x||!E||O,onClick:X}),(0,h.jsx)(u.IconButton,{onClick:()=>R(!1),size:`small`,children:(0,h.jsx)(b.default,{})})]})]}),(0,h.jsx)(u.Divider,{}),(0,h.jsx)(u.Box,{sx:{p:3,flexGrow:1,overflowY:`auto`},children:M&&z&&(0,h.jsx)(N,{schedulerType:t,value:z,onChange:e=>{B(e),D(!0)},disabled:x,readOnlyFields:i})})]})})]})};exports.Scheduler=N,exports.SchedulerDrawerButton=F,exports.SchedulersList=Y,exports.actionField=J,exports.indexColumn=q,exports.indexable=K,Object.keys(c).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[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,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},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@teamco/ischeduler-core`),l=require(`react`);l=s(l);let u=require(`@mui/material`),d=require(`@mui/x-date-pickers/DateTimePicker`),f=require(`@mui/x-date-pickers/LocalizationProvider`),p=require(`@mui/x-date-pickers/AdapterDayjs`),m=require(`dayjs`);m=s(m);let h=require(`react/jsx-runtime`),g=require(`@mui/icons-material/CalendarMonth`);g=s(g);let _=require(`@mui/icons-material/Settings`);_=s(_);let v=require(`@mui/icons-material/Add`);v=s(v);let y=require(`@mui/icons-material/DateRange`);y=s(y);let b=require(`@mui/icons-material/Close`);b=s(b);let x=require(`@mui/icons-material/Save`);x=s(x);let S=require(`@mui/icons-material/MoreVert`);S=s(S);let C=require(`@mui/icons-material/Refresh`);C=s(C);let w=require(`@mui/icons-material/Delete`);w=s(w);let T=require(`@mui/icons-material/Edit`);T=s(T);var E=e=>{let{t}=(0,c.useSchedulerContext)(),{min:n=1,label:r,disabled:i,durationTypes:a=[],exclude:o=[],typeValue:s,periodValue:l,onTypeChange:d,onValueChange:f}=e;return(0,h.jsxs)(u.Box,{sx:{display:`flex`,gap:1,width:`100%`},children:[(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{id:`duration-type-label`,children:t(`scheduler.meta.period`)}),(0,h.jsx)(u.Select,{labelId:`duration-type-label`,value:s||``,label:t(`scheduler.meta.period`),disabled:i,onChange:e=>d?.(e.target.value),children:a.filter(e=>!o.includes(e)).map(e=>(0,h.jsx)(u.MenuItem,{value:e,children:c.EDurationTypes[e]},String(e)))})]}),(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:r,value:l??``,disabled:i,slotProps:{htmlInput:{min:n}},onChange:e=>f?.(parseInt(e.target.value,10))})]})},D=e=>{let{options:t,value:n=[],onChange:r,disabled:i,loading:a,label:o,error:s,helperText:c}=e;return(0,h.jsxs)(u.Box,{children:[o&&(0,h.jsx)(u.Typography,{variant:`caption`,color:s?`error`:`textSecondary`,sx:{mb:.5,display:`block`},children:o}),(0,h.jsx)(u.ToggleButtonGroup,{value:n,onChange:(e,t)=>{r?.(t??[])},disabled:i||a,size:`small`,exclusive:!1,sx:{flexWrap:`wrap`,gap:.5,"& .MuiToggleButtonGroup-grouped":{margin:0,border:`1px solid rgba(0, 0, 0, 0.12) !important`,borderRadius:`4px !important`}},children:t.map(e=>(0,h.jsx)(u.ToggleButton,{value:e.value,sx:{minWidth:40,px:1},children:e.label},e.key))}),c&&(0,h.jsx)(u.FormHelperText,{error:s,children:c})]})},O=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r=[],onChange:i,disabled:a,setOccurs:o,scheduler:s}=e,d=(0,l.useRef)(s);(0,l.useEffect)(()=>{d.current=s},[s]);let f=(0,l.useMemo)(()=>Object.keys(c.EDays).map(e=>t(`scheduler.weekdays.short.${c.EDays[e].toLowerCase()}`)),[t]),p=(0,l.useMemo)(()=>Object.keys(c.EDays).map(e=>t(`scheduler.weekdays.${c.EDays[e].toLowerCase()}`)),[t]),m=e=>e.map((t,n)=>e[(n+c.CFirstDayIdx)%7]),g=m(f),_=m(p),v=g.map((e,t)=>{let n=_[t],r=(0,c.getKeyFromEnum)(c.EDays,n);return{key:`${e}-${t}`,label:e,value:r}}),y=(0,l.useCallback)(e=>{if(i){let n=e;i(n);let r=d.current,a={...r,repeat:{...r.repeat,weekly:{days:n}}};(0,c.handleDurationValueChange)(a.duration,a,o,t)}},[i,o,t]);return(0,h.jsx)(u.Box,{children:(0,h.jsx)(D,{label:t(`scheduler.days`),options:v,value:r,onChange:y,disabled:a,loading:n})})},k=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,onWeeklyChange:a,disabled:o,setOccurs:s,scheduler:d}=e,f=(0,l.useRef)(d);(0,l.useEffect)(()=>{f.current=d},[d]);let p=r?.type||`DAY`,m=(e,n)=>{if(n!==null&&i){let e={...r,type:n,...n===`PERIOD`&&!r?.weekDay?{weekDay:`FIRST`}:{}};i(e);let a=f.current,o={...a,repeat:{...a.repeat,monthly:e}};n===`DAY`?(0,c.handleSelectWeeklyDay)(o.duration.period,o,s,t):(0,c.handleDurationValueChange)(o.duration,o,s,t)}},v=e=>{if(i){let n={...r,monthDay:e};i(n);let a=f.current;(0,c.handleSelectWeeklyDay)(e,{...a,repeat:{...a.repeat,monthly:n}},s,t)}},y=(e,n)=>{if(n!==null&&i){let e={...r,weekDay:n};i(e);let a=f.current,o={...a,repeat:{...a.repeat,monthly:e}};(0,c.handleDurationValueChange)(o.duration,o,s,t)}},b=[{value:`FIRST`,label:t(`scheduler.day.first`)},{value:`SECOND`,label:t(`scheduler.day.second`)},{value:`THIRD`,label:t(`scheduler.day.third`)},{value:`FOURTH`,label:t(`scheduler.day.fourth`)},{value:`LAST`,label:t(`scheduler.day.last`)}];return(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,h.jsxs)(u.ToggleButtonGroup,{value:p,exclusive:!0,onChange:m,disabled:o||n,size:`small`,children:[(0,h.jsxs)(u.ToggleButton,{value:`DAY`,"aria-label":`day`,children:[(0,h.jsx)(g.default,{fontSize:`small`,sx:{mr:1}}),t(`scheduler.day`)]}),(0,h.jsxs)(u.ToggleButton,{value:`PERIOD`,"aria-label":`period`,children:[(0,h.jsx)(_.default,{fontSize:`small`,sx:{mr:1}}),t(`scheduler.meta.period`)]})]}),p===`DAY`?(0,h.jsx)(u.TextField,{label:t(`scheduler.day`),type:`number`,size:`small`,value:r?.monthDay??``,disabled:o||n,slotProps:{htmlInput:{min:1,max:31}},onChange:e=>v(parseInt(e.target.value,10)),sx:{width:120}}):(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,h.jsx)(u.ToggleButtonGroup,{value:r?.weekDay||``,exclusive:!0,onChange:y,disabled:o||n,size:`small`,sx:{flexWrap:`wrap`},children:b.map(e=>(0,h.jsx)(u.ToggleButton,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(O,{value:d.repeat?.weekly?.days,onChange:e=>{a?.(e)},disabled:o,setOccurs:s,scheduler:d})]})]})},A=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,disabled:a,setOccurs:o,scheduler:s,repeatMonthly:d,onMonthlyChange:f,onWeeklyChange:p}=e,m=(0,l.useRef)(s);(0,l.useEffect)(()=>{m.current=s},[s]);let g=(0,l.useMemo)(()=>Object.keys(c.EMonths).map(e=>t(`scheduler.months.${c.EMonths[e].toLowerCase()}`)),[t]),_=(0,l.useMemo)(()=>Object.keys(c.EMonths).map(e=>t(`scheduler.months.short.${c.EMonths[e].toLowerCase()}`)),[t]),v=Object.keys(c.EMonths).map((e,t)=>({key:`${e}-${t}`,label:(0,h.jsx)(u.Tooltip,{title:g[t],children:(0,h.jsx)(`span`,{children:_[t]})}),value:e}));return(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:3},children:[(0,h.jsx)(D,{label:t(`scheduler.months`),options:v,value:r?.months||[],onChange:e=>{if(i){let n=e,a={...r,months:n};i(a);let s=m.current,l={...s,repeat:{...s.repeat,yearly:a}};(0,c.handleDurationValueChange)(l.duration,l,o,t)}},disabled:a,loading:n}),(0,h.jsx)(k,{value:d,onChange:f,onWeeklyChange:p,disabled:a,setOccurs:o,scheduler:s})]})},j=e=>{let{disabled:t,value:n,startedAt:r,onChange:i}=e,{t:a}=(0,c.useSchedulerContext)(),o=r?(0,m.default)(r).add(1,`day`):(0,m.default)();return(0,h.jsx)(d.DateTimePicker,{label:a(`scheduler.duration.endDate`),value:n??null,onChange:i,disabled:t||!r,minDateTime:o,slotProps:{textField:{size:`small`,fullWidth:!0}}})},M=e=>{let{t}=(0,c.useSchedulerContext)(),{min:n=1,value:r,onChange:i,disabled:a=!1}=e;return(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:t(`scheduler.occurrences`),value:r??``,disabled:a,slotProps:{htmlInput:{min:n}},onChange:e=>i?.(parseInt(e.target.value,10))})},N=e=>{let{t,loading:n}=(0,c.useSchedulerContext)(),{value:r,onChange:i,disabled:a=!1,durationTypes:o=Object.keys(c.EDurationTypes),discountTypes:s=Object.keys(c.EDiscountType),schedulerType:g}=e,_=(0,l.useMemo)(()=>g===c.ESchedulerPrefix.SALE?c.DEFAULT_SALE_SCHEDULER:c.DEFAULT_DISCOUNT_SCHEDULER,[g]),[v,y]=(0,l.useState)(()=>r??_),b=r??v,[x,S]=(0,l.useState)(`0`),[C,w]=(0,l.useState)(null),[T,D]=(0,l.useState)(r);r!==T&&(y(r??_),D(r)),(0,l.useEffect)(()=>{b.range?.startedAt&&(0,c.handleChangeStartDate)((0,m.default)(b.range.startedAt),w),b.duration&&(0,c.handleDurationValueChange)(b.duration,b,S,t)},[b,t]);let N=(e,t)=>{let n=e.split(`.`),r=(e,t,n)=>{if(t.length===1)return{...e,[t[0]]:n};let[i,...a]=t;return{...e,[i]:r(e[i]??{},a,n)}},a=r(b,n,t);y(a),i?.(a)};return(0,h.jsx)(f.LocalizationProvider,{dateAdapter:p.AdapterDayjs,children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:3,py:2},children:[[c.ESchedulerPrefix.DISCOUNT,c.ESchedulerPrefix.TRIAL_DISCOUNT].includes(g)&&(0,h.jsx)(u.Grid2,{container:!0,spacing:2,children:(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,gap:1},children:[(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{children:t(`scheduler.meta.duration`)}),(0,h.jsx)(u.Select,{value:b.discount?.type||``,label:t(`scheduler.meta.duration`),disabled:a||n,onChange:e=>N(`discount.type`,e.target.value),children:s.map(e=>(0,h.jsx)(u.MenuItem,{value:e,children:c.EDiscountType[e]},String(e)))})]}),(0,h.jsx)(u.TextField,{fullWidth:!0,size:`small`,type:`number`,label:t(`scheduler.meta.duration`),value:b.discount?.value??``,disabled:a||n,onChange:e=>N(`discount.value`,parseInt(e.target.value,10))})]})})}),(0,h.jsxs)(u.Grid2,{container:!0,spacing:2,children:[(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsx)(E,{label:t(`scheduler.duration`),disabled:a||n,typeValue:b.duration?.type,periodValue:b.duration?.period,durationTypes:o,required:!0,onTypeChange:e=>N(`duration.type`,e),onValueChange:e=>N(`duration.period`,e)})}),(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsx)(d.DateTimePicker,{label:t(`scheduler.startedAt`),value:(0,m.default)(b.range?.startedAt),onChange:e=>N(`range.startedAt`,e),disabled:a||n,slotProps:{textField:{size:`small`,fullWidth:!0}}})})]}),b.duration?.type===`WEEK`&&(0,h.jsx)(O,{value:b.repeat?.weekly?.days,onChange:e=>N(`repeat.weekly.days`,e),disabled:a,setOccurs:S,scheduler:b}),b.duration?.type===`MONTH`&&(0,h.jsx)(k,{value:b.repeat?.monthly,onChange:e=>N(`repeat.monthly`,e),onWeeklyChange:e=>N(`repeat.weekly.days`,e),disabled:a,setOccurs:S,scheduler:b}),b.duration?.type===`YEAR`&&(0,h.jsx)(A,{value:b.repeat?.yearly,onChange:e=>N(`repeat.yearly`,e),disabled:a,setOccurs:S,scheduler:b,repeatMonthly:b.repeat?.monthly,onMonthlyChange:e=>N(`repeat.monthly`,e),onWeeklyChange:e=>N(`repeat.weekly.days`,e)}),(0,h.jsxs)(u.Grid2,{container:!0,spacing:2,children:[(0,h.jsx)(u.Grid2,{size:{xs:12,sm:6},children:(0,h.jsxs)(u.FormControl,{fullWidth:!0,size:`small`,children:[(0,h.jsx)(u.InputLabel,{children:t(`scheduler.duration.end`)}),(0,h.jsx)(u.Select,{value:b.range?.endReason?.type||``,label:t(`scheduler.duration.end`),disabled:a,onChange:e=>N(`range.endReason.type`,e.target.value),children:[{label:t(`scheduler.duration.end.day`),value:c.CEndReasonTypes[0]},{label:t(`scheduler.duration.end.after`),value:c.CEndReasonTypes[1]},{label:t(`scheduler.duration.end.no`),value:c.CEndReasonTypes[2]}].map(e=>(0,h.jsx)(u.MenuItem,{value:e.value,children:e.label},e.value))})]})}),(0,h.jsxs)(u.Grid2,{size:{xs:12,sm:6},children:[b.range?.endReason?.type===c.CEndReasonTypes[0]&&(0,h.jsx)(j,{value:(0,m.default)(b.range?.endReason?.expiredAt),startedAt:(0,m.default)(b.range?.startedAt),onChange:e=>N(`range.endReason.expiredAt`,e),disabled:a}),b.range?.endReason?.type===c.CEndReasonTypes[1]&&(0,h.jsx)(M,{value:b.range?.endReason?.occurrences,onChange:e=>N(`range.endReason.occurrences`,e),disabled:a})]})]}),(0,h.jsx)(u.Typography,{variant:`body2`,sx:{fontStyle:`italic`,color:`text.secondary`},dangerouslySetInnerHTML:{__html:t(`scheduler.result`,{occurs:x,startAt:C??``})}})]})})},P=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{loading:r,className:i,isEdit:a,disabled:o,size:s=`small`,color:l=`primary`,icon:d=(0,h.jsx)(x.default,{fontSize:`small`}),type:f=`button`,variant:p=`contained`,onClick:m}=e;if(!(a?n.canUpdate:n.canCreate))return null;let g=t(a?`actions.update`:`actions.save`);return(0,h.jsx)(u.Button,{type:f,size:s,variant:p,className:i,disabled:o||r,startIcon:r?(0,h.jsx)(u.CircularProgress,{size:16,color:`inherit`}):d,onClick:m,color:l,children:g})},F=({schedulerType:e,disabled:t,onSuccess:n,setDirty:r,dirty:i,isCreating:a,setIsCreating:o,buttonProps:s,open:d,onOpenChange:f,showButton:p=!0})=>{let{t:m,loading:g,permissions:_,onCreate:v,limit:x=c.DEFAULT_SCHEDULERS_LIMIT}=(0,c.useSchedulerContext)(),[S,C]=(0,l.useState)(!1),w=d===void 0?S:d,T=e=>{f?f(e):C(e)},E=(0,l.useMemo)(()=>e===c.ESchedulerPrefix.SALE?c.DEFAULT_SALE_SCHEDULER:c.DEFAULT_DISCOUNT_SCHEDULER,[e]),[D,O]=(0,l.useState)(E);if((0,l.useEffect)(()=>{w&&O(E)},[w,E]),!_.canCreate)return null;let k=()=>{T(!0)},A=()=>{T(!1),r(!1)},j=async()=>{try{o(!0);let t={id:`new-${Date.now()}`,...D,type:e,[c.CNsDiscount]:e===c.ESchedulerPrefix.SALE?null:D?.[c.CNsDiscount]};v&&await v(e,t),n?.(t),T(!1),r(!1)}catch(e){console.error(`Failed to save scheduler:`,e)}finally{o(!1)}};return(0,h.jsxs)(h.Fragment,{children:[p&&(0,h.jsx)(u.Tooltip,{title:t?m(`scheduler.limited`,{limit:x}):``,children:(0,h.jsx)(`span`,{children:(0,h.jsx)(u.Button,{variant:`text`,size:`small`,...s,disabled:t||g,onClick:k,sx:{textTransform:`none`,p:0,minWidth:`auto`,...s?.sx},children:m(`scheduler`)})})}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:w,onClose:A,slotProps:{paper:{sx:{width:{xs:`100%`,sm:600},p:0}}},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,h.jsxs)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(y.default,{color:`primary`}),(0,h.jsx)(u.Typography,{variant:`h6`,children:m(`scheduler`)})]}),(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(P,{loading:g||a,disabled:t||!i,onClick:j}),(0,h.jsx)(u.IconButton,{onClick:A,size:`small`,children:(0,h.jsx)(b.default,{})})]})]}),(0,h.jsx)(u.Divider,{}),(0,h.jsx)(u.Box,{sx:{p:3,flexGrow:1,overflowY:`auto`},children:(0,h.jsx)(N,{schedulerType:e,value:D,onChange:e=>{O(e),r(!0)},disabled:t})})]})})]})},I=e=>{let{t}=(0,c.useSchedulerContext)(),{selectedColumns:n=[],columnsList:r=[],onChange:i}=e;if(!r?.length)return(0,h.jsx)(h.Fragment,{});let a=t(`table.hideColumns`);return(0,h.jsxs)(u.FormControl,{sx:{m:1,minWidth:250},size:`small`,children:[(0,h.jsx)(u.InputLabel,{id:`hide-columns-label`,children:a}),(0,h.jsx)(u.Select,{labelId:`hide-columns-label`,id:`hide-columns-select`,multiple:!0,value:n,onChange:e=>{let t=e.target.value,n=typeof t==`string`?t.split(`,`):t;n.length<1||i?.(n)},input:(0,h.jsx)(u.OutlinedInput,{label:a}),renderValue:e=>e.map(e=>r.find(t=>t.value===e)?.label??e).join(`, `),sx:{maxHeight:40},children:r.map(e=>(0,h.jsxs)(u.MenuItem,{value:e.value,children:[(0,h.jsx)(u.Checkbox,{checked:n.indexOf(e.value)>-1,size:`small`}),(0,h.jsx)(u.ListItemText,{primary:e.label})]},e.value))})]})},L=e=>{let{loading:t,t:n}=(0,c.useSchedulerContext)(),{children:r,items:i=[],onRefresh:a}=e,[o,s]=(0,l.useState)(null),d=!!o,f=e=>{s(e.currentTarget)},p=()=>{s(null)};return(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:1,mb:1},children:[r,(0,h.jsx)(u.IconButton,{"aria-label":`more`,id:`toolbar-button`,"aria-controls":d?`toolbar-menu`:void 0,"aria-expanded":d?`true`:void 0,"aria-haspopup":`true`,onClick:f,size:`small`,children:t?(0,h.jsx)(u.CircularProgress,{size:20}):(0,h.jsx)(S.default,{})}),(0,h.jsxs)(u.Menu,{id:`toolbar-menu`,anchorEl:o,open:d,onClose:p,slotProps:{list:{"aria-labelledby":`toolbar-button`}},children:[i.map((e,t)=>(0,h.jsxs)(u.MenuItem,{onClick:()=>{e.onClick&&e.onClick(),p()},children:[e.icon&&(0,h.jsx)(u.ListItemIcon,{children:e.icon}),typeof e.label==`string`?(0,h.jsx)(u.ListItemText,{children:e.label}):(0,h.jsx)(u.Box,{sx:{flexGrow:1,display:`flex`},children:e.label})]},t)),i.length>0&&a&&(0,h.jsx)(u.Divider,{}),a&&(0,h.jsxs)(u.MenuItem,{onClick:()=>{a(),p()},children:[(0,h.jsx)(u.ListItemIcon,{children:(0,h.jsx)(C.default,{fontSize:`small`})}),(0,h.jsx)(u.ListItemText,{children:n(`toolbar.refresh`)})]})]})]})},R={ACTIVE:`success`,DEACTIVATED:`default`,DELETED:`error`,PROCESSING:`info`,PENDING:`warning`,APPROVED:`success`,PUBLISHED:`primary`},z=({status:e})=>(0,h.jsx)(u.Chip,{label:String(e),size:`small`,color:R[e]||`default`,variant:`outlined`}),B=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{entity:r,disabled:i,onDelete:a,showLabel:o=!1}=e,[s,d]=(0,l.useState)(!1);if(!r||!n.canDelete)return null;let f=e=>{e.stopPropagation(),d(!0)},p=e=>{e.stopPropagation(),d(!1)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.Tooltip,{title:t(`actions.delete`),children:(0,h.jsx)(`span`,{children:(0,h.jsxs)(u.IconButton,{color:`error`,size:`small`,onClick:f,disabled:i,children:[(0,h.jsx)(w.default,{fontSize:`small`}),o&&t(`actions.delete`)]})})}),(0,h.jsxs)(u.Dialog,{open:s,onClose:p,onClick:e=>e.stopPropagation(),children:[(0,h.jsx)(u.DialogTitle,{children:t(`actions.delete`)}),(0,h.jsx)(u.DialogContent,{children:(0,h.jsx)(u.DialogContentText,{children:t(`actions.confirm.delete`)})}),(0,h.jsxs)(u.DialogActions,{children:[(0,h.jsx)(u.Button,{onClick:p,size:`small`,children:t(`actions.cancel`)}),(0,h.jsx)(u.Button,{onClick:e=>{e.stopPropagation(),a?.(r),d(!1)},color:`error`,variant:`contained`,size:`small`,autoFocus:!0,children:t(`actions.delete`)})]})]})]})},V=e=>{let{t,permissions:n}=(0,c.useSchedulerContext)(),{entity:r,disabled:i,onEdit:a,showLabel:o=!1}=e;return!r||!n.canUpdate?null:(0,h.jsx)(u.Tooltip,{title:t(`actions.edit`),children:(0,h.jsx)(`span`,{children:(0,h.jsxs)(u.IconButton,{color:`primary`,size:`small`,onClick:e=>{e.stopPropagation(),a?.(r)},disabled:i,children:[(0,h.jsx)(T.default,{fontSize:`small`}),o&&t(`actions.edit`)]})})})},H=e=>(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:e?.days.map((e,t)=>(0,h.jsx)(u.Chip,{label:e,size:`small`,variant:`outlined`,color:`primary`},t))}),U=(e,t)=>e?.type===`PERIOD`?(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:t?.days.map((t,n)=>(0,h.jsx)(u.Chip,{label:`${e.weekDay} ${t}`,size:`small`,variant:`outlined`,color:`secondary`},n))}):(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:(0,h.jsx)(u.Chip,{label:e?.monthDay?.toString(),size:`small`,variant:`outlined`,color:`info`},`monthDay`)}),W=(e,t,n)=>(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,gap:.5},children:[U(t,n),(0,h.jsx)(u.Box,{sx:{display:`flex`,flexWrap:`wrap`,gap:.5},children:e?.months?.map((e,t)=>(0,h.jsx)(u.Chip,{label:e,size:`small`,variant:`outlined`,color:`warning`},t))})]}),G=e=>{let{disabled:t,schedulerType:n,currency:r,t:i,onEdit:a,onDelete:o}=e;return[{id:`index`,key:`index`,label:`#`,minWidth:50},{id:`duration`,key:`duration`,label:i(`scheduler.meta.duration`),minWidth:120,format:e=>{let t=e;return`${t?.period} (${t?.type})`}},{id:`repeat`,key:`repeat`,label:i(`scheduler.duration`),minWidth:200,format:(e,t)=>{let{duration:n,repeat:r}=t,{weekly:i,monthly:a,yearly:o}=r;switch(n?.type){case`WEEK`:return H(i);case`MONTH`:return U(a,i);case`YEAR`:return W(o,a,i);default:return null}}},[c.ESchedulerPrefix.DISCOUNT,c.ESchedulerPrefix.TRIAL_DISCOUNT].includes(n)?{id:`discount`,key:`discount`,label:i(`scheduler.meta.duration`),minWidth:120,format:e=>{let t=e;return t?t.type===`PERCENT`?`${t.value}${c.CDiscountTypeValues[t.type]}`:(0,c.numberToCurrency)(t.value,r??`USD`):`—`}}:null,{id:`status`,key:`status`,label:i(`scheduler.status`),minWidth:120,align:`center`,concealable:!0,format:e=>(0,h.jsx)(z,{status:e})},{id:`updatedAt`,key:`updatedAt`,label:i(`scheduler.updatedAt`),minWidth:180,align:`center`,concealable:!0,format:e=>{let t=e;return(0,h.jsx)(`span`,{children:t?.updatedAt?(0,c.tsToLocaleDateTime)((0,m.default)(t.updatedAt).toDate()):`—`})}},a||o?{id:`actions`,key:`actions`,label:i(`table.actions`),minWidth:100,align:`center`,format:(e,n)=>(0,h.jsxs)(u.Box,{sx:{display:`flex`,justifyContent:`center`,gap:.5},children:[a&&(0,h.jsx)(V,{onEdit:a,disabled:t,entity:n}),o&&(0,h.jsx)(B,{onDelete:o,entity:n,disabled:t})]})}:null].filter(Boolean)},K=e=>e.map((e,t)=>({...e,key:e.id||t.toString(),index:t+1})),q=()=>({title:`#`,dataIndex:`index`,key:`index`,width:50}),J=e=>({title:e(`table.actions`),key:`actions`,width:100}),Y=e=>{let{type:t,title:n,disabled:r,readOnlyFields:i=[],currency:a,onRefresh:o}=e,{schedulers:s,loading:d,limit:f=c.DEFAULT_SCHEDULERS_LIMIT,disabled:p,t:m,permissions:g,onUpdate:_,onDelete:x}=(0,c.useSchedulerContext)(),S=r??p,[C,w]=(0,l.useState)(new Set),[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(!1),[k,A]=(0,l.useState)(!1),[j,M]=(0,l.useState)(!1),[R,z]=(0,l.useState)(!1),[B,V]=(0,l.useState)(null),[H,U]=(0,l.useState)(0),[W,q]=(0,l.useState)(10),J=(0,l.useMemo)(()=>{let e=s[t]??[];return C.size>0&&(e=e.filter(e=>!e.id||!C.has(e.id))),K(e)},[s,t,C]),Y=J.length>=f,X=(0,l.useCallback)(e=>{V(JSON.parse(JSON.stringify(e))),z(!0),O(!1)},[]),ee=async()=>{if(!(!B||!_))try{await _(t,B),z(!1),V(null),O(!1),o?.()}catch(e){console.error(`Failed to update scheduler:`,e)}},Z=(0,l.useCallback)(async e=>{if(e.id?.startsWith(`new-`)){w(t=>{let n=new Set(t);return e.id&&n.add(e.id),n});return}x&&e.id&&(await x(t,e.id),o?.())},[x,t,o]),{filteredColumns:Q,columnsList:te,selectedColumns:ne,setSelectedColumns:re}=(0,c.useColumnsToggle)((0,l.useMemo)(()=>G({disabled:S,schedulerType:t,entities:J,currency:a,t:m,onEdit:g.canUpdate?X:void 0,onDelete:g.canDelete?Z:void 0}),[S,t,J,a,m,g,X,Z])),ie=(e,t)=>{U(t)},ae=e=>{q(parseInt(e.target.value,10)),U(0)},$=J.slice(H*W,H*W+W);return(0,h.jsxs)(u.Paper,{sx:{width:`100%`,overflow:`hidden`,mb:2},children:[(0,h.jsx)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`flex-end`,gap:2},children:(0,h.jsx)(L,{onRefresh:o,items:g.canCreate&&!Y?[{label:m(`scheduler`),icon:(0,h.jsx)(v.default,{}),onClick:()=>M(!0)}]:[],children:(0,h.jsx)(I,{columnsList:te,selectedColumns:ne,onChange:re})})}),(0,h.jsx)(F,{open:j,onOpenChange:M,showButton:!1,schedulerType:t,setDirty:E,dirty:T,isCreating:k,setIsCreating:A,onSuccess:()=>o?.()}),(0,h.jsx)(u.TableContainer,{sx:{maxHeight:440},children:(0,h.jsxs)(u.Table,{stickyHeader:!0,"aria-label":`schedulers table`,size:`small`,children:[(0,h.jsx)(u.TableHead,{children:(0,h.jsx)(u.TableRow,{children:Q.filter(e=>!e.hidden).map(e=>(0,h.jsx)(u.TableCell,{align:e.align,style:{minWidth:e.minWidth},children:e.label},e.id))})}),(0,h.jsxs)(u.TableBody,{children:[$.map(e=>(0,h.jsx)(u.TableRow,{hover:!0,role:`checkbox`,tabIndex:-1,children:Q.filter(e=>!e.hidden).map(t=>{let n=t.id.includes(`.`)?t.id.split(`.`).reduce((e,t)=>e?.[t],e):e[t.id];return(0,h.jsx)(u.TableCell,{align:t.align,children:t.format?t.format(n,e):n},t.id)})},e.key)),$.length===0&&(0,h.jsx)(u.TableRow,{children:(0,h.jsx)(u.TableCell,{colSpan:Q.length,align:`center`,sx:{py:3},children:(0,h.jsx)(u.Typography,{variant:`body2`,color:`text.secondary`,children:`No items found`})})})]})]})}),(0,h.jsx)(u.TablePagination,{rowsPerPageOptions:[5,10,25,100],component:`div`,count:J.length,rowsPerPage:W,page:H,onPageChange:ie,onRowsPerPageChange:ae}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:R,onClose:()=>{z(!1),V(null)},slotProps:{paper:{sx:{width:{xs:`100%`,sm:600},p:0}}},children:(0,h.jsxs)(u.Box,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[(0,h.jsxs)(u.Box,{sx:{p:2,display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(y.default,{color:`primary`}),(0,h.jsx)(u.Typography,{variant:`h6`,children:n??m(`scheduler`)})]}),(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(P,{isEdit:!0,loading:d,disabled:S||!D||k,onClick:ee}),(0,h.jsx)(u.IconButton,{onClick:()=>z(!1),size:`small`,children:(0,h.jsx)(b.default,{})})]})]}),(0,h.jsx)(u.Divider,{}),(0,h.jsx)(u.Box,{sx:{p:3,flexGrow:1,overflowY:`auto`},children:R&&B&&(0,h.jsx)(N,{schedulerType:t,value:B,onChange:e=>{V(e),O(!0)},disabled:S,readOnlyFields:i})})]})})]})};exports.Scheduler=N,exports.SchedulerDrawerButton=F,exports.SchedulersList=Y,exports.actionField=J,exports.indexColumn=q,exports.indexable=K,Object.keys(c).forEach(function(e){e!==`default`&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[e]}})});
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CDiscountTypeValues as e, CEndReasonTypes as t, CFirstDayIdx as n, CNsDiscount as r, DEFAULT_DISCOUNT_SCHEDULER as i, DEFAULT_SALE_SCHEDULER as a, DEFAULT_SCHEDULERS_LIMIT as o, EDays as s, EDiscountType as c, EDurationTypes as l, EMonths as u, ESchedulerPrefix as d, getKeyFromEnum as f, handleChangeStartDate as p, handleDurationValueChange as m, handleSelectWeeklyDay as h, numberToCurrency as g, tsToLocaleDateTime as _, useColumnsToggle as v, useSchedulerContext as y } from "@teamco/ischeduler-core";
|
|
2
2
|
import { useCallback as b, useEffect as x, useMemo as S, useRef as C, useState as w } from "react";
|
|
3
|
-
import { Box as T, Button as E, Checkbox as D, Chip as O, CircularProgress as k, Dialog as A, DialogActions as j, DialogContent as M, DialogContentText as N, DialogTitle as P, Divider as
|
|
3
|
+
import { Box as T, Button as E, Checkbox as D, Chip as O, CircularProgress as k, Dialog as A, DialogActions as j, DialogContent as M, DialogContentText as N, DialogTitle as P, Divider as ee, Drawer as te, FormControl as F, FormHelperText as I, Grid2 as L, IconButton as R, InputLabel as z, ListItemIcon as B, ListItemText as V, Menu as H, MenuItem as U, OutlinedInput as ne, Paper as re, Select as W, Table as ie, TableBody as ae, TableCell as oe, TableContainer as se, TableHead as ce, TablePagination as le, TableRow as G, TextField as K, ToggleButton as q, ToggleButtonGroup as J, Tooltip as Y, Typography as X } from "@mui/material";
|
|
4
4
|
import { DateTimePicker as ue } from "@mui/x-date-pickers/DateTimePicker";
|
|
5
5
|
import { LocalizationProvider as de } from "@mui/x-date-pickers/LocalizationProvider";
|
|
6
6
|
import { AdapterDayjs as fe } from "@mui/x-date-pickers/AdapterDayjs";
|
|
@@ -26,10 +26,10 @@ var we = (e) => {
|
|
|
26
26
|
gap: 1,
|
|
27
27
|
width: "100%"
|
|
28
28
|
},
|
|
29
|
-
children: [/* @__PURE__ */ $(
|
|
29
|
+
children: [/* @__PURE__ */ $(F, {
|
|
30
30
|
fullWidth: !0,
|
|
31
31
|
size: "small",
|
|
32
|
-
children: [/* @__PURE__ */ Q(
|
|
32
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
33
33
|
id: "duration-type-label",
|
|
34
34
|
children: t("scheduler.meta.period")
|
|
35
35
|
}), /* @__PURE__ */ Q(W, {
|
|
@@ -92,7 +92,7 @@ var we = (e) => {
|
|
|
92
92
|
children: e.label
|
|
93
93
|
}, e.key))
|
|
94
94
|
}),
|
|
95
|
-
c && /* @__PURE__ */ Q(
|
|
95
|
+
c && /* @__PURE__ */ Q(I, {
|
|
96
96
|
error: s,
|
|
97
97
|
children: c
|
|
98
98
|
})
|
|
@@ -355,11 +355,11 @@ var we = (e) => {
|
|
|
355
355
|
onChange: (e) => i?.(parseInt(e.target.value, 10))
|
|
356
356
|
});
|
|
357
357
|
}, je = (e) => {
|
|
358
|
-
let { t: n, loading: r } = y(), { value: o, onChange: s, disabled: u = !1, durationTypes: f = Object.keys(l), discountTypes: h = Object.keys(c), schedulerType: g } = e, _ = g === d.SALE ? a : i, [v, b] = w(() => _),
|
|
359
|
-
x(() => {
|
|
360
|
-
|
|
361
|
-
}, [
|
|
362
|
-
let
|
|
358
|
+
let { t: n, loading: r } = y(), { value: o, onChange: s, disabled: u = !1, durationTypes: f = Object.keys(l), discountTypes: h = Object.keys(c), schedulerType: g } = e, _ = S(() => g === d.SALE ? a : i, [g]), [v, b] = w(() => o ?? _), C = o ?? v, [E, D] = w("0"), [O, k] = w(null), [A, j] = w(o);
|
|
359
|
+
o !== A && (b(o ?? _), j(o)), x(() => {
|
|
360
|
+
C.range?.startedAt && p(Z(C.range.startedAt), k), C.duration && m(C.duration, C, D, n);
|
|
361
|
+
}, [C, n]);
|
|
362
|
+
let M = (e, t) => {
|
|
363
363
|
let n = e.split("."), r = (e, t, n) => {
|
|
364
364
|
if (t.length === 1) return {
|
|
365
365
|
...e,
|
|
@@ -370,7 +370,7 @@ var we = (e) => {
|
|
|
370
370
|
...e,
|
|
371
371
|
[i]: r(e[i] ?? {}, a, n)
|
|
372
372
|
};
|
|
373
|
-
}, i = r(
|
|
373
|
+
}, i = r(C, n, t);
|
|
374
374
|
b(i), s?.(i);
|
|
375
375
|
};
|
|
376
376
|
return /* @__PURE__ */ Q(de, {
|
|
@@ -383,10 +383,10 @@ var we = (e) => {
|
|
|
383
383
|
py: 2
|
|
384
384
|
},
|
|
385
385
|
children: [
|
|
386
|
-
[d.DISCOUNT, d.TRIAL_DISCOUNT].includes(g) && /* @__PURE__ */ Q(
|
|
386
|
+
[d.DISCOUNT, d.TRIAL_DISCOUNT].includes(g) && /* @__PURE__ */ Q(L, {
|
|
387
387
|
container: !0,
|
|
388
388
|
spacing: 2,
|
|
389
|
-
children: /* @__PURE__ */ Q(
|
|
389
|
+
children: /* @__PURE__ */ Q(L, {
|
|
390
390
|
size: {
|
|
391
391
|
xs: 12,
|
|
392
392
|
sm: 6
|
|
@@ -396,14 +396,14 @@ var we = (e) => {
|
|
|
396
396
|
display: "flex",
|
|
397
397
|
gap: 1
|
|
398
398
|
},
|
|
399
|
-
children: [/* @__PURE__ */ $(
|
|
399
|
+
children: [/* @__PURE__ */ $(F, {
|
|
400
400
|
fullWidth: !0,
|
|
401
401
|
size: "small",
|
|
402
|
-
children: [/* @__PURE__ */ Q(
|
|
403
|
-
value:
|
|
402
|
+
children: [/* @__PURE__ */ Q(z, { children: n("scheduler.meta.duration") }), /* @__PURE__ */ Q(W, {
|
|
403
|
+
value: C.discount?.type || "",
|
|
404
404
|
label: n("scheduler.meta.duration"),
|
|
405
405
|
disabled: u || r,
|
|
406
|
-
onChange: (e) =>
|
|
406
|
+
onChange: (e) => M("discount.type", e.target.value),
|
|
407
407
|
children: h.map((e) => /* @__PURE__ */ Q(U, {
|
|
408
408
|
value: e,
|
|
409
409
|
children: c[e]
|
|
@@ -414,17 +414,17 @@ var we = (e) => {
|
|
|
414
414
|
size: "small",
|
|
415
415
|
type: "number",
|
|
416
416
|
label: n("scheduler.meta.duration"),
|
|
417
|
-
value:
|
|
417
|
+
value: C.discount?.value ?? "",
|
|
418
418
|
disabled: u || r,
|
|
419
|
-
onChange: (e) =>
|
|
419
|
+
onChange: (e) => M("discount.value", parseInt(e.target.value, 10))
|
|
420
420
|
})]
|
|
421
421
|
})
|
|
422
422
|
})
|
|
423
423
|
}),
|
|
424
|
-
/* @__PURE__ */ $(
|
|
424
|
+
/* @__PURE__ */ $(L, {
|
|
425
425
|
container: !0,
|
|
426
426
|
spacing: 2,
|
|
427
|
-
children: [/* @__PURE__ */ Q(
|
|
427
|
+
children: [/* @__PURE__ */ Q(L, {
|
|
428
428
|
size: {
|
|
429
429
|
xs: 12,
|
|
430
430
|
sm: 6
|
|
@@ -432,22 +432,22 @@ var we = (e) => {
|
|
|
432
432
|
children: /* @__PURE__ */ Q(we, {
|
|
433
433
|
label: n("scheduler.duration"),
|
|
434
434
|
disabled: u || r,
|
|
435
|
-
typeValue:
|
|
436
|
-
periodValue:
|
|
435
|
+
typeValue: C.duration?.type,
|
|
436
|
+
periodValue: C.duration?.period,
|
|
437
437
|
durationTypes: f,
|
|
438
438
|
required: !0,
|
|
439
|
-
onTypeChange: (e) =>
|
|
440
|
-
onValueChange: (e) =>
|
|
439
|
+
onTypeChange: (e) => M("duration.type", e),
|
|
440
|
+
onValueChange: (e) => M("duration.period", e)
|
|
441
441
|
})
|
|
442
|
-
}), /* @__PURE__ */ Q(
|
|
442
|
+
}), /* @__PURE__ */ Q(L, {
|
|
443
443
|
size: {
|
|
444
444
|
xs: 12,
|
|
445
445
|
sm: 6
|
|
446
446
|
},
|
|
447
447
|
children: /* @__PURE__ */ Q(ue, {
|
|
448
448
|
label: n("scheduler.startedAt"),
|
|
449
|
-
value: Z(
|
|
450
|
-
onChange: (e) =>
|
|
449
|
+
value: Z(C.range?.startedAt),
|
|
450
|
+
onChange: (e) => M("range.startedAt", e),
|
|
451
451
|
disabled: u || r,
|
|
452
452
|
slotProps: { textField: {
|
|
453
453
|
size: "small",
|
|
@@ -456,47 +456,47 @@ var we = (e) => {
|
|
|
456
456
|
})
|
|
457
457
|
})]
|
|
458
458
|
}),
|
|
459
|
-
|
|
460
|
-
value:
|
|
461
|
-
onChange: (e) =>
|
|
459
|
+
C.duration?.type === "WEEK" && /* @__PURE__ */ Q(Ee, {
|
|
460
|
+
value: C.repeat?.weekly?.days,
|
|
461
|
+
onChange: (e) => M("repeat.weekly.days", e),
|
|
462
462
|
disabled: u,
|
|
463
|
-
setOccurs:
|
|
464
|
-
scheduler:
|
|
463
|
+
setOccurs: D,
|
|
464
|
+
scheduler: C
|
|
465
465
|
}),
|
|
466
|
-
|
|
467
|
-
value:
|
|
468
|
-
onChange: (e) =>
|
|
469
|
-
onWeeklyChange: (e) =>
|
|
466
|
+
C.duration?.type === "MONTH" && /* @__PURE__ */ Q(De, {
|
|
467
|
+
value: C.repeat?.monthly,
|
|
468
|
+
onChange: (e) => M("repeat.monthly", e),
|
|
469
|
+
onWeeklyChange: (e) => M("repeat.weekly.days", e),
|
|
470
470
|
disabled: u,
|
|
471
|
-
setOccurs:
|
|
472
|
-
scheduler:
|
|
471
|
+
setOccurs: D,
|
|
472
|
+
scheduler: C
|
|
473
473
|
}),
|
|
474
|
-
|
|
475
|
-
value:
|
|
476
|
-
onChange: (e) =>
|
|
474
|
+
C.duration?.type === "YEAR" && /* @__PURE__ */ Q(Oe, {
|
|
475
|
+
value: C.repeat?.yearly,
|
|
476
|
+
onChange: (e) => M("repeat.yearly", e),
|
|
477
477
|
disabled: u,
|
|
478
|
-
setOccurs:
|
|
479
|
-
scheduler:
|
|
480
|
-
repeatMonthly:
|
|
481
|
-
onMonthlyChange: (e) =>
|
|
482
|
-
onWeeklyChange: (e) =>
|
|
478
|
+
setOccurs: D,
|
|
479
|
+
scheduler: C,
|
|
480
|
+
repeatMonthly: C.repeat?.monthly,
|
|
481
|
+
onMonthlyChange: (e) => M("repeat.monthly", e),
|
|
482
|
+
onWeeklyChange: (e) => M("repeat.weekly.days", e)
|
|
483
483
|
}),
|
|
484
|
-
/* @__PURE__ */ $(
|
|
484
|
+
/* @__PURE__ */ $(L, {
|
|
485
485
|
container: !0,
|
|
486
486
|
spacing: 2,
|
|
487
|
-
children: [/* @__PURE__ */ Q(
|
|
487
|
+
children: [/* @__PURE__ */ Q(L, {
|
|
488
488
|
size: {
|
|
489
489
|
xs: 12,
|
|
490
490
|
sm: 6
|
|
491
491
|
},
|
|
492
|
-
children: /* @__PURE__ */ $(
|
|
492
|
+
children: /* @__PURE__ */ $(F, {
|
|
493
493
|
fullWidth: !0,
|
|
494
494
|
size: "small",
|
|
495
|
-
children: [/* @__PURE__ */ Q(
|
|
496
|
-
value:
|
|
495
|
+
children: [/* @__PURE__ */ Q(z, { children: n("scheduler.duration.end") }), /* @__PURE__ */ Q(W, {
|
|
496
|
+
value: C.range?.endReason?.type || "",
|
|
497
497
|
label: n("scheduler.duration.end"),
|
|
498
498
|
disabled: u,
|
|
499
|
-
onChange: (e) =>
|
|
499
|
+
onChange: (e) => M("range.endReason.type", e.target.value),
|
|
500
500
|
children: [
|
|
501
501
|
{
|
|
502
502
|
label: n("scheduler.duration.end.day"),
|
|
@@ -516,19 +516,19 @@ var we = (e) => {
|
|
|
516
516
|
}, e.value))
|
|
517
517
|
})]
|
|
518
518
|
})
|
|
519
|
-
}), /* @__PURE__ */ $(
|
|
519
|
+
}), /* @__PURE__ */ $(L, {
|
|
520
520
|
size: {
|
|
521
521
|
xs: 12,
|
|
522
522
|
sm: 6
|
|
523
523
|
},
|
|
524
|
-
children: [
|
|
525
|
-
value: Z(
|
|
526
|
-
startedAt: Z(
|
|
527
|
-
onChange: (e) =>
|
|
524
|
+
children: [C.range?.endReason?.type === t[0] && /* @__PURE__ */ Q(ke, {
|
|
525
|
+
value: Z(C.range?.endReason?.expiredAt),
|
|
526
|
+
startedAt: Z(C.range?.startedAt),
|
|
527
|
+
onChange: (e) => M("range.endReason.expiredAt", e),
|
|
528
528
|
disabled: u
|
|
529
|
-
}),
|
|
530
|
-
value:
|
|
531
|
-
onChange: (e) =>
|
|
529
|
+
}), C.range?.endReason?.type === t[1] && /* @__PURE__ */ Q(Ae, {
|
|
530
|
+
value: C.range?.endReason?.occurrences,
|
|
531
|
+
onChange: (e) => M("range.endReason.occurrences", e),
|
|
532
532
|
disabled: u
|
|
533
533
|
})]
|
|
534
534
|
})]
|
|
@@ -540,8 +540,8 @@ var we = (e) => {
|
|
|
540
540
|
color: "text.secondary"
|
|
541
541
|
},
|
|
542
542
|
dangerouslySetInnerHTML: { __html: n("scheduler.result", {
|
|
543
|
-
occurs:
|
|
544
|
-
startAt:
|
|
543
|
+
occurs: E,
|
|
544
|
+
startAt: O ?? ""
|
|
545
545
|
}) }
|
|
546
546
|
})
|
|
547
547
|
]
|
|
@@ -566,26 +566,26 @@ var we = (e) => {
|
|
|
566
566
|
children: p
|
|
567
567
|
});
|
|
568
568
|
}, Ne = ({ schedulerType: e, disabled: t, onSuccess: n, setDirty: s, dirty: c, isCreating: l, setIsCreating: u, buttonProps: f, open: p, onOpenChange: m, showButton: h = !0 }) => {
|
|
569
|
-
let { t: g, loading: _, permissions: v, onCreate: b } = y(), [
|
|
570
|
-
m ? m(e) :
|
|
571
|
-
},
|
|
569
|
+
let { t: g, loading: _, permissions: v, onCreate: b, limit: C = o } = y(), [D, O] = w(!1), k = p === void 0 ? D : p, A = (e) => {
|
|
570
|
+
m ? m(e) : O(e);
|
|
571
|
+
}, j = S(() => e === d.SALE ? a : i, [e]), [M, N] = w(j);
|
|
572
572
|
if (x(() => {
|
|
573
|
-
|
|
574
|
-
}, [
|
|
575
|
-
let
|
|
576
|
-
|
|
577
|
-
},
|
|
578
|
-
|
|
573
|
+
k && N(j);
|
|
574
|
+
}, [k, j]), !v.canCreate) return null;
|
|
575
|
+
let P = () => {
|
|
576
|
+
A(!0);
|
|
577
|
+
}, F = () => {
|
|
578
|
+
A(!1), s(!1);
|
|
579
579
|
}, I = async () => {
|
|
580
580
|
try {
|
|
581
581
|
u(!0);
|
|
582
582
|
let t = {
|
|
583
583
|
id: `new-${Date.now()}`,
|
|
584
|
-
...
|
|
584
|
+
...M,
|
|
585
585
|
type: e,
|
|
586
|
-
[r]: e === d.SALE ? null :
|
|
586
|
+
[r]: e === d.SALE ? null : M?.[r]
|
|
587
587
|
};
|
|
588
|
-
b && await b(e, t), n?.(t),
|
|
588
|
+
b && await b(e, t), n?.(t), A(!1), s(!1);
|
|
589
589
|
} catch (e) {
|
|
590
590
|
console.error("Failed to save scheduler:", e);
|
|
591
591
|
} finally {
|
|
@@ -593,13 +593,13 @@ var we = (e) => {
|
|
|
593
593
|
}
|
|
594
594
|
};
|
|
595
595
|
return /* @__PURE__ */ $(pe, { children: [h && /* @__PURE__ */ Q(Y, {
|
|
596
|
-
title: t ? g("scheduler.limited", { limit:
|
|
596
|
+
title: t ? g("scheduler.limited", { limit: C }) : "",
|
|
597
597
|
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ Q(E, {
|
|
598
598
|
variant: "text",
|
|
599
599
|
size: "small",
|
|
600
600
|
...f,
|
|
601
601
|
disabled: t || _,
|
|
602
|
-
onClick:
|
|
602
|
+
onClick: P,
|
|
603
603
|
sx: {
|
|
604
604
|
textTransform: "none",
|
|
605
605
|
p: 0,
|
|
@@ -608,10 +608,10 @@ var we = (e) => {
|
|
|
608
608
|
},
|
|
609
609
|
children: g("scheduler")
|
|
610
610
|
}) })
|
|
611
|
-
}), /* @__PURE__ */ Q(
|
|
611
|
+
}), /* @__PURE__ */ Q(te, {
|
|
612
612
|
anchor: "right",
|
|
613
|
-
open:
|
|
614
|
-
onClose:
|
|
613
|
+
open: k,
|
|
614
|
+
onClose: F,
|
|
615
615
|
slotProps: { paper: { sx: {
|
|
616
616
|
width: {
|
|
617
617
|
xs: "100%",
|
|
@@ -653,14 +653,14 @@ var we = (e) => {
|
|
|
653
653
|
loading: _ || l,
|
|
654
654
|
disabled: t || !c,
|
|
655
655
|
onClick: I
|
|
656
|
-
}), /* @__PURE__ */ Q(
|
|
657
|
-
onClick:
|
|
656
|
+
}), /* @__PURE__ */ Q(R, {
|
|
657
|
+
onClick: F,
|
|
658
658
|
size: "small",
|
|
659
659
|
children: /* @__PURE__ */ Q(ve, {})
|
|
660
660
|
})]
|
|
661
661
|
})]
|
|
662
662
|
}),
|
|
663
|
-
/* @__PURE__ */ Q(
|
|
663
|
+
/* @__PURE__ */ Q(ee, {}),
|
|
664
664
|
/* @__PURE__ */ Q(T, {
|
|
665
665
|
sx: {
|
|
666
666
|
p: 3,
|
|
@@ -669,9 +669,9 @@ var we = (e) => {
|
|
|
669
669
|
},
|
|
670
670
|
children: /* @__PURE__ */ Q(je, {
|
|
671
671
|
schedulerType: e,
|
|
672
|
-
value:
|
|
672
|
+
value: M,
|
|
673
673
|
onChange: (e) => {
|
|
674
|
-
|
|
674
|
+
N(e), s(!0);
|
|
675
675
|
},
|
|
676
676
|
disabled: t
|
|
677
677
|
})
|
|
@@ -683,13 +683,13 @@ var we = (e) => {
|
|
|
683
683
|
let { t } = y(), { selectedColumns: n = [], columnsList: r = [], onChange: i } = e;
|
|
684
684
|
if (!r?.length) return /* @__PURE__ */ Q(pe, {});
|
|
685
685
|
let a = t("table.hideColumns");
|
|
686
|
-
return /* @__PURE__ */ $(
|
|
686
|
+
return /* @__PURE__ */ $(F, {
|
|
687
687
|
sx: {
|
|
688
688
|
m: 1,
|
|
689
689
|
minWidth: 250
|
|
690
690
|
},
|
|
691
691
|
size: "small",
|
|
692
|
-
children: [/* @__PURE__ */ Q(
|
|
692
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
693
693
|
id: "hide-columns-label",
|
|
694
694
|
children: a
|
|
695
695
|
}), /* @__PURE__ */ Q(W, {
|
|
@@ -709,7 +709,7 @@ var we = (e) => {
|
|
|
709
709
|
children: [/* @__PURE__ */ Q(D, {
|
|
710
710
|
checked: n.indexOf(e.value) > -1,
|
|
711
711
|
size: "small"
|
|
712
|
-
}), /* @__PURE__ */ Q(
|
|
712
|
+
}), /* @__PURE__ */ Q(V, { primary: e.label })]
|
|
713
713
|
}, e.value))
|
|
714
714
|
})]
|
|
715
715
|
});
|
|
@@ -729,7 +729,7 @@ var we = (e) => {
|
|
|
729
729
|
},
|
|
730
730
|
children: [
|
|
731
731
|
r,
|
|
732
|
-
/* @__PURE__ */ Q(
|
|
732
|
+
/* @__PURE__ */ Q(R, {
|
|
733
733
|
"aria-label": "more",
|
|
734
734
|
id: "toolbar-button",
|
|
735
735
|
"aria-controls": c ? "toolbar-menu" : void 0,
|
|
@@ -739,7 +739,7 @@ var we = (e) => {
|
|
|
739
739
|
size: "small",
|
|
740
740
|
children: t ? /* @__PURE__ */ Q(k, { size: 20 }) : /* @__PURE__ */ Q(be, {})
|
|
741
741
|
}),
|
|
742
|
-
/* @__PURE__ */ $(
|
|
742
|
+
/* @__PURE__ */ $(H, {
|
|
743
743
|
id: "toolbar-menu",
|
|
744
744
|
anchorEl: o,
|
|
745
745
|
open: c,
|
|
@@ -750,7 +750,7 @@ var we = (e) => {
|
|
|
750
750
|
onClick: () => {
|
|
751
751
|
e.onClick && e.onClick(), u();
|
|
752
752
|
},
|
|
753
|
-
children: [e.icon && /* @__PURE__ */ Q(
|
|
753
|
+
children: [e.icon && /* @__PURE__ */ Q(B, { children: e.icon }), typeof e.label == "string" ? /* @__PURE__ */ Q(V, { children: e.label }) : /* @__PURE__ */ Q(T, {
|
|
754
754
|
sx: {
|
|
755
755
|
flexGrow: 1,
|
|
756
756
|
display: "flex"
|
|
@@ -758,12 +758,12 @@ var we = (e) => {
|
|
|
758
758
|
children: e.label
|
|
759
759
|
})]
|
|
760
760
|
}, t)),
|
|
761
|
-
i.length > 0 && a && /* @__PURE__ */ Q(
|
|
761
|
+
i.length > 0 && a && /* @__PURE__ */ Q(ee, {}),
|
|
762
762
|
a && /* @__PURE__ */ $(U, {
|
|
763
763
|
onClick: () => {
|
|
764
764
|
a(), u();
|
|
765
765
|
},
|
|
766
|
-
children: [/* @__PURE__ */ Q(
|
|
766
|
+
children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(xe, { fontSize: "small" }) }), /* @__PURE__ */ Q(V, { children: n("toolbar.refresh") })]
|
|
767
767
|
})
|
|
768
768
|
]
|
|
769
769
|
})
|
|
@@ -792,7 +792,7 @@ var we = (e) => {
|
|
|
792
792
|
};
|
|
793
793
|
return /* @__PURE__ */ $(pe, { children: [/* @__PURE__ */ Q(Y, {
|
|
794
794
|
title: t("actions.delete"),
|
|
795
|
-
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(
|
|
795
|
+
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(R, {
|
|
796
796
|
color: "error",
|
|
797
797
|
size: "small",
|
|
798
798
|
onClick: l,
|
|
@@ -826,7 +826,7 @@ var we = (e) => {
|
|
|
826
826
|
let { t, permissions: n } = y(), { entity: r, disabled: i, onEdit: a, showLabel: o = !1 } = e;
|
|
827
827
|
return !r || !n.canUpdate ? null : /* @__PURE__ */ Q(Y, {
|
|
828
828
|
title: t("actions.edit"),
|
|
829
|
-
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(
|
|
829
|
+
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(R, {
|
|
830
830
|
color: "primary",
|
|
831
831
|
size: "small",
|
|
832
832
|
onClick: (e) => {
|
|
@@ -994,56 +994,56 @@ var we = (e) => {
|
|
|
994
994
|
key: "actions",
|
|
995
995
|
width: 100
|
|
996
996
|
}), qe = (e) => {
|
|
997
|
-
let { type: t, title: n, disabled: r, readOnlyFields: i = [], currency: a, onRefresh: s } = e, { schedulers: c, loading: l,
|
|
997
|
+
let { type: t, title: n, disabled: r, readOnlyFields: i = [], currency: a, onRefresh: s } = e, { schedulers: c, loading: l, limit: u = o, disabled: d, t: f, permissions: p, onUpdate: m, onDelete: h } = y(), g = r ?? d, [_, x] = w(/* @__PURE__ */ new Set()), [C, E] = w(!1), [D, O] = w(!1), [k, A] = w(!1), [j, M] = w(!1), [N, P] = w(!1), [F, I] = w(null), [L, z] = w(0), [B, V] = w(10), H = S(() => {
|
|
998
998
|
let e = c[t] ?? [];
|
|
999
|
-
return
|
|
999
|
+
return _.size > 0 && (e = e.filter((e) => !e.id || !_.has(e.id))), We(e);
|
|
1000
1000
|
}, [
|
|
1001
1001
|
c,
|
|
1002
1002
|
t,
|
|
1003
|
-
|
|
1004
|
-
]),
|
|
1005
|
-
I(JSON.parse(JSON.stringify(e))),
|
|
1006
|
-
}, []),
|
|
1007
|
-
if (!(!
|
|
1008
|
-
await
|
|
1003
|
+
_
|
|
1004
|
+
]), U = H.length >= u, ne = b((e) => {
|
|
1005
|
+
I(JSON.parse(JSON.stringify(e))), P(!0), O(!1);
|
|
1006
|
+
}, []), W = async () => {
|
|
1007
|
+
if (!(!F || !m)) try {
|
|
1008
|
+
await m(t, F), P(!1), I(null), O(!1), s?.();
|
|
1009
1009
|
} catch (e) {
|
|
1010
1010
|
console.error("Failed to update scheduler:", e);
|
|
1011
1011
|
}
|
|
1012
|
-
},
|
|
1012
|
+
}, K = b(async (e) => {
|
|
1013
1013
|
if (e.id?.startsWith("new-")) {
|
|
1014
|
-
|
|
1014
|
+
x((t) => {
|
|
1015
1015
|
let n = new Set(t);
|
|
1016
1016
|
return e.id && n.add(e.id), n;
|
|
1017
1017
|
});
|
|
1018
1018
|
return;
|
|
1019
1019
|
}
|
|
1020
|
-
|
|
1020
|
+
h && e.id && (await h(t, e.id), s?.());
|
|
1021
1021
|
}, [
|
|
1022
|
-
|
|
1022
|
+
h,
|
|
1023
1023
|
t,
|
|
1024
1024
|
s
|
|
1025
|
-
]), { filteredColumns:
|
|
1026
|
-
disabled:
|
|
1025
|
+
]), { filteredColumns: q, columnsList: J, selectedColumns: Y, setSelectedColumns: ue } = v(S(() => Ue({
|
|
1026
|
+
disabled: g,
|
|
1027
1027
|
schedulerType: t,
|
|
1028
1028
|
entities: H,
|
|
1029
1029
|
currency: a,
|
|
1030
|
-
t:
|
|
1031
|
-
onEdit:
|
|
1032
|
-
onDelete:
|
|
1030
|
+
t: f,
|
|
1031
|
+
onEdit: p.canUpdate ? ne : void 0,
|
|
1032
|
+
onDelete: p.canDelete ? K : void 0
|
|
1033
1033
|
}), [
|
|
1034
|
-
|
|
1034
|
+
g,
|
|
1035
1035
|
t,
|
|
1036
1036
|
H,
|
|
1037
1037
|
a,
|
|
1038
|
-
d,
|
|
1039
1038
|
f,
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1039
|
+
p,
|
|
1040
|
+
ne,
|
|
1041
|
+
K
|
|
1042
|
+
])), de = (e, t) => {
|
|
1043
|
+
z(t);
|
|
1044
|
+
}, fe = (e) => {
|
|
1045
|
+
V(parseInt(e.target.value, 10)), z(0);
|
|
1046
|
+
}, Z = H.slice(L * B, L * B + B);
|
|
1047
1047
|
return /* @__PURE__ */ $(re, {
|
|
1048
1048
|
sx: {
|
|
1049
1049
|
width: "100%",
|
|
@@ -1061,27 +1061,27 @@ var we = (e) => {
|
|
|
1061
1061
|
},
|
|
1062
1062
|
children: /* @__PURE__ */ Q(Fe, {
|
|
1063
1063
|
onRefresh: s,
|
|
1064
|
-
items:
|
|
1065
|
-
label:
|
|
1064
|
+
items: p.canCreate && !U ? [{
|
|
1065
|
+
label: f("scheduler"),
|
|
1066
1066
|
icon: /* @__PURE__ */ Q(ge, {}),
|
|
1067
|
-
onClick: () =>
|
|
1067
|
+
onClick: () => M(!0)
|
|
1068
1068
|
}] : [],
|
|
1069
1069
|
children: /* @__PURE__ */ Q(Pe, {
|
|
1070
|
-
columnsList:
|
|
1071
|
-
selectedColumns:
|
|
1072
|
-
onChange:
|
|
1070
|
+
columnsList: J,
|
|
1071
|
+
selectedColumns: Y,
|
|
1072
|
+
onChange: ue
|
|
1073
1073
|
})
|
|
1074
1074
|
})
|
|
1075
1075
|
}),
|
|
1076
1076
|
/* @__PURE__ */ Q(Ne, {
|
|
1077
|
-
open:
|
|
1078
|
-
onOpenChange:
|
|
1077
|
+
open: j,
|
|
1078
|
+
onOpenChange: M,
|
|
1079
1079
|
showButton: !1,
|
|
1080
1080
|
schedulerType: t,
|
|
1081
|
-
setDirty:
|
|
1082
|
-
dirty:
|
|
1083
|
-
isCreating:
|
|
1084
|
-
setIsCreating:
|
|
1081
|
+
setDirty: E,
|
|
1082
|
+
dirty: C,
|
|
1083
|
+
isCreating: k,
|
|
1084
|
+
setIsCreating: A,
|
|
1085
1085
|
onSuccess: () => s?.()
|
|
1086
1086
|
}),
|
|
1087
1087
|
/* @__PURE__ */ Q(se, {
|
|
@@ -1090,23 +1090,23 @@ var we = (e) => {
|
|
|
1090
1090
|
stickyHeader: !0,
|
|
1091
1091
|
"aria-label": "schedulers table",
|
|
1092
1092
|
size: "small",
|
|
1093
|
-
children: [/* @__PURE__ */ Q(ce, { children: /* @__PURE__ */ Q(G, { children:
|
|
1093
|
+
children: [/* @__PURE__ */ Q(ce, { children: /* @__PURE__ */ Q(G, { children: q.filter((e) => !e.hidden).map((e) => /* @__PURE__ */ Q(oe, {
|
|
1094
1094
|
align: e.align,
|
|
1095
1095
|
style: { minWidth: e.minWidth },
|
|
1096
1096
|
children: e.label
|
|
1097
|
-
}, e.id)) }) }), /* @__PURE__ */ $(ae, { children: [
|
|
1097
|
+
}, e.id)) }) }), /* @__PURE__ */ $(ae, { children: [Z.map((e) => /* @__PURE__ */ Q(G, {
|
|
1098
1098
|
hover: !0,
|
|
1099
1099
|
role: "checkbox",
|
|
1100
1100
|
tabIndex: -1,
|
|
1101
|
-
children:
|
|
1101
|
+
children: q.filter((e) => !e.hidden).map((t) => {
|
|
1102
1102
|
let n = t.id.includes(".") ? t.id.split(".").reduce((e, t) => e?.[t], e) : e[t.id];
|
|
1103
1103
|
return /* @__PURE__ */ Q(oe, {
|
|
1104
1104
|
align: t.align,
|
|
1105
1105
|
children: t.format ? t.format(n, e) : n
|
|
1106
1106
|
}, t.id);
|
|
1107
1107
|
})
|
|
1108
|
-
}, e.key)),
|
|
1109
|
-
colSpan:
|
|
1108
|
+
}, e.key)), Z.length === 0 && /* @__PURE__ */ Q(G, { children: /* @__PURE__ */ Q(oe, {
|
|
1109
|
+
colSpan: q.length,
|
|
1110
1110
|
align: "center",
|
|
1111
1111
|
sx: { py: 3 },
|
|
1112
1112
|
children: /* @__PURE__ */ Q(X, {
|
|
@@ -1128,14 +1128,14 @@ var we = (e) => {
|
|
|
1128
1128
|
count: H.length,
|
|
1129
1129
|
rowsPerPage: B,
|
|
1130
1130
|
page: L,
|
|
1131
|
-
onPageChange:
|
|
1132
|
-
onRowsPerPageChange:
|
|
1131
|
+
onPageChange: de,
|
|
1132
|
+
onRowsPerPageChange: fe
|
|
1133
1133
|
}),
|
|
1134
|
-
/* @__PURE__ */ Q(
|
|
1134
|
+
/* @__PURE__ */ Q(te, {
|
|
1135
1135
|
anchor: "right",
|
|
1136
|
-
open:
|
|
1136
|
+
open: N,
|
|
1137
1137
|
onClose: () => {
|
|
1138
|
-
|
|
1138
|
+
P(!1), I(null);
|
|
1139
1139
|
},
|
|
1140
1140
|
slotProps: { paper: { sx: {
|
|
1141
1141
|
width: {
|
|
@@ -1166,7 +1166,7 @@ var we = (e) => {
|
|
|
1166
1166
|
},
|
|
1167
1167
|
children: [/* @__PURE__ */ Q(_e, { color: "primary" }), /* @__PURE__ */ Q(X, {
|
|
1168
1168
|
variant: "h6",
|
|
1169
|
-
children: n ??
|
|
1169
|
+
children: n ?? f("scheduler")
|
|
1170
1170
|
})]
|
|
1171
1171
|
}), /* @__PURE__ */ $(T, {
|
|
1172
1172
|
sx: {
|
|
@@ -1177,29 +1177,29 @@ var we = (e) => {
|
|
|
1177
1177
|
children: [/* @__PURE__ */ Q(Me, {
|
|
1178
1178
|
isEdit: !0,
|
|
1179
1179
|
loading: l,
|
|
1180
|
-
disabled:
|
|
1181
|
-
onClick:
|
|
1182
|
-
}), /* @__PURE__ */ Q(
|
|
1183
|
-
onClick: () =>
|
|
1180
|
+
disabled: g || !D || k,
|
|
1181
|
+
onClick: W
|
|
1182
|
+
}), /* @__PURE__ */ Q(R, {
|
|
1183
|
+
onClick: () => P(!1),
|
|
1184
1184
|
size: "small",
|
|
1185
1185
|
children: /* @__PURE__ */ Q(ve, {})
|
|
1186
1186
|
})]
|
|
1187
1187
|
})]
|
|
1188
1188
|
}),
|
|
1189
|
-
/* @__PURE__ */ Q(
|
|
1189
|
+
/* @__PURE__ */ Q(ee, {}),
|
|
1190
1190
|
/* @__PURE__ */ Q(T, {
|
|
1191
1191
|
sx: {
|
|
1192
1192
|
p: 3,
|
|
1193
1193
|
flexGrow: 1,
|
|
1194
1194
|
overflowY: "auto"
|
|
1195
1195
|
},
|
|
1196
|
-
children:
|
|
1196
|
+
children: N && F && /* @__PURE__ */ Q(je, {
|
|
1197
1197
|
schedulerType: t,
|
|
1198
|
-
value:
|
|
1198
|
+
value: F,
|
|
1199
1199
|
onChange: (e) => {
|
|
1200
|
-
I(e),
|
|
1200
|
+
I(e), O(!0);
|
|
1201
1201
|
},
|
|
1202
|
-
disabled:
|
|
1202
|
+
disabled: g,
|
|
1203
1203
|
readOnlyFields: i
|
|
1204
1204
|
})
|
|
1205
1205
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["Scheduler.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Scheduler.d.ts","sourceRoot":"","sources":["Scheduler.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAgB5D,OAAO,EAEL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,UAAU,EAMX,MAAM,yBAAyB,CAAC;AASjC,oBAAY,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,gBAAgB,CAAC;IAChC,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,aAAa,CAAC,EAAE,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,MAAM,OAAO,cAAc,CAAC,EAAE,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAyN/C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulerDrawerButton.d.ts","sourceRoot":"","sources":["SchedulerDrawerButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAQL,WAAW,EACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAEL,gBAAgB,EAChB,UAAU,EAKX,MAAM,yBAAyB,CAAC;AAKjC,oBAAY,0BAA0B,GAAG;IACvC,aAAa,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"SchedulerDrawerButton.d.ts","sourceRoot":"","sources":["SchedulerDrawerButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAQL,WAAW,EACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAEL,gBAAgB,EAChB,UAAU,EAKX,MAAM,yBAAyB,CAAC;AAKjC,oBAAY,0BAA0B,GAAG;IACvC,aAAa,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAEnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAoJtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulersList.d.ts","sourceRoot":"","sources":["SchedulersList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AA2B9D,OAAO,
|
|
1
|
+
{"version":3,"file":"SchedulersList.d.ts","sourceRoot":"","sources":["SchedulersList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AA2B9D,OAAO,EAEL,SAAS,EACT,gBAAgB,EAIjB,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,mBAAmB,GAAG;IAChC,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,OAAO,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwRxD,CAAC"}
|