PageSourceSearch

https://texora.ai/assets/JobCalendar.CAUbJhGi.js

js texora.ai collected 2026-10-05 12:50:00 UTC 16,911 bytes, 1 lines download raw bytes

1import{u as ee,r as l,j as e,a as T}from"./index.CMes7NSj.js";import{L as te}from"./Layout.C71eM22T.js";import{C as _}from"./calendar.BpDkqKTL.js";import{P as I}from"./plus.B2sTCp4I.js";import{R as se}from"./refresh-cw.BBYs83Zs.js";import{C as re}from"./chevron-left.CMXh4DxZ.js";import{C as ae}from"./chevron-right.Ce9jvXfU.js";import{C as Y}from"./circle-alert.CPUTNIMj.js";import{L as O}from"./loader-circle.Bi7q0UmI.js";import{C as P}from"./clock.DQPSbsTx.js";import{B as F}from"./briefcase.CCBGcyc1.js";import{F as oe}from"./file-pen.CGV69vSz.js";import{T as ie}from"./trash-2._q1IJ7V4.js";import{C as ne}from"./circle-check-big.5mieDMMq.js";import{X as J}from"./x.CTBTNLmV.js";import{S as le}from"./sparkles.DX8_njP2.js";import"./useTheme.BfVecHYw.js";import"./createLucideIcon.BIPH4Qyf.js";import"./shield.D67KeQV5.js";import"./mail.CwKlJeun.js";import"./gift.BqHmzo-y.js";import"./check.BNCofhee.js";import"./copy.DhcUi1QA.js";import"./lock.DT1CA5IT.js";import"./eye-off.w0-4f_JF.js";import"./eye.DXTTr_Ft.js";import"./calendar-clock.CS3VChkK.js";import"./message-square.DvgMIpvb.js";import"./user-plus.vYWnvW7b.js";import"./newspaper.C8N7UTGz.js";import"./clipboard-list.0WZHK3yk.js";import"./calendar-check.BzAPdruy.js";import"./circle-check.TQ-UR8j1.js";import"./star.Cj_rqQAr.js";import"./users-round.CAV0qVaX.js";import"./zap.BJddcI11.js";import"./users.BA7_fJ_p.js";import"./layers.DgnA_cYT.js";import"./upload.CgbGIhr1.js";import"./folder-open.ewln6EAy.js";import"./target.BRdav6nX.js";import"./file-text.Din2KaI_.js";import"./trending-up.C0wFoeA-.js";import"./layout-dashboard.DFPBaI_A.js";import"./building-2.COgzt34u.js";import"./chart-column.D2lO_iiz.js";import"./activity.Bld1vZ8d.js";import"./megaphone.D6EkCnjX.js";import"./wallet.CW5CW5Oc.js";import"./sun.AYU8lJGG.js";import"./log-out.DdKQLPwm.js";import"./menu.BFOkls43.js";import"./layout-template.E4XSTnuE.js";import"./file-check.UhbWq35z.js";import"./search.CkxbqJzX.js";import"./settings.CY7BgCwr.js";import"./image.B558kRj9.js";const ce=["January","February","March","April","May","June","July","August","September","October","November","December"],de=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ge=(r,s)=>r.getFullYear()===s.getFullYear()&&r.getMonth()===s.getMonth()&&r.getDate()===s.getDate(),U=9,B=0,E=r=>r?new Date(r).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):"",R=r=>r?new Date(r).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"",me=r=>{const s=r.getFullYear(),u=r.getMonth(),m=new Date(s,u,1).getDay(),h=new Date(s,u,1-m),g=[];for(let p=0;p<42;p++){const x=new Date(h);x.setDate(h.getDate()+p),g.push(x)}return g},yt=()=>{const r=ee(),[s,u]=l.useState(()=>{const t=localStorage.getItem("theme");return t==="dark"||t===null});l.useEffect(()=>{const t=()=>{const o=localStorage.getItem("theme");u(o==="dark"||o===null)};t();const a=setInterval(t,100);return()=>clearInterval(a)},[]);const c=l.useMemo(()=>new Date,[]),[m,h]=l.useState(()=>new Date(c.getFullYear(),c.getMonth(),1)),[g,p]=l.useState([]),[x,A]=l.useState([]),[y,N]=l.useState(!0),[w,D]=l.useState(""),[k,v]=l.useState(null),[b,d]=l.useState(null),j=(t,a)=>{d({type:t,message:a}),setTimeout(()=>d(null),4500)},f=async()=>{var t,a,o,n;N(!0),D("");try{const[i,S]=await Promise.all([T.get("/api/jobs/scheduled/list"),T.get("/api/jobs/drafts/list")]);p(((t=i.data)==null?void 0:t.jobs)||[]),A(((a=S.data)==null?void 0:a.jobs)||[])}catch(i){D(((n=(o=i==null?void 0:i.response)==null?void 0:o.data)==null?void 0:n.error)||i.message||"Failed to load calendar data")}finally{N(!1)}};l.useEffect(()=>{f()},[]);const M=l.useMemo(()=>{const t={};for(const a of g){if(!a.scheduledAt)continue;const o=new Date(a.scheduledAt),n=`${o.getFullYear()}-${o.getMonth()}-${o.getDate()}`;t[n]||(t[n]=[]),t[n].push(a)}return t},[g]),H=l.useMemo(()=>me(m),[m]),W=`${ce[m.getMonth()]} ${m.getFullYear()}`,z=()=>{const t=new Date(m);t.setMonth(t.getMonth()-1),h(t)},Q=()=>{const t=new Date(m);t.setMonth(t.getMonth()+1),h(t)},G=()=>h(new Date(c.getFullYear(),c.getMonth(),1)),L=t=>{const a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),o=new Date(c.getFullYear(),c.getMonth(),c.getDate());return a<o},K=t=>{L(t)||v(t)},X=async(t,a)=>{var o,n;try{await T.post(`/api/jobs/${t}/schedule`,{scheduledAt:a.toISOString()}),j("success","Job scheduled successfully"),v(null),f()}catch(i){j("error",((n=(o=i==null?void 0:i.response)==null?void 0:o.data)==null?void 0:n.error)||i.message||"Failed to schedule")}},q=async(t,a)=>{var o,n;if(window.confirm(`Cancel schedule for "${a}"? It will return to drafts.`))try{await T.delete(`/api/jobs/${t}/schedule`),j("success","Schedule cancelled — job returned to drafts"),f()}catch(i){j("error",((n=(o=i==null?void 0:i.response)==null?void 0:o.data)==null?void 0:n.error)||i.message||"Failed to cancel")}},V=t=>{const a=new Date(t);a.setHours(U,B,0,0),r("/post-job",{state:{presetScheduleAt:a.toISOString()}})},Z=s?"bg-gray-900 text-white":"bg-gray-50 text-gray-900",$=s?"bg-gray-800 border-gray-700/60":"bg-white border-gray-200";return e.jsxs(te,{children:[e.jsx("div",{className:`min-h-screen transition-colors duration-300 ${Z}`,children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6",children:[e.jsx("div",{className:`rounded-xl p-4 mb-4 border ${$}`,children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:`w-5 h-5 ${s?"text-indigo-400":"text-indigo-600"}`}),e.jsx("h1",{className:"text-lg font-semibold",children:"Job Calendar"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>r("/post-job"),className:"flex items-center gap-2 px-4 py-2 rounded-xl font-semibold text-sm bg-indigo-600 text-white hover:bg-indigo-700 transition-all",children:[e.jsx(I,{className:"w-4 h-4"})," New Job"]}),e.jsxs("button",{onClick:f,className:`flex items-center gap-2 px-4 py-2 rounded-xl font-semibold transition-all duration-200 ${s?"bg-gradient-to-r from-gray-700 to-gray-600 text-white hover:from-gray-600 hover:to-gray-500 shadow-lg":"bg-gradient-to-r from-gray-200 to-gray-300 text-gray-900 hover:from-gray-300 hover:to-gray-400 shadow-md"}`,children:[e.jsx(se,{className:`w-4 h-4 ${y?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]})]})]})}),e.jsxs("div",{className:`rounded-xl p-3 mb-4 border flex items-center justify-between ${$}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:z,className:`p-2 rounded-lg transition-colors ${s?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-600"}`,"aria-label":"Previous month",children:e.jsx(re,{className:"w-5 h-5"})}),e.jsx("h2",{className:`text-lg font-bold min-w-[180px] text-center ${s?"text-white":"text-gray-900"}`,children:W}),e.jsx("button",{onClick:Q,className:`p-2 rounded-lg transition-colors ${s?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-600"}`,"aria-label":"Next month",children:e.jsx(ae,{className:"w-5 h-5"})})]}),e.jsx("button",{onClick:G,className:`text-sm font-medium px-3 py-1.5 rounded-lg transition-colors ${s?"bg-gray-700 text-gray-200 hover:bg-gray-600":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:"Today"})]}),w&&e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 mb-6 rounded-xl border ${s?"bg-red-500/10 border-red-500/30 text-red-400":"bg-red-50 border-red-200 text-red-700"}`,children:[e.jsx(Y,{className:"w-5 h-5 flex-shrink-0"}),e.jsx("span",{className:"text-sm",children:w})]}),e.jsxs("div",{className:`rounded-xl border overflow-hidden ${$}`,children:[e.jsx("div",{className:`grid grid-cols-7 ${s?"bg-gray-800 border-b border-gray-700":"bg-gray-50 border-b border-gray-200"}`,children:de.map(t=>e.jsx("div",{className:`px-2 py-3 text-[11px] font-bold uppercase tracking-wide text-center ${s?"text-gray-400":"text-gray-500"}`,children:t},t))}),y?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(O,{className:`w-8 h-8 animate-spin ${s?"text-indigo-400":"text-indigo-600"}`})}):e.jsx("div",{className:"grid grid-cols-7",children:H.map(t=>{const a=t.getMonth()===m.getMonth(),o=ge(t,c),n=L(t),i=`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`,S=M[i]||[];return e.jsxs("button",{onClick:()=>K(t),disabled:n,className:`relative min-h-[110px] p-2 text-left border-r border-b transition-colors ${s?"border-gray-700":"border-gray-200"} ${n?s?"bg-gray-900/40 cursor-not-allowed":"bg-gray-50 cursor-not-allowed":a?s?"bg-gray-800/40 hover:bg-indigo-600/10":"bg-white hover:bg-indigo-50/50":s?"bg-gray-900/30 text-gray-500":"bg-gray-50/60 text-gray-400"} ${o?s?"ring-1 ring-indigo-500/50":"ring-1 ring-indigo-300":""}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:`text-xs font-semibold ${o?s?"text-indigo-300":"text-indigo-700":a?s?"text-gray-200":"text-gray-700":s?"text-gray-600":"text-gray-400"}`,children:t.getDate()}),!n&&a&&e.jsx(I,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 ${s?"text-indigo-400":"text-indigo-500"}`})]}),e.jsxs("div",{className:"space-y-1",children:[S.slice(0,3).map(C=>e.jsxs("div",{className:`px-1.5 py-1 rounded text-[10px] leading-tight font-medium truncate ${s?"bg-indigo-500/20 text-indigo-200 border border-indigo-500/30":"bg-indigo-100 text-indigo-800 border border-indigo-200"}`,title:`${C.jobTitle} — ${E(C.scheduledAt)}`,children:[e.jsx("span",{className:"opacity-70",children:E(C.scheduledAt)})," · ",C.jobTitle]},C._id)),S.length>3&&e.jsxs("p",{className:`text-[10px] ${s?"text-gray-500":"text-gray-400"}`,children:["+",S.length-3," more"]})]})]},t.toISOString())})})]}),!y&&g.length>0&&e.jsxs("div",{className:`mt-4 rounded-xl p-5 border ${$}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(P,{className:`w-5 h-5 ${s?"text-indigo-400":"text-indigo-600"}`}),e.jsx("h3",{className:`text-lg font-semibold ${s?"text-white":"text-gray-900"}`,children:"Upcoming scheduled jobs"})]}),e.jsx("ul",{className:"space-y-2",children:g.slice().sort((t,a)=>new Date(t.scheduledAt)-new Date(a.scheduledAt)).slice(0,8).map(t=>e.jsxs("li",{className:`flex items-center justify-between gap-3 p-3 rounded-xl border ${s?"bg-gray-900/40 border-gray-700/50":"bg-white border-gray-200"}`,children:[e.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${s?"bg-indigo-500/20":"bg-indigo-50"}`,children:e.jsx(F,{className:`w-4 h-4 ${s?"text-indigo-400":"text-indigo-600"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:`text-sm font-medium truncate ${s?"text-white":"text-gray-900"}`,children:t.jobTitle}),e.jsxs("p",{className:`text-xs mt-0.5 ${s?"text-gray-400":"text-gray-500"}`,children:[R(t.scheduledAt)," · ",E(t.scheduledAt),t.department&&` · ${t.department}`]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>r(`/edit-job/${t._id}`),className:`p-1.5 rounded-lg transition-colors ${s?"text-gray-300 hover:text-white hover:bg-gray-700":"text-gray-500 hover:text-gray-900 hover:bg-gray-100"}`,title:"Edit",children:e.jsx(oe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>q(t._id,t.jobTitle),className:`p-1.5 rounded-lg transition-colors ${s?"text-gray-300 hover:text-red-400 hover:bg-red-500/10":"text-gray-500 hover:text-red-600 hover:bg-red-50"}`,title:"Cancel schedule",children:e.jsx(ie,{className:"w-4 h-4"})})]})]},t._id))})]}),!y&&x.length>0&&e.jsxs("div",{className:`mt-4 rounded-xl p-5 border ${$}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:`w-5 h-5 ${s?"text-indigo-400":"text-indigo-600"}`}),e.jsxs("h3",{className:`text-lg font-semibold ${s?"text-white":"text-gray-900"}`,children:["Draft jobs (",x.length,")"]})]}),e.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Click a calendar date to schedule any draft"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:x.slice(0,6).map(t=>e.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-xl border ${s?"bg-gray-900/40 border-gray-700/50":"bg-white border-gray-200"}`,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${s?"bg-gray-700":"bg-gray-100"}`,children:e.jsx(F,{className:`w-4 h-4 ${s?"text-gray-400":"text-gray-500"}`})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:`text-sm font-medium truncate ${s?"text-white":"text-gray-900"}`,children:t.jobTitle}),e.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:t.employmentType||"—"})]})]},t._id))})]})]})}),k&&e.jsx(xe,{isDarkMode:s,date:k,drafts:x,onClose:()=>v(null),onScheduleDraft:X,onQuickCreate:V}),b&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50",children:e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-xl shadow-lg text-white ${b.type==="success"?"bg-emerald-500":"bg-red-500"}`,children:[b.type==="success"?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(Y,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:b.message}),e.jsx("button",{onClick:()=>d(null),className:"ml-1 opacity-70 hover:opacity-100",children:e.jsx(J,{className:"w-3.5 h-3.5"})})]})})]})},xe=({isDarkMode:r,date:s,drafts:u,onClose:c,onScheduleDraft:m,onQuickCreate:h})=>{const[g,p]=l.useState(""),[x,A]=l.useState(`${String(U).padStart(2,"0")}
1:${String(B).padStart(2,"0")}`),[y,N]=l.useState(!1),w=()=>{const[d,j]=x.split(":").map(M=>parseInt(M,10)),f=new Date(s);return f.setHours(d||0,j||0,0,0),f},D=async()=>{if(g){N(!0);try{await m(g,w())}finally{N(!1)}}},k=()=>{c(),h(w())},v=r?"bg-gray-800 border-gray-700":"bg-white border-gray-200",b=`w-full px-3 py-2 rounded-xl border text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 ${r?"bg-gray-900 border-gray-700 text-white":"bg-gray-50 border-gray-200 text-gray-900"}`;return e.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:c}),e.jsx("div",{className:`relative w-full max-w-md rounded-2xl shadow-2xl border ${v}`,children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-violet-500 text-white flex items-center justify-center",children:e.jsx(_,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:`text-lg font-bold ${r?"text-white":"text-gray-900"}`,children:["Schedule for ",R(s)]}),e.jsx("p",{className:`text-sm ${r?"text-gray-400":"text-gray-500"}`,children:"Pick an existing draft or create a new job"})]})]}),e.jsx("label",{className:`block text-sm font-medium mb-1.5 ${r?"text-gray-300":"text-gray-700"}`,children:"Time"}),e.jsx("input",{type:"time",value:x,onChange:d=>A(d.target.value),className:b}),e.jsx("label",{className:`block text-sm font-medium mt-4 mb-1.5 ${r?"text-gray-300":"text-gray-700"}`,children:"Schedule an existing draft"}),u.length===0?e.jsx("p",{className:`text-xs mb-2 ${r?"text-gray-500":"text-gray-400"}`,children:'No drafts available — use "Create new job" below.'}):e.jsxs("select",{value:g,onChange:d=>p(d.target.value),className:b,children:[e.jsx("option",{value:"",children:"— pick a draft —"}),u.map(d=>e.jsx("option",{value:d._id,children:d.jobTitle},d._id))]}),e.jsxs("button",{onClick:D,disabled:!g||y,className:"w-full mt-4 inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl bg-gradient-to-r from-indigo-600 to-violet-600 text-white font-semibold hover:from-indigo-700 hover:to-violet-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[y?e.jsx(O,{className:"w-4 h-4 animate-spin"}):e.jsx(P,{className:"w-4 h-4"}),"Schedule draft"]}),e.jsxs("div",{className:"flex items-center gap-3 my-5",children:[e.jsx("div",{className:`flex-1 h-px ${r?"bg-gray-700":"bg-gray-200"}`}),e.jsx("span",{className:`text-xs ${r?"text-gray-500":"text-gray-400"}`,children:"or"}),e.jsx("div",{className:`flex-1 h-px ${r?"bg-gray-700":"bg-gray-200"}`})]}),e.jsxs("button",{onClick:k,className:`w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-xl border font-semibold transition-colors ${r?"border-gray-700 text-gray-200 hover:bg-gray-700":"border-gray-200 text-gray-700 hover:bg-gray-100"}`,children:[e.jsx(le,{className:"w-4 h-4"}),"Create new job for this date"]}),e.jsx("button",{onClick:c,className:`absolute top-4 right-4 p-1.5 rounded-lg ${r?"hover:bg-gray-700 text-gray-300":"hover:bg-gray-100 text-gray-500"}`,"aria-label":"Close",children:e.jsx(J,{className:"w-5 h-5"})})]})})]})};export{yt as default};

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.