import{d as S,k as I,aC as N,l as C,G as F,ax as b,z as h,aF as O,o as d,c as g,q as e,w as a,s as u,H as P,A as i,I as l,L as m,P as q,aG as D,F as M,a as j,b as v,W as z,K as G,B as y,n as V,a7 as J,aD as p,aA as $,aE as H}from"./index-2e57ee69.js";import{J as k}from"./applicants.service-23a5de62.js";import{_ as K}from"./upload.vue_vue_type_script_setup_true_lang-123887f2.js";import{V as W,a as w}from"./VTabs-837e0b88.js";import{V as Q,a as x}from"./VRow-22fc34ca.js";import{V as X,a as Y}from"./VToolbar-6d94a41a.js";import{V as Z}from"./VMenu-9f22b74a.js";import{V as ee,d as ae,a as E,b as L}from"./VList-0b71c0f0.js";import{b as R}from"./route-block-83d24a4e.js";import"./job-offer-a441ea01.js";import"./VFileInput-0856c4d1.js";import"./VChip-73a1db56.js";import"./VSpacer-0163be53.js";import"./VDivider-29fb9868.js";const te=V("p",{class:"my-0 py-0"},"Aquí puedes gestionar tus Curriculum's Vitae.",-1),se=V("p",null,"No tienes Curriculum's Vitae registrados.",-1),oe=V("p",null,"Sube uno nuevo para comenzar.",-1),re=S({__name:"cvs",setup(le){const T=I(),U=N(),c=C(U.path.includes("postulations")?"postulations":"cvs"),n=C([]),f=async()=>{try{const{data:t}=await k.myCVs();n.value=t}catch(t){console.error("Error fetching CVs:",t)}};F(c,t=>{T.push(`/bolsa-laboral-panel/me/${t}`)});const A=t=>{fetch(J.getUrlImage(t.url)).then(o=>o.blob()).then(o=>{const s=window.URL.createObjectURL(o),r=document.createElement("a");r.href=s,r.download=t.url.split("/").pop()||t.version+".pdf",document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(s)}).catch(o=>{p("Error al descargar el archivo"+o.message)})},B=async t=>{await $({title:"Eliminar CV",content:"¿Estás seguro de que deseas eliminar este Curriculum's Vitae?"})&&k.deleteMyCV(t.id).then(({success:s,message:r})=>{if(!s){p(r||"Error al eliminar el Curriculum's Vitae");return}H("Curriculum's Vitae eliminado correctamente."),f()}).catch(s=>{p("Error al eliminar el Curriculum's Vitae: "+s.message)})},_=t=>{n.value.unshift({id:t.id,version:t.version,url:t.url,createdAt:new Date().toISOString()})};return b(async()=>{await f(),h.on("uploadCV",t=>_(t))}),O(()=>{h.off("uploadCV",t=>_(t))}),b(()=>{f()}),(t,o)=>(d(),g("div",null,[e(m,{rounded:"xl",class:"mb-4"},{default:a(()=>[e(W,{modelValue:u(c),"onUpdate:modelValue":o[0]||(o[0]=s=>P(c)?c.value=s:null),grow:"",stacked:""},{default:a(()=>[e(w,{value:"postulations"},{default:a(()=>[e(i,{icon:"mdi-briefcase",class:"mr-2"}),l(" Postulaciones ")]),_:1}),e(w,{value:"cvs"},{default:a(()=>[e(i,{icon:"mdi-file-document",class:"mr-2"}),l(" Curriculum's Vitae ")]),_:1})]),_:1},8,["modelValue"])]),_:1}),e(m,{class:"mb-4"},{default:a(()=>[e(q,null,{default:a(()=>[e(Q,{style:{"align-items":"center"}},{default:a(()=>[e(x,{cols:"12",sm:"6"},{default:a(()=>[e(i,{icon:"mdi-file-document",class:"mr-2"}),l(" Curriculum's Vitae ")]),_:1}),e(x,{cols:"12",sm:"6",class:"text-right"},{default:a(()=>[e(K,{styleBtn:"tonal"})]),_:1})]),_:1})]),_:1}),e(u(D),null,{default:a(()=>[te,l(" Puedes subir y eliminar tus CVs. ")]),_:1})]),_:1}),u(n).length>0?(d(!0),g(M,{key:0},j(u(n),s=>(d(),v(m,{key:s.id,class:"mb-4"},{default:a(()=>[e(X,{color:"surface",class:"pa-2",elevation:5},{prepend:a(()=>[e(i,{icon:"mdi-briefcase",class:"mr-2"})]),append:a(()=>[e(Z,{location:"bottom"},{activator:a(({props:r})=>[e(z,G({icon:"mdi-dots-vertical",variant:"text"},r),null,16)]),default:a(()=>[e(ee,null,{default:a(()=>[e(ae,null,{default:a(()=>[l("Acciones")]),_:1}),e(E,{onClick:()=>A(s)},{default:a(()=>[e(L,null,{default:a(()=>[e(i,{start:""},{default:a(()=>[l(" mdi-download ")]),_:1}),l(" Descargar ")]),_:1})]),_:2},1032,["onClick"]),e(E,{onClick:()=>B(s)},{default:a(()=>[e(L,null,{default:a(()=>[e(i,{start:""},{default:a(()=>[l(" mdi-trash ")]),_:1}),l(" Eliminar ")]),_:1})]),_:2},1032,["onClick"])]),_:2},1024)]),_:2},1024)]),default:a(()=>[e(Y,{class:"text-h6",text:s.version},null,8,["text"])]),_:2},1024)]),_:2},1024))),128)):y("",!0),u(n).length===0?(d(),v(m,{key:1,class:"pa-4 text-center"},{default:a(()=>[se,oe]),_:1})):y("",!0)]))}});typeof R=="function"&&R(re);export{re as default};
