import{j as e,v as w,D as N,J as x,r as C,I as h}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e10.js";import{a as c}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e4.js";import{u as S}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e25.js";import{_ as y}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e22.js";import{u as $}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e19.js";import{W as k}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e18.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e8.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e5.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e7.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e6.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e2.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e3.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e9.js";const F=({userID:r,onBackBtnClickHnd:m,create:i,product:l})=>{const{editProduct:g,addProduct:f}=S(),{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=(t,o)=>{p({...s,[t]:o})},j=t=>{let o="";switch(s.transportadora){case"Correios":case"Jadlog":o=`https://app.melhorrastreio.com.br/app/${s.codigo}`;break;case"Shopee":case"Aliexpress":case"Gear Best":case"China Post":o=`https://www.muambator.com.br/pacotes/${s.codigo}/detalhes/`;break;case"Loggi":o=`https://www.loggi.com/rastreador/${s.codigo}`;break;default:o=`https://parcelsapp.com/pt/tracking/${s.codigo}`;break}return o},u=async t=>{if(t.preventDefault(),await y("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 v=r.length>15?r+"@g.us":r+"@c.us";k.Chat("sendTxt",{id:v,msg:_})}const o={id:(l==null?void 0:l.id)||C(),nome:s.nome,date:s.date,transportadora:s.transportadora,codigo:s.codigo,orderID:s.orderID};o.nome.length>0&&o.date.length>0&&o.transportadora.length>0&&o.codigo.length>0?(i?f(r,o):g(r,(l==null?void 0:l.id)||"",o),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(w,{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:t=>n("nome",t.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:t=>n("orderID",t.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:t=>n("date",t.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:t=>n("codigo",t.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:t=>n("transportadora",t.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};
