PageSourceSearch

https://static.unreality.is/assets/_id_-CDBmxrOT.js

js unreality.is collected 2026-10-06 04:56:05 UTC 11,296 bytes, 1 lines download raw bytes

1import{r as e}from"./rolldown-runtime-DwynqlJ6.js";import{i as s,r as a}from"./animation-vendor-Cu7i5djq.js";import{h as t}from"./react-vendor-DOdzVUP9.js";import{a as r,i}from"./router-Pz9oQ9aI.js";import{c as o,j as n,l,m as d,p as c,t as p}from"./state-vendor-Bno-87vC.js";import{n as m}from"./use-toast-BFN2Rnfk.js";import{t as u}from"./button-0Jrzi_Qn.js";import{bt as j,ct as x,on as h,s as g,un as f,y as b}from"./icons-vendor-PGdPJyIF.js";import{a as y,i as v,n as N,r as w,t as S}from"./select-BiiM8EbU.js";import{n as T,r as k}from"./routes-BTHeC-N1.js";import{a as q,c as M,i as C,n as E,o as F,r as J,s as I,t as D}from"./form-CyZyApim.js";import{i as U}from"./media-utils-C3FrgNq3.js";import{t as B}from"./api-client-DBV6AiYF.js";import{n as O,t as P}from"./alert-DEq2buPz.js";import{n as R,t as V}from"./job-permissions-BA3XWyPX.js";import{a as $,c as K,d as Y,f as z,h as A,i as L,l as Q,m as W,n as _,o as G,p as H,r as X,s as Z,t as ee,u as se}from"./media-uploader-BsSZi4ye.js";var ae=e(s(),1),te=a();var re=o({...A,category:l({message:"Please select a category."}),status:p(["open","closed","filled"],{message:"Please select a job status."})}),ie=[{value:"open",label:"Open"},{value:"filled",label:"Filled"},{value:"closed",label:"Closed"}];function oe({job:e}){const[s,a]=(0,ae.useState)(!1),[,r]=i(),o=n(),{toast:l}=m(),[p,x]=(0,ae.useState)([]),[h,f]=(0,ae.useState)(e.mediaUrls?e.mediaUrls.map((s,a)=>({url:s,type:e.mediaTypes?.[a]||"image"})):[]),[T,O]=(0,ae.useState)([]),{data:P}=d({queryKey:["/api/user"],queryFn:async()=>{const e=await fetch("/api/user",{credentials:"include"});if(!e.ok)throw new Error(`Request failed: ${e.status}`);return e.json()}}),{data:R}=d({queryKey:["/api/projects",{userId:P?.id}],queryFn:async()=>{const e=await fetch(`/api/projects?userId=${P.id}`,{credentials:"include"});if(!e.ok)throw new Error(`Request failed: ${e.status}`);return e.json()},enabled:Boolean(P?.id)}),V=t({resolver:M(re),defaultValues:{title:e.title,category:e.category,location:e.location,locationType:e.locationType,projectType:e.projectType,jobType:e.jobType??"job",budgetMin:e.budgetMin?e.budgetMin.toString():"",budgetMax:e.budgetMax?e.budgetMax.toString():"",dueDate:(()=>{if(e.dueDate)return new Date(e.dueDate)})(),description:e.description,creativeBrief:"",deliverables:"",requiredSkills:e.category?e.category.split(",").filter(e=>e.trim()):[],tags:e.tags&&0!==e.tags.length?e.tags.join(", "):"",realityTags:e.realityTags||[],industrySubsets:e.industrySubsets||[],projectId:e.projectId?e.projectId.toString():"none",status:e.status}}),A=c({mutationFn:async s=>(await B.put(`/jobs/${e.id}`,s)).data,onSuccess:s=>{o.invalidateQueries({queryKey:["/api/jobs"]}),o.invalidateQueries({queryKey:["/api/jobs",e.id]}),l({title:"Job updated successfully!",description:"Your job has been updated."}),r(k.job(e.id))},onError:e=>{console.error("Error updating job:",e),l({title:"Failed to update job",description:"There was an error updating your job. Please try again.",variant:"destructive"}),a(!1)}}),oe="rfp"===V.getValues().jobType?"Update RFP":"Update Job",ne=s?"Updating...":oe;return(0,te.jsx)("div",{className:"w-full max-w-3xl mx-auto",children:(0,te.jsxs)(D,{...V,children:[(0,te.jsxs)("div",{className:"text-sm text-muted-foreground mb-6",children:["Fields marked with ",(0,te.jsx)("span",{className:"text-destructive",children:"*"})," are required"]}),(0,te.jsxs)("form",{onSubmit:V.handleSubmit(async e=>{a(!0);try{const s=function(e,s,a,t){const r=new FormData;r.append("title",e.title),r.append("category",(e.requiredSkills||[]).join(",")||e.category),r.append("location",e.location),r.append("locationType",e.locationType),r.append("projectType",e.projectType),r.append("jobType",e.jobType),r.append("budgetMin",e.budgetMin??""),r.append("budgetMax",e.budgetMax??""),r.append("dueDate",e.dueDate?e.dueDate.toISOString():""),r.append("description",e.description),r.append("creativeBrief",e.creativeBrief||""),r.append("deliverables",e.deliverables||"");const i=e.projectId&&""!==e.projectId&&"none"!==e.projectId?e.projectId:"";r.append("projectId",i);const o=e.tags?e.tags.split(",").map(e=>e.trim()).filter(e=>e.length>0):[];return r.append("tags",JSON.stringify(o)),r.append("realityTags",JSON.stringify(e.realityTags)),r.append("industrySubsets",JSON.stringify(e.industrySubsets)),r.append("status",e.status),function(e,s,a,t){const r=s.length>0,i=a.length>0;if(r&&!i&&0===t.length)e.append("keepExistingMedia","true");else if(i){a.forEach(s=>{e.append("file",s)});const i=r&&t.length<s.length;e.append("keepExistingMedia",i?"true":"false")}
1else e.append("keepExistingMedia","false")}(r,s,a,t),r}(e,h,p,T);await A.mutateAsync(s)}catch(s){console.error("Error in form submission:",s),a(!1)}}),className:"space-y-8",children:[(0,te.jsx)(H,{form:V}),(0,te.jsx)(C,{control:V.control,name:"status",render:({field:e})=>(0,te.jsxs)(q,{children:[(0,te.jsxs)(F,{children:["Job Status ",(0,te.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,te.jsxs)(S,{onValueChange:e.onChange,defaultValue:e.value,required:!0,children:[(0,te.jsx)(E,{children:(0,te.jsx)(v,{className:"bg-background",children:(0,te.jsx)(y,{placeholder:"Select job status"})})}),(0,te.jsx)(N,{children:ie.map(e=>(0,te.jsx)(w,{value:e.value,children:e.label},e.value))})]}),(0,te.jsx)(J,{children:"Set the current status of this job opening"}),(0,te.jsx)(I,{})]})}),(0,te.jsx)(C,{control:V.control,name:"jobType",render:({field:e})=>(0,te.jsxs)(q,{children:[(0,te.jsxs)(F,{children:["Job Type ",(0,te.jsx)("span",{className:"text-destructive",children:"*"})]}),(0,te.jsxs)(S,{onValueChange:e.onChange,defaultValue:e.value,required:!0,children:[(0,te.jsx)(E,{children:(0,te.jsx)(v,{className:"bg-background",children:(0,te.jsx)(y,{placeholder:"Select job type"})})}),(0,te.jsxs)(N,{children:[(0,te.jsx)(w,{value:"job",children:(0,te.jsxs)("div",{className:"flex flex-col",children:[(0,te.jsx)("span",{children:"Job Opportunity"}),(0,te.jsx)("span",{className:"text-xs text-muted-foreground",children:"You're hiring someone to join or assist on a defined role"})]})}),(0,te.jsx)(w,{value:"rfp",children:(0,te.jsxs)("div",{className:"flex flex-col",children:[(0,te.jsx)("span",{children:"RFP (Request for Proposal)"}),(0,te.jsx)("span",{className:"text-xs text-muted-foreground",children:"You're requesting project proposals to solve a specific creative brief"})]})})]})]}),(0,te.jsx)(J,{children:"Choose whether this is a job opportunity or a request for proposals"}),(0,te.jsx)(I,{})]})}),(0,te.jsx)("div",{className:"space-y-6",children:(0,te.jsx)(se,{form:V})}),(0,te.jsx)($,{form:V}),(0,te.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:(0,te.jsx)(Q,{form:V})}),(0,te.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,te.jsx)(G,{form:V}),(0,te.jsx)(Z,{form:V})]}),(0,te.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:(0,te.jsx)(_,{form:V})}),(0,te.jsx)(L,{form:V}),(0,te.jsx)(K,{form:V,projects:R}),(0,te.jsx)(W,{form:V}),(0,te.jsxs)("div",{className:"space-y-4",children:[(0,te.jsx)(F,{children:"Media (Optional)"}),h.length>0&&(0,te.jsxs)("div",{children:[(0,te.jsx)("h4",{className:"text-sm font-medium mb-3 font-logo",children:"Current Media:"}),(0,te.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:h.map((e,s)=>(0,te.jsx)("div",{className:"relative group",children:(0,te.jsxs)("div",{className:"border rounded-lg overflow-hidden",children:["image"===e.type?(0,te.jsx)("img",{src:U(e.url),alt:`Media ${s+1}`,className:"w-full h-24 object-cover",onError:e=>{e.target.src="/placeholder-image.svg"}}):(0,te.jsx)("div",{className:"w-full h-24 bg-secondary flex items-center justify-center",children:(0,te.jsx)(g,{className:"h-8 w-8 text-muted-foreground"})}),(0,te.jsx)(u,{type:"button",variant:"destructive",size:"sm",className:"absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{return s=e.url,O(e=>[...e,s]),void f(e=>e.filter(e=>e.url!==s));var s},children:(0,te.jsx)(b,{className:"h-3 w-3"})})]})},e.url))})]}),(0,te.jsxs)("div",{children:[(0,te.jsx)("h4",{className:"text-sm font-medium mb-3 font-logo",children:"Add New Media:"}),(0,te.jsx)(ee,{onUpload:e=>{x(s=>[...s,...e])},maxFiles:5,maxSize:52428800,accept:{"image/*":[],"video/*":[]}})]}),p.length>0&&(0,te.jsxs)("div",{children:[(0,te.jsx)("h4",{className:"text-sm font-medium mb-2 font-logo",children:"New Uploads:"}),(0,te.jsx)("ul",{className:"space-y-2",children:p.map((e,s)=>(0,te.jsxs)("li",{className:"flex items-center justify-between bg-secondary/30 p-2 rounded",children:[(0,te.jsxs)("div",{className:"flex items-center gap-2",children:[e.type.startsWith("image/")?(0,te.jsx)(j,{className:"h-4 w-4 text-muted-foreground"}):(0,te.jsx)(g,{className:"h-4 w-4 text-muted-foreground"}),(0,te.jsx)("span",{className:"text-sm truncate max-w-[250px]",children:e.name})]}),(0,te.jsx)(u,{type:"button",variant:"ghost",size:"sm",onClick:()=>(e=>{x(s=>s.filter((s,a)=>a!==e))})(s),children:"Remove"})]},e.name))})]}),(0,te.jsx)(J,{children:"Upload images or videos related to the job (maximum 50MB total). You can add new media or remove existing media."})]}),(0,te.jsx)(z,{form:V}),(0,te.jsx)(Y,{form:V}),(0,te.jsx)(X,{form:V}),(0,te.jsxs)("div",{className:"flex justify-end space-x-4",children:[(0,te.jsx)(u,{type:"button",variant:"outline",onClick:()=>r(k.job(e.id)),disabled:s,children:"Cancel"}),(0,te.jsx)(u,{type:"submit",disabled:s,children:ne})]})]})]})})}function ne(){const e=r(),[,s]=i(),{isLoading:a,user:t}=R(),o=T(e.id),{data:n,isLoading:l,error:c}=d({queryKey:["/api/jobs",o],queryFn:async()=>{const e=await fetch(`/api/jobs/${o}`,{credentials:"include"});if(!e.ok){const s=await e.json().catch(()=>({}));throw new Error(s?.error||"Failed to load job")}return e.json()},enabled:null!==o}),p=V(n,t),m=()=>{o&&s(k.job(o))};return l||a?(0,te.jsx)("div",{className:"flex items-center justify-center min-h-screen",children:(0,te.jsx)(x,{className:"h-8 w-8 animate-spin text-primary"})}):c||!n?(0,te.jsxs)("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[(0,te.jsxs)(P,{variant:"destructive",className:"mb-4",children:[(0,te.jsx)(h,{className:"h-4 w-4"}),(0,te.jsx)(O,{children:c instanceof Error?c.message:"Failed to load job details"})]}),(0,te.jsxs)(u,{onClick:()=>s("/jobs"),variant:"outline",className:"gap-2",children:[(0,te.jsx)(f,{className:"h-4 w-4"}),"Back to Jobs"]})]}):p?(0,te.jsxs)("div",{className:"max-w-5xl mx-auto px-4 py-8 pb-20",children:[(0,te.jsxs)(u,{onClick:m,variant:"outline",className:"mb-6 gap-2",children:[(0,te.jsx)(f,{className:"h-4 w-4"}),"Back to Job Details"]}
1),(0,te.jsxs)("div",{className:"mb-8",children:[(0,te.jsx)("h1",{className:"text-3xl font-bold font-logo mb-2",children:"Edit Job"}),(0,te.jsx)("p",{className:"text-muted-foreground",children:"Update your job posting details."})]}),(0,te.jsx)(oe,{job:n})]}):(0,te.jsxs)("div",{className:"max-w-4xl mx-auto px-4 py-8",children:[(0,te.jsxs)(P,{variant:"destructive",className:"mb-4",children:[(0,te.jsx)(h,{className:"h-4 w-4"}),(0,te.jsx)(O,{children:"You don't have permission to edit this job."})]}),(0,te.jsxs)(u,{onClick:m,variant:"outline",className:"gap-2",children:[(0,te.jsx)(f,{className:"h-4 w-4"}),"Back to Job Details"]})]})}export{ne 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.