1"use strict";(globalThis.webpackChunkclient=globalThis.webpackChunkclient||[]).push([[3212],{116(){},3212(e,a,t){t.r(a),t.d(a,{default:()=>p,validatecate:()=>g});var s=t(5043),n=t(2166),o=t(6213),l=t(1811);var r=t(64),c=t.n(r),d=t(184),i=t(7874),m=t(9261),u=t(579);function g(e){let a={};return e.name||(a.name="Por favor, Ingrese nombre de categor\xeda"),a}const p=(0,n.Ng)(function(e){return{brand:e.Brand.brandsAdmin}},function(e){return{brandAdd:(a,t)=>e(((e,a)=>async t=>{console.log("agregando",e);try{const{data:s}=await o.A.post(`${l.dJ}brands/add`,e,{headers:{"x-access-token":a}});t({type:"BRAND_ADMIN_ADD",payload:s}),localStorage.setItem("brandAdded",!0)}catch(r){var s,n;const e=(null===(s=r.response)||void 0===s||null===(n=s.data)||void 0===n?void 0:n.message)||r.message;localStorage.setItem("brandAdded",e),console.log(e)}})(a,t))}})(e=>{(0,n.wA)();const a=(0,n.d4)(e=>e.User.userDetail),[t,o]=s.useState({name:"",description:""}),[l,r]=s.useState({}),p=function(e){o({...t,[e.target.name]:e.target.value}),r(g({...t,[e.target.name]:e.target.value}))};return localStorage.getItem("userInfo")?(0,u.jsx)("div",{className:"boxcontainer",children:(0,u.jsxs)("div",{className:"boxteam",children:[(0,u.jsxs)("div",{className:"titteam",children:[(0,u.jsx)(d.NBi,{}),"Agregar Marca"]}),(0,u.jsxs)("form",{onSubmit:async function(s){s.preventDefault();let n="";n=localStorage.getItem("urlImage")?localStorage.getItem("urlImage"):t.image;const l={name:t.name,description:t.description,image:n};await e.brandAdd(l,a.token),"true"===localStorage.getItem("brandAdded")?c().fire({title:"Genial! La marca ha sido cargada. Deseas cargar otra?",showDenyButton:!0,showCancelButton:!1,confirmButtonText:"S\xed",icon:"success"}).then(e=>{e.isConfirmed?o({name:"",description:""}):e.isDenied&&window.history.go(-1)}):c().fire({title:localStorage.getItem("brandAdded"),confirmButtonText:"Ok",icon:"error"})},children:[(0,u.jsxs)("div",{children:[(0,u.jsxs)("label",{children:["Marca",(0,u.jsx)("input",{className:l.name&&"danger",type:"text",placeholder:"marca",name:"name",onChange:p,value:t.name})]}),l.name&&(0,u.jsx)("p",{className:"danger",children:l.name})]}),(0,u.jsx)("div",{children:(0,u.jsxs)("label",{children:["Descripci\xf3n",(0,u.jsx)("input",{type:"text",placeholder:"Descripcion",name:"description",onChange:p,value:t.description})]})}),(0,u.jsxs)("div",{class:"mb-3",children:[(0,u.jsx)("label",{class:"form-label",children:"Imagen/Logo"}),(0,u.jsx)(m.A,{})]}),(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{className:"btn btn-success",type:"submit",children:"Agregar"}),(0,u.jsx)("button",{className:"btn btn-secondary",type:"reset",onClick:()=>{window.history.go(-1)},children:"Volver"})]})]}),(0,u.jsx)("div",{id:"regis",className:"logsub"})]})}):(0,u.jsx)(i.N_,{to:"/loginadmin",children:(0,u.jsx)("h5",{children:"Debe estar logueado"})})})},3255(e,a,t){t.d(a,{DD:()=>o,iu:()=>l});var s=t(6213),n=t(1811);const o=e=>async a=>{try{const{data:t}=await s.A.delete(`${n.yw}delete/${e}`);a({type:"DELETE_PRODUCT",payload:e}),localStorage.setItem("productDeleted",!0)}catch(l){var t,o;const e=(null===(t=l.response)||void 0===t||null===(o=t.data)||void 0===o?void 0:o.message)||l.message;localStorage.setItem("productDeleted",e),console.log(e)}},l=e=>function(a){a({type:"URL_INFO",payload:e});const t=e.replace("http://","https://");localStorage.setItem("urlImage",t)}},9261(e,a,t){t.d(a,{A:()=>i});var s=t(5043),n=t(6213),o=t(3516),l=(t(116),t(3255)),r=t(2166),c=t(1811),d=t(579);const i=()=>
1{const[e,a]=(0,s.useState)(),[t,i]=(0,s.useState)(),[m,u]=(0,s.useState)(!1),g=(0,r.wA)();return(0,d.jsx)("div",{className:"imageupch",children:(0,d.jsxs)("form",{action:"/pedidos",method:"post",encType:"multipart/form-data",children:[(0,d.jsxs)("div",{class:"mb-3",children:[(0,d.jsx)("label",{class:"form-label",children:(0,d.jsx)("h6",{children:"Ingrese logo o imagen"})}),(0,d.jsx)("input",{class:"form-control btn btn-outline-success",type:"file",name:"foto",onChange:e=>{a(e.target.files[0])}})]}),(0,d.jsxs)("div",{class:"mb-3",children:[" ",m&&(0,d.jsx)("i",{children:" Cargando... "})]}),(0,d.jsxs)("div",{class:"mb-3",children:["Luego de elegir archivo, presione"," ",(0,d.jsxs)("button",{class:"btn btn-outline-success",disabled:m,type:"submit",value:"Create",onClick:async a=>{a.preventDefault(),u(!0),console.log(e);const t=new FormData;t.append("file",e),t.append("upload_preset",c.fd),await n.A.post("https://api.cloudinary.com/v1_1/"+c.j$+"/image/upload",t).then(e=>{i(e.data.url),console.log(e.data.url),u(!1),g((0,l.iu)(e.data.url)),console.log(e)}).catch(e=>{console.log(e)})},children:[" ","Cargar Imagen"," "]})]}),(0,d.jsx)("div",{class:"mb-3",children:(0,d.jsx)(o._V,{cloudName:c.j$,publicId:t})}),(0,d.jsx)("div",{class:"mb-3"})]})})}}}]); 2//# sourceMappingURL=3212.3ce19130.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.