import{r as c,j as e}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a71.js";import{u as v}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7127.js";import{aA as N}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7124.js";import{u as C}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7120.js";import{W as $}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7119.js";import{Q as k,$ as S,a2 as x,r as y,I as h}from"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7111.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a718.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a717.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a719.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a716.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a714.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a713.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a712.js";import"./v_7_4_2_28_54378c94-eda0-47d4-8f59-c666edac6a7110.js";const F=({userID:l,onBackBtnClickHnd:m,create:i,product:r})=>{const{editProduct:g,addProduct:f}=v(),{language:a}=C(),[t,p]=c.useState({id:"",nome:"",date:new Date().toISOString().split("T")[0],transportadora:"",codigo:"",orderID:""}),[d,b]=c.useState(!1);c.useEffect(()=>{r&&p(r)},[r]);const n=(o,s)=>{p({...t,[o]:s})},j=o=>{let s="";switch(t.transportadora){case"Correios":s=`https://www.linkcorreios.com.br/?id=${t.codigo}`;break;case"Jadlog":s=`https://t.17track.net/pt#nums=${t.codigo}`;break;case"Shopee":case"Aliexpress":case"Gear Best":case"China Post":s=`https://www.muambator.com.br/pacotes/${t.codigo}/detalhes/`;break;case"Loggi":s=`https://www.loggi.com/rastreador/${t.codigo}`;break;default:s=`https://parcelsapp.com/pt/tracking/${t.codigo}`;break}return s},u=async o=>{if(o.preventDefault(),await N("encomendas")===!0)return;if(d){let _=`*${a.modal_table_info}:*
*${a.modal_product}:* ${t.nome}
*${a.modal_table_code}:* ${t.codigo}
*${a.modal_table_rastreio}:* ${j(t.id)}`;const w=l.length>15?l+"@g.us":l+"@c.us";$.Chat("sendTxt",{id:w,msg:_})}const s={id:r?.id||y(),nome:t.nome,date:t.date,transportadora:t.transportadora,codigo:t.codigo,orderID:t.orderID};s.nome.length>0&&s.date.length>0&&s.transportadora.length>0&&s.codigo.length>0?(i?f(l,s):g(l,r?.id||"",s),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(k,{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:t.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:t.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:t.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:t.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:t.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(S,{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};
