import{aw as u,f2 as d,j as e,az as m,f7 as v,ax as i,a9 as o,aA as s}from"./app-BgLa5dit.js";import{b as c}from"./4qGb1BIY.chunk.js";function y(t){const a=u(),r=`${d.getCustomFormControlClassName(a.errors,a.touched,"classifications")} h-auto py-2 mb-3`,n=a.values.frequency!==c.Regular;return e.jsxs(m,{children:[e.jsx("div",{className:r,children:e.jsx(v,{label:"Select a classification",tree:t.classificationTree,selectedIds:[a.values.classificationId],onSelect:l=>a.setFieldValue("classificationId",l.id),collapse:!t.isNew,multiSelect:!1,showRequiredStar:!0})}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-6",children:e.jsx(i,{type:"date",label:"Start date",name:"startDate",value:a.values.startDate,onChange:l=>{a.setValues({...a.values,startDate:l.target.value,endDate:l.target.value})},showRequiredStar:!0})}),e.jsx("div",{className:"col-6",children:e.jsx(i,{type:"date",label:"End date",name:"endDate",value:a.values.endDate,showRequiredStar:!0})})]}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-6",children:e.jsxs(i,{as:"select",label:"Frequency",name:"frequency",value:a.values.frequency,onChange:l=>{a.setValues({...a.values,frequency:l.target.value,interval:null})},showRequiredStar:!0,children:[e.jsx("option",{value:c.Regular,children:"One-off"}),e.jsx("option",{value:c.Yearly,children:"Yearly"})]})}),e.jsx("div",{className:"col-6",children:e.jsx(i,{type:"number",label:"Interval",name:"interval",showRequiredStar:n,placeholder:n?"Enter the interval":"",disabled:!n,infoTooltip:n?"How many years between each event?":""})})]}),e.jsxs(o,{children:[e.jsx(o.Cancel,{text:t.isNew?"Back":"Cancel",onClick:()=>{t.isNew?a.setFieldValue("step","presentation"):t.closePopup()}}),e.jsx(o.Submit,{type:"submit",text:t.isNew?"Add to calendar":"Save changes",variant:"dark"})]})]})}const h={presentationId:s.string().required("Please select a presentation"),classificationId:s.string().required("Please select a classification"),startDate:s.string().required("Please select a start date"),endDate:s.string().required("Please select an end date").when("startDate",(t,a)=>t?a.test("is-after-start-date","End date cannot be before the start date",r=>!r||new Date(r)>=new Date(t)):a),frequency:s.mixed().required("Please select a frequency"),interval:s.number().when("frequency",{is:c.Yearly,then:s.number().required("Please specify the interval"),otherwise:s.number().nullable()})},b=s.object().shape(h);export{h as S,y as a,b};
//# sourceMappingURL=3qXJd5bi.chunk.js.map
