@teamco/ischeduler-mui 2.0.10 → 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 +182 -169
- package/dist/mui/src/components/Scheduler.d.ts.map +1 -1
- package/dist/mui/src/components/SchedulerDrawerButton.d.ts +3 -0
- 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/dist/mui/src/components/internal/Toolbar.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})=>{let{t:d,loading:f,permissions:p,onCreate:m}=(0,c.useSchedulerContext)(),[g,_]=(0,l.useState)(!1),v=(0,l.useMemo)(()=>e===c.ESchedulerPrefix.SALE?c.DEFAULT_SALE_SCHEDULER:c.DEFAULT_DISCOUNT_SCHEDULER,[e]),[x,S]=(0,l.useState)(v);if(!p.canCreate)return null;let C=e=>{e.preventDefault(),e.stopPropagation(),S(v),_(!0)},w=()=>{_(!1),r(!1)},T=async()=>{try{o(!0);let t={id:`new-${Date.now()}`,...x,type:e,[c.CNsDiscount]:e===c.ESchedulerPrefix.SALE?null:x?.[c.CNsDiscount]};m&&await m(e,t),n?.(t),_(!1),r(!1)}catch(e){console.error(`Failed to save scheduler:`,e)}finally{o(!1)}};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(u.Tooltip,{title:t?d(`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||f,onClick:C,sx:{textTransform:`none`,p:0,minWidth:`auto`,...s?.sx},children:d(`scheduler`)})})}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:g,onClose:w,PaperProps:{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:d(`scheduler`)})]}),(0,h.jsxs)(u.Box,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,h.jsx)(P,{loading:f||a,disabled:t||!i,onClick:T}),(0,h.jsx)(u.IconButton,{onClick:w,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:x,onChange:e=>{S(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,MenuListProps:{"aria-labelledby":`toolbar-button`},children:[i.map((e,t)=>(0,h.jsxs)(u.MenuItem,{onClick:()=>{e.onClick?.(),p()},children:[e.icon&&(0,h.jsx)(u.ListItemIcon,{children:e.icon}),(0,h.jsx)(u.ListItemText,{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)(null),[M,R]=(0,l.useState)(0),[z,B]=(0,l.useState)(10),V=(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]),H=V.length>=c.DEFAULT_SCHEDULERS_LIMIT,U=(0,l.useCallback)(e=>{j(JSON.parse(JSON.stringify(e))),k(!0),T(!1)},[]),W=async()=>{if(!(!A||!g))try{await g(t,A),k(!1),j(null),T(!1),o?.()}catch(e){console.error(`Failed to update scheduler:`,e)}},q=(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:J,columnsList:Y,selectedColumns:X,setSelectedColumns:Z}=(0,c.useColumnsToggle)((0,l.useMemo)(()=>G({disabled:x,schedulerType:t,entities:V,currency:a,t:p,onEdit:m.canUpdate?U:void 0,onDelete:m.canDelete?q:void 0}),[x,t,V,a,p,m,U,q])),Q=(e,t)=>{R(t)},ee=e=>{B(parseInt(e.target.value,10)),R(0)},$=V.slice(M*z,M*z+z);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&&!H?[{label:(0,h.jsx)(F,{setDirty:T,dirty:w,isCreating:E,setIsCreating:D,schedulerType:t,disabled:x||d||H||E,onSuccess:()=>o?.(),buttonProps:{startIcon:(0,h.jsx)(v.default,{})}}),onClick:()=>{}}]:[],children:(0,h.jsx)(I,{columnsList:Y,selectedColumns:X,onChange:Z})})}),(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:J.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:J.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:J.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:V.length,rowsPerPage:z,page:M,onPageChange:Q,onRowsPerPageChange:ee}),(0,h.jsx)(u.Drawer,{anchor:`right`,open:O,onClose:()=>{k(!1),j(null)},PaperProps:{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||!w||E,onClick:W}),(0,h.jsx)(u.IconButton,{onClick:()=>k(!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:O&&A&&(0,h.jsx)(N,{schedulerType:t,value:A,onChange:e=>{j(e),T(!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
|
]
|
|
@@ -565,56 +565,60 @@ var we = (e) => {
|
|
|
565
565
|
color: c,
|
|
566
566
|
children: p
|
|
567
567
|
});
|
|
568
|
-
}, Ne = ({ schedulerType: e, disabled: t, onSuccess: n, setDirty: s, dirty: c, isCreating: l, setIsCreating: u, buttonProps: f }) => {
|
|
569
|
-
let { t:
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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, 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
|
+
if (x(() => {
|
|
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
|
+
}, I = async () => {
|
|
576
580
|
try {
|
|
577
581
|
u(!0);
|
|
578
582
|
let t = {
|
|
579
583
|
id: `new-${Date.now()}`,
|
|
580
|
-
...
|
|
584
|
+
...M,
|
|
581
585
|
type: e,
|
|
582
|
-
[r]: e === d.SALE ? null :
|
|
586
|
+
[r]: e === d.SALE ? null : M?.[r]
|
|
583
587
|
};
|
|
584
|
-
|
|
588
|
+
b && await b(e, t), n?.(t), A(!1), s(!1);
|
|
585
589
|
} catch (e) {
|
|
586
590
|
console.error("Failed to save scheduler:", e);
|
|
587
591
|
} finally {
|
|
588
592
|
u(!1);
|
|
589
593
|
}
|
|
590
594
|
};
|
|
591
|
-
return /* @__PURE__ */ $(pe, { children: [/* @__PURE__ */ Q(Y, {
|
|
592
|
-
title: t ?
|
|
595
|
+
return /* @__PURE__ */ $(pe, { children: [h && /* @__PURE__ */ Q(Y, {
|
|
596
|
+
title: t ? g("scheduler.limited", { limit: C }) : "",
|
|
593
597
|
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ Q(E, {
|
|
594
598
|
variant: "text",
|
|
595
599
|
size: "small",
|
|
596
600
|
...f,
|
|
597
|
-
disabled: t ||
|
|
598
|
-
onClick:
|
|
601
|
+
disabled: t || _,
|
|
602
|
+
onClick: P,
|
|
599
603
|
sx: {
|
|
600
604
|
textTransform: "none",
|
|
601
605
|
p: 0,
|
|
602
606
|
minWidth: "auto",
|
|
603
607
|
...f?.sx
|
|
604
608
|
},
|
|
605
|
-
children:
|
|
609
|
+
children: g("scheduler")
|
|
606
610
|
}) })
|
|
607
|
-
}), /* @__PURE__ */ Q(
|
|
611
|
+
}), /* @__PURE__ */ Q(te, {
|
|
608
612
|
anchor: "right",
|
|
609
|
-
open:
|
|
610
|
-
onClose:
|
|
611
|
-
|
|
613
|
+
open: k,
|
|
614
|
+
onClose: F,
|
|
615
|
+
slotProps: { paper: { sx: {
|
|
612
616
|
width: {
|
|
613
617
|
xs: "100%",
|
|
614
618
|
sm: 600
|
|
615
619
|
},
|
|
616
620
|
p: 0
|
|
617
|
-
} },
|
|
621
|
+
} } },
|
|
618
622
|
children: /* @__PURE__ */ $(T, {
|
|
619
623
|
sx: {
|
|
620
624
|
display: "flex",
|
|
@@ -637,7 +641,7 @@ var we = (e) => {
|
|
|
637
641
|
},
|
|
638
642
|
children: [/* @__PURE__ */ Q(_e, { color: "primary" }), /* @__PURE__ */ Q(X, {
|
|
639
643
|
variant: "h6",
|
|
640
|
-
children:
|
|
644
|
+
children: g("scheduler")
|
|
641
645
|
})]
|
|
642
646
|
}), /* @__PURE__ */ $(T, {
|
|
643
647
|
sx: {
|
|
@@ -646,17 +650,17 @@ var we = (e) => {
|
|
|
646
650
|
gap: 1
|
|
647
651
|
},
|
|
648
652
|
children: [/* @__PURE__ */ Q(Me, {
|
|
649
|
-
loading:
|
|
653
|
+
loading: _ || l,
|
|
650
654
|
disabled: t || !c,
|
|
651
|
-
onClick:
|
|
652
|
-
}), /* @__PURE__ */ Q(
|
|
653
|
-
onClick:
|
|
655
|
+
onClick: I
|
|
656
|
+
}), /* @__PURE__ */ Q(R, {
|
|
657
|
+
onClick: F,
|
|
654
658
|
size: "small",
|
|
655
659
|
children: /* @__PURE__ */ Q(ve, {})
|
|
656
660
|
})]
|
|
657
661
|
})]
|
|
658
662
|
}),
|
|
659
|
-
/* @__PURE__ */ Q(
|
|
663
|
+
/* @__PURE__ */ Q(ee, {}),
|
|
660
664
|
/* @__PURE__ */ Q(T, {
|
|
661
665
|
sx: {
|
|
662
666
|
p: 3,
|
|
@@ -665,9 +669,9 @@ var we = (e) => {
|
|
|
665
669
|
},
|
|
666
670
|
children: /* @__PURE__ */ Q(je, {
|
|
667
671
|
schedulerType: e,
|
|
668
|
-
value:
|
|
672
|
+
value: M,
|
|
669
673
|
onChange: (e) => {
|
|
670
|
-
|
|
674
|
+
N(e), s(!0);
|
|
671
675
|
},
|
|
672
676
|
disabled: t
|
|
673
677
|
})
|
|
@@ -679,13 +683,13 @@ var we = (e) => {
|
|
|
679
683
|
let { t } = y(), { selectedColumns: n = [], columnsList: r = [], onChange: i } = e;
|
|
680
684
|
if (!r?.length) return /* @__PURE__ */ Q(pe, {});
|
|
681
685
|
let a = t("table.hideColumns");
|
|
682
|
-
return /* @__PURE__ */ $(
|
|
686
|
+
return /* @__PURE__ */ $(F, {
|
|
683
687
|
sx: {
|
|
684
688
|
m: 1,
|
|
685
689
|
minWidth: 250
|
|
686
690
|
},
|
|
687
691
|
size: "small",
|
|
688
|
-
children: [/* @__PURE__ */ Q(
|
|
692
|
+
children: [/* @__PURE__ */ Q(z, {
|
|
689
693
|
id: "hide-columns-label",
|
|
690
694
|
children: a
|
|
691
695
|
}), /* @__PURE__ */ Q(W, {
|
|
@@ -725,7 +729,7 @@ var we = (e) => {
|
|
|
725
729
|
},
|
|
726
730
|
children: [
|
|
727
731
|
r,
|
|
728
|
-
/* @__PURE__ */ Q(
|
|
732
|
+
/* @__PURE__ */ Q(R, {
|
|
729
733
|
"aria-label": "more",
|
|
730
734
|
id: "toolbar-button",
|
|
731
735
|
"aria-controls": c ? "toolbar-menu" : void 0,
|
|
@@ -740,20 +744,26 @@ var we = (e) => {
|
|
|
740
744
|
anchorEl: o,
|
|
741
745
|
open: c,
|
|
742
746
|
onClose: u,
|
|
743
|
-
|
|
747
|
+
slotProps: { list: { "aria-labelledby": "toolbar-button" } },
|
|
744
748
|
children: [
|
|
745
749
|
i.map((e, t) => /* @__PURE__ */ $(U, {
|
|
746
750
|
onClick: () => {
|
|
747
|
-
e.onClick
|
|
751
|
+
e.onClick && e.onClick(), u();
|
|
748
752
|
},
|
|
749
|
-
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
|
+
sx: {
|
|
755
|
+
flexGrow: 1,
|
|
756
|
+
display: "flex"
|
|
757
|
+
},
|
|
758
|
+
children: e.label
|
|
759
|
+
})]
|
|
750
760
|
}, t)),
|
|
751
|
-
i.length > 0 && a && /* @__PURE__ */ Q(
|
|
761
|
+
i.length > 0 && a && /* @__PURE__ */ Q(ee, {}),
|
|
752
762
|
a && /* @__PURE__ */ $(U, {
|
|
753
763
|
onClick: () => {
|
|
754
764
|
a(), u();
|
|
755
765
|
},
|
|
756
|
-
children: [/* @__PURE__ */ Q(
|
|
766
|
+
children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(xe, { fontSize: "small" }) }), /* @__PURE__ */ Q(V, { children: n("toolbar.refresh") })]
|
|
757
767
|
})
|
|
758
768
|
]
|
|
759
769
|
})
|
|
@@ -782,7 +792,7 @@ var we = (e) => {
|
|
|
782
792
|
};
|
|
783
793
|
return /* @__PURE__ */ $(pe, { children: [/* @__PURE__ */ Q(Y, {
|
|
784
794
|
title: t("actions.delete"),
|
|
785
|
-
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(
|
|
795
|
+
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(R, {
|
|
786
796
|
color: "error",
|
|
787
797
|
size: "small",
|
|
788
798
|
onClick: l,
|
|
@@ -816,7 +826,7 @@ var we = (e) => {
|
|
|
816
826
|
let { t, permissions: n } = y(), { entity: r, disabled: i, onEdit: a, showLabel: o = !1 } = e;
|
|
817
827
|
return !r || !n.canUpdate ? null : /* @__PURE__ */ Q(Y, {
|
|
818
828
|
title: t("actions.edit"),
|
|
819
|
-
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(
|
|
829
|
+
children: /* @__PURE__ */ Q("span", { children: /* @__PURE__ */ $(R, {
|
|
820
830
|
color: "primary",
|
|
821
831
|
size: "small",
|
|
822
832
|
onClick: (e) => {
|
|
@@ -984,56 +994,56 @@ var we = (e) => {
|
|
|
984
994
|
key: "actions",
|
|
985
995
|
width: 100
|
|
986
996
|
}), qe = (e) => {
|
|
987
|
-
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(() => {
|
|
988
998
|
let e = c[t] ?? [];
|
|
989
|
-
return
|
|
999
|
+
return _.size > 0 && (e = e.filter((e) => !e.id || !_.has(e.id))), We(e);
|
|
990
1000
|
}, [
|
|
991
1001
|
c,
|
|
992
1002
|
t,
|
|
993
|
-
|
|
994
|
-
]),
|
|
995
|
-
|
|
996
|
-
}, []),
|
|
997
|
-
if (!(!
|
|
998
|
-
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?.();
|
|
999
1009
|
} catch (e) {
|
|
1000
1010
|
console.error("Failed to update scheduler:", e);
|
|
1001
1011
|
}
|
|
1002
|
-
},
|
|
1012
|
+
}, K = b(async (e) => {
|
|
1003
1013
|
if (e.id?.startsWith("new-")) {
|
|
1004
|
-
|
|
1014
|
+
x((t) => {
|
|
1005
1015
|
let n = new Set(t);
|
|
1006
1016
|
return e.id && n.add(e.id), n;
|
|
1007
1017
|
});
|
|
1008
1018
|
return;
|
|
1009
1019
|
}
|
|
1010
|
-
|
|
1020
|
+
h && e.id && (await h(t, e.id), s?.());
|
|
1011
1021
|
}, [
|
|
1012
|
-
|
|
1022
|
+
h,
|
|
1013
1023
|
t,
|
|
1014
1024
|
s
|
|
1015
|
-
]), { filteredColumns:
|
|
1016
|
-
disabled:
|
|
1025
|
+
]), { filteredColumns: q, columnsList: J, selectedColumns: Y, setSelectedColumns: ue } = v(S(() => Ue({
|
|
1026
|
+
disabled: g,
|
|
1017
1027
|
schedulerType: t,
|
|
1018
|
-
entities:
|
|
1028
|
+
entities: H,
|
|
1019
1029
|
currency: a,
|
|
1020
|
-
t:
|
|
1021
|
-
onEdit:
|
|
1022
|
-
onDelete:
|
|
1030
|
+
t: f,
|
|
1031
|
+
onEdit: p.canUpdate ? ne : void 0,
|
|
1032
|
+
onDelete: p.canDelete ? K : void 0
|
|
1023
1033
|
}), [
|
|
1024
|
-
|
|
1034
|
+
g,
|
|
1025
1035
|
t,
|
|
1026
|
-
|
|
1036
|
+
H,
|
|
1027
1037
|
a,
|
|
1028
|
-
d,
|
|
1029
1038
|
f,
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
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);
|
|
1037
1047
|
return /* @__PURE__ */ $(re, {
|
|
1038
1048
|
sx: {
|
|
1039
1049
|
width: "100%",
|
|
@@ -1051,49 +1061,52 @@ var we = (e) => {
|
|
|
1051
1061
|
},
|
|
1052
1062
|
children: /* @__PURE__ */ Q(Fe, {
|
|
1053
1063
|
onRefresh: s,
|
|
1054
|
-
items:
|
|
1055
|
-
label:
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
isCreating: E,
|
|
1059
|
-
setIsCreating: D,
|
|
1060
|
-
schedulerType: t,
|
|
1061
|
-
disabled: h || l || R || E,
|
|
1062
|
-
onSuccess: () => s?.(),
|
|
1063
|
-
buttonProps: { startIcon: /* @__PURE__ */ Q(ge, {}) }
|
|
1064
|
-
}),
|
|
1065
|
-
onClick: () => {}
|
|
1064
|
+
items: p.canCreate && !U ? [{
|
|
1065
|
+
label: f("scheduler"),
|
|
1066
|
+
icon: /* @__PURE__ */ Q(ge, {}),
|
|
1067
|
+
onClick: () => M(!0)
|
|
1066
1068
|
}] : [],
|
|
1067
1069
|
children: /* @__PURE__ */ Q(Pe, {
|
|
1068
|
-
columnsList:
|
|
1069
|
-
selectedColumns:
|
|
1070
|
-
onChange:
|
|
1070
|
+
columnsList: J,
|
|
1071
|
+
selectedColumns: Y,
|
|
1072
|
+
onChange: ue
|
|
1071
1073
|
})
|
|
1072
1074
|
})
|
|
1073
1075
|
}),
|
|
1076
|
+
/* @__PURE__ */ Q(Ne, {
|
|
1077
|
+
open: j,
|
|
1078
|
+
onOpenChange: M,
|
|
1079
|
+
showButton: !1,
|
|
1080
|
+
schedulerType: t,
|
|
1081
|
+
setDirty: E,
|
|
1082
|
+
dirty: C,
|
|
1083
|
+
isCreating: k,
|
|
1084
|
+
setIsCreating: A,
|
|
1085
|
+
onSuccess: () => s?.()
|
|
1086
|
+
}),
|
|
1074
1087
|
/* @__PURE__ */ Q(se, {
|
|
1075
1088
|
sx: { maxHeight: 440 },
|
|
1076
1089
|
children: /* @__PURE__ */ $(ie, {
|
|
1077
1090
|
stickyHeader: !0,
|
|
1078
1091
|
"aria-label": "schedulers table",
|
|
1079
1092
|
size: "small",
|
|
1080
|
-
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, {
|
|
1081
1094
|
align: e.align,
|
|
1082
1095
|
style: { minWidth: e.minWidth },
|
|
1083
1096
|
children: e.label
|
|
1084
|
-
}, e.id)) }) }), /* @__PURE__ */ $(ae, { children: [
|
|
1097
|
+
}, e.id)) }) }), /* @__PURE__ */ $(ae, { children: [Z.map((e) => /* @__PURE__ */ Q(G, {
|
|
1085
1098
|
hover: !0,
|
|
1086
1099
|
role: "checkbox",
|
|
1087
1100
|
tabIndex: -1,
|
|
1088
|
-
children:
|
|
1101
|
+
children: q.filter((e) => !e.hidden).map((t) => {
|
|
1089
1102
|
let n = t.id.includes(".") ? t.id.split(".").reduce((e, t) => e?.[t], e) : e[t.id];
|
|
1090
1103
|
return /* @__PURE__ */ Q(oe, {
|
|
1091
1104
|
align: t.align,
|
|
1092
1105
|
children: t.format ? t.format(n, e) : n
|
|
1093
1106
|
}, t.id);
|
|
1094
1107
|
})
|
|
1095
|
-
}, e.key)),
|
|
1096
|
-
colSpan:
|
|
1108
|
+
}, e.key)), Z.length === 0 && /* @__PURE__ */ Q(G, { children: /* @__PURE__ */ Q(oe, {
|
|
1109
|
+
colSpan: q.length,
|
|
1097
1110
|
align: "center",
|
|
1098
1111
|
sx: { py: 3 },
|
|
1099
1112
|
children: /* @__PURE__ */ Q(X, {
|
|
@@ -1112,25 +1125,25 @@ var we = (e) => {
|
|
|
1112
1125
|
100
|
|
1113
1126
|
],
|
|
1114
1127
|
component: "div",
|
|
1115
|
-
count:
|
|
1116
|
-
rowsPerPage:
|
|
1117
|
-
page:
|
|
1118
|
-
onPageChange:
|
|
1119
|
-
onRowsPerPageChange:
|
|
1128
|
+
count: H.length,
|
|
1129
|
+
rowsPerPage: B,
|
|
1130
|
+
page: L,
|
|
1131
|
+
onPageChange: de,
|
|
1132
|
+
onRowsPerPageChange: fe
|
|
1120
1133
|
}),
|
|
1121
|
-
/* @__PURE__ */ Q(
|
|
1134
|
+
/* @__PURE__ */ Q(te, {
|
|
1122
1135
|
anchor: "right",
|
|
1123
|
-
open:
|
|
1136
|
+
open: N,
|
|
1124
1137
|
onClose: () => {
|
|
1125
|
-
|
|
1138
|
+
P(!1), I(null);
|
|
1126
1139
|
},
|
|
1127
|
-
|
|
1140
|
+
slotProps: { paper: { sx: {
|
|
1128
1141
|
width: {
|
|
1129
1142
|
xs: "100%",
|
|
1130
1143
|
sm: 600
|
|
1131
1144
|
},
|
|
1132
1145
|
p: 0
|
|
1133
|
-
} },
|
|
1146
|
+
} } },
|
|
1134
1147
|
children: /* @__PURE__ */ $(T, {
|
|
1135
1148
|
sx: {
|
|
1136
1149
|
display: "flex",
|
|
@@ -1153,7 +1166,7 @@ var we = (e) => {
|
|
|
1153
1166
|
},
|
|
1154
1167
|
children: [/* @__PURE__ */ Q(_e, { color: "primary" }), /* @__PURE__ */ Q(X, {
|
|
1155
1168
|
variant: "h6",
|
|
1156
|
-
children: n ??
|
|
1169
|
+
children: n ?? f("scheduler")
|
|
1157
1170
|
})]
|
|
1158
1171
|
}), /* @__PURE__ */ $(T, {
|
|
1159
1172
|
sx: {
|
|
@@ -1164,29 +1177,29 @@ var we = (e) => {
|
|
|
1164
1177
|
children: [/* @__PURE__ */ Q(Me, {
|
|
1165
1178
|
isEdit: !0,
|
|
1166
1179
|
loading: l,
|
|
1167
|
-
disabled:
|
|
1168
|
-
onClick:
|
|
1169
|
-
}), /* @__PURE__ */ Q(
|
|
1170
|
-
onClick: () =>
|
|
1180
|
+
disabled: g || !D || k,
|
|
1181
|
+
onClick: W
|
|
1182
|
+
}), /* @__PURE__ */ Q(R, {
|
|
1183
|
+
onClick: () => P(!1),
|
|
1171
1184
|
size: "small",
|
|
1172
1185
|
children: /* @__PURE__ */ Q(ve, {})
|
|
1173
1186
|
})]
|
|
1174
1187
|
})]
|
|
1175
1188
|
}),
|
|
1176
|
-
/* @__PURE__ */ Q(
|
|
1189
|
+
/* @__PURE__ */ Q(ee, {}),
|
|
1177
1190
|
/* @__PURE__ */ Q(T, {
|
|
1178
1191
|
sx: {
|
|
1179
1192
|
p: 3,
|
|
1180
1193
|
flexGrow: 1,
|
|
1181
1194
|
overflowY: "auto"
|
|
1182
1195
|
},
|
|
1183
|
-
children:
|
|
1196
|
+
children: N && F && /* @__PURE__ */ Q(je, {
|
|
1184
1197
|
schedulerType: t,
|
|
1185
|
-
value:
|
|
1198
|
+
value: F,
|
|
1186
1199
|
onChange: (e) => {
|
|
1187
|
-
|
|
1200
|
+
I(e), O(!0);
|
|
1188
1201
|
},
|
|
1189
|
-
disabled:
|
|
1202
|
+
disabled: g,
|
|
1190
1203
|
readOnlyFields: i
|
|
1191
1204
|
})
|
|
1192
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"}
|
|
@@ -10,6 +10,9 @@ export declare type SchedulerDrawerButtonProps = {
|
|
|
10
10
|
isCreating: boolean;
|
|
11
11
|
setIsCreating: (isCreating: boolean) => void;
|
|
12
12
|
buttonProps?: Partial<ButtonProps>;
|
|
13
|
+
open?: boolean;
|
|
14
|
+
onOpenChange?: (open: boolean) => void;
|
|
15
|
+
showButton?: boolean;
|
|
13
16
|
};
|
|
14
17
|
export declare const SchedulerDrawerButton: React.FC<SchedulerDrawerButtonProps>;
|
|
15
18
|
//# sourceMappingURL=SchedulerDrawerButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchedulerDrawerButton.d.ts","sourceRoot":"","sources":["SchedulerDrawerButton.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAexC,aAAK,YAAY,GAAG;IAClB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,aAAK,aAAa,GAAG;IACnB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAiF3C,CAAC"}
|