import{j as e,y as w,H as N,Q as x,r as C,I as h}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b10.js";import{a as c}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b4.js";import{u as y}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b26.js";import{a2 as S}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b23.js";import{u as $}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b19.js";import{W as k}from"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b18.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b8.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b5.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b7.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b6.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b9.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b2.js";import"./v_7_4_1_31_281d2484-5da9-48a8-8939-2c37d755bb5b3.js";const z=({userID:r,onBackBtnClickHnd:m,create:i,product:o})=>{const{editProduct:g,addProduct:f}=y(),{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(()=>{o&&p(o)},[o]);const n=(t,l)=>{p({...s,[t]:l})},j=t=>{let l="";switch(s.transportadora){case"Correios":case"Jadlog":l=`https://t.17track.net/pt#nums=${s.codigo}`;break;case"Shopee":case"Aliexpress":case"Gear Best":case"China Post":l=`https://www.muambator.com.br/pacotes/${s.codigo}/detalhes/`;break;case"Loggi":l=`https://www.loggi.com/rastreador/${s.codigo}`;break;default:l=`https://parcelsapp.com/pt/tracking/${s.codigo}`;break}return l},u=async t=>{if(t.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 v=r.length>15?r+"@g.us":r+"@c.us";k.Chat("sendTxt",{id:v,msg:_})}const l={id:(o==null?void 0:o.id)||C(),nome:s.nome,date:s.date,transportadora:s.transportadora,codigo:s.codigo,orderID:s.orderID};l.nome.length>0&&l.date.length>0&&l.transportadora.length>0&&l.codigo.length>0?(i?f(r,l):g(r,(o==null?void 0:o.id)||"",l),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{z as default};
