import{r as R,j as e,H as c,bm as u,Q as b,I as g}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b225080910.js";import{a as x}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508094.js";import{a2 as y}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b225080923.js";import{u as N}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b225080927.js";import{u as I}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b225080919.js";import{m as F}from"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508098.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b225080918.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508097.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b2250809.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508096.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508092.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508093.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508099.js";import"./v_7_4_1_21_73d2acb1-b7f3-47a2-a8fe-3772b22508095.js";function K({userId:f,create:n,notification:r,onBackBtnClickHnd:h}){const{language:t}=I(),{setNotifications:v,editNotification:w,notifications:S}=N(),[a,_]=x.useState({id:R(),date:"",read:!1,timeOut:!1,time:"",title:"",desc:"",user_id:f}),[p,A]=x.useState(!1);x.useEffect(()=>{r&&_(r)},[r]);const d=(s,i)=>{_({...a,[s]:i})},j=async s=>{if(s.preventDefault(),await y("lembretes"))console.error("User is FREE, cannot proceed.");else{const l={id:a.id||R(),date:a.date,read:!1,timeOut:!1,time:a.time,title:a.title,desc:a.desc,user_id:f};if(p){let o=new Date;o.setHours(o.getHours()-3),o.setMinutes(o.getMinutes()-5);let C=o.toISOString().slice(0,10),D=o.toISOString().slice(11,16).replace(":",""),m="https://calendar.google.com/calendar/render?action=TEMPLATE&text=";m+=`${encodeURIComponent(a.title)}&dates=${C.replace(new RegExp("[-:+]","g"),"")}T${D}/${a.date.replace(new RegExp("[-:+]","g"),"")}T${a.time.replace(new RegExp("[-:+]","g"),"")}`,m+=`&details=${encodeURIComponent(a.desc)}`,m+="&ctz=America/Sao_Paulo",window.open(m,"_blank")}if(l.title.length>0&&l.desc.length>0&&l.date.length>0&&l.time.length>0){if(n)v([...S,l]);else if(r.id)w(r.id,l);else{console.error("Invalid notification ID:",r==null?void 0:r.id);return}g({type:"Success",message:`${n?t.modal_createAReminder_alertMessageSucess:t.modal_createAReminder_alertMessageSucessEdit}`,position:"top-right"}),h()}else g({type:"Error",message:t.modal_createAReminder_FillAllFields,position:"top-right"})}},E=s=>{const{value:i}=s.target,l=i,o=new Date().toISOString().slice(0,10);if(l<o){g({type:"Error",message:t.modal_createAReminder_alertMessageDataError,position:"top-right"});return}d("date",i)};return e.jsxs("form",{className:"w-[30rem] h-auto flex flex-col gap-2 p-2",onSubmit:j,children:[e.jsxs("header",{className:"flex flex-col gap-3",children:[e.jsx(c,{size:"20px",weight:"bold",children:n?t.modal_createAReminder_title:t.modal_editAReminder_title}),e.jsx(c,{size:"14px",children:t.modal_createAReminder_subTitle})]}),e.jsxs("main",{className:"flex flex-col gap-2",children:[e.jsx(u,{icon:e.jsx(F,{size:16}),title:t.modal_name,type:"text",placeHolder:t.modal_createAReminder_PlaceHoldertittle,value:a.title,onchange:s=>d("title",s.target.value),maxLength:55}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(c,{size:"17px",weight:"bold",children:t.description}),e.jsx("textarea",{placeholder:t.modal_createAReminder_subDesc,rows:6,maxLength:784,className:"w-full p-2 text-sm leading-5 text-[var(--primary)] bg-base-200 input-bordered rounded-md resize-none",onChange:s=>d("desc",s.target.value),value:a.desc})]}),e.jsx(u,{title:t.modal_date,type:"date",value:a.date,onchange:E}),e.jsx(u,{title:t.modal_hours,type:"time",value:a.time,onchange:s=>d("time",s.target.value)})]}),e.jsxs("footer",{className:"flex flex-col mt-2 gap-3",children:[e.jsxs("div",{className:"flex gap-3 w-full items-center",children:[e.jsx("input",{type:"checkbox",name:"Google Calendar",checked:p,onChange:()=>A(!p)}),e.jsx(c,{children:t.modal_createAReminder_checkBoxText})]}),e.jsxs("div",{className:"flex w-full justify-evenly",children:[e.jsx(b,{funcao:h,name:t.modal_schedulingCallendar_cancelButton}),e.jsx(b,{funcao:j,name:n?t.modal_schedulingCallendar_saveButton:t.modal_schedulingCallendar_editButton})]})]})]})}export{K as default};
