import{j as e,X as v,a1 as N,a4 as x,r as C,I as h}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b710.js";import{a as c}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b74.js";import{u as k}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b726.js";import{av as S}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b723.js";import{u as $}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b719.js";import{W as y}from"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b718.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b78.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b7.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b75.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b77.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b76.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b79.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b72.js";import"./v_7_4_2_16_364f475f-21c1-4d89-bf17-70efc8c405b73.js";const F=({userID:r,onBackBtnClickHnd:m,create:i,product:l})=>{const{editProduct:g,addProduct:f}=k(),{language:a}=$(),[s,p]=c.useState({id:"",nome:"",date:new Date().toISOString().split("T")[0],transportadora:"",codigo:"",orderID:""}),[d,b]=c.useState(!1);c.useEffect(()=>{l&&p(l)},[l]);const n=(o,t)=>{p({...s,[o]:t})},j=o=>{let t="";switch(s.transportadora){case"Correios":t=`https://www.linkcorreios.com.br/?id=${s.codigo}`;break;case"Jadlog":t=`https://t.17track.net/pt#nums=${s.codigo}`;break;case"Shopee":case"Aliexpress":case"Gear Best":case"China Post":t=`https://www.muambator.com.br/pacotes/${s.codigo}/detalhes/`;break;case"Loggi":t=`https://www.loggi.com/rastreador/${s.codigo}`;break;default:t=`https://parcelsapp.com/pt/tracking/${s.codigo}`;break}return t},u=async o=>{if(o.preventDefault(),await S("encomendas")===!0)return;if(d){let _=`*${a.modal_table_info}:*
*${a.modal_product}:* ${s.nome}
*${a.modal_table_code}:* ${s.codigo}
*${a.modal_table_rastreio}:* ${j(s.id)}`;const w=r.length>15?r+"@g.us":r+"@c.us";y.Chat("sendTxt",{id:w,msg:_})}const t={id:(l==null?void 0:l.id)||C(),nome:s.nome,date:s.date,transportadora:s.transportadora,codigo:s.codigo,orderID:s.orderID};t.nome.length>0&&t.date.length>0&&t.transportadora.length>0&&t.codigo.length>0?(i?f(r,t):g(r,(l==null?void 0:l.id)||"",t),m(),h({type:"Success",message:`${i?a.encomendas_Notif_success:a.encomendas_Notif_success_edit}`,position:"top-right"})):h({type:"Error",message:a.agendamento_Notif_error,position:"top-right"})};return e.jsxs("form",{className:"w-[600px] grid gap-4 overflow-auto pr-1",style:{maxHeight:"calc(100vh - 70px)"},onSubmit:u,children:[e.jsx(v,{children:i?a.modal_orders_title:a.modal_orders_title_edit}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsxs("div",{className:"form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:a.modal_table_name})}),e.jsx("input",{type:"text",placeholder:a.modal_table_insert_name,className:"input input-bordered w-full input-sm",value:s.nome,onChange:o=>n("nome",o.target.value)})]}),e.jsxs("div",{className:"form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:`ID (${a.opcional})`})}),e.jsx("input",{type:"text",placeholder:a.modal_table_insert_id,className:"input input-bordered w-full input-sm",value:s.orderID,onChange:o=>n("orderID",o.target.value)})]})]}),e.jsxs("div",{className:"flex justify-between gap-6",children:[e.jsxs("div",{className:"form-control w-full max-w-xs",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:a.modal_table_data})}),e.jsx("input",{type:"Date",className:"input input-bordered w-full max-w-xs input-sm",value:s.date,onChange:o=>n("date",o.target.value)})]}),e.jsxs("div",{className:"form-control w-full max-w-xs",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:a.modal_table_code})}),e.jsx("input",{type:"text",className:"input input-bordered w-full max-w-xs input-sm",placeholder:a.modal_table_insert_code,value:s.codigo,onChange:o=>n("codigo",o.target.value)})]})]}),e.jsxs("div",{className:"form-control w-full",children:[e.jsx("label",{className:"label",children:e.jsx("span",{className:"label-text",children:a.modal_table_transport})}),e.jsxs("select",{className:"!py-0 select select-bordered !select-sm w-full",value:s.transportadora,onChange:o=>n("transportadora",o.target.value),children:[e.jsx("option",{value:"",children:a.noneSelected}),e.jsx("option",{value:"Correios",children:"Correios"}),e.jsx("option",{value:"Jadlog",children:"Jadlog"}),e.jsx("option",{value:"Shopee",children:"Shopee"}),e.jsx("option",{value:"Loggi",children:"Loggi"}),e.jsx("option",{value:"Aliexpress",children:"Aliexpress"}),e.jsx("option",{value:"Gear Best",children:"Gear Best"}),e.jsx("option",{value:"China Post",children:"China Post"}),e.jsx("option",{value:a.modal_table_outras,children:a.modal_table_outras})]})]}),e.jsxs("div",{className:"flex gap-3 w-full items-center",children:[e.jsx("input",{type:"checkbox",name:"Send Mensage",checked:d,onChange:()=>b(!d)}),e.jsx(N,{children:a.modal_encomendas_checkBoxText})]}),e.jsxs("div",{className:"flex justify-between gap-2 pt-4 w-full",children:[e.jsx(x,{funcao:m,name:a.cancel}),e.jsx(x,{funcao:u,name:i?a.modal_add:a.edit})]})]})};export{F as default};
