1import{x as T,ap as E,d as f,e as O,j as e,aS as A,B as l,ak as L,dW as H,dX as B,dY as D,cx as M}from"./index-DMKs-Jou.js";import{C as m}from"./Card-jiH_VNKn.js";import{C as $}from"./ConfirmDialog-DiELJRI3.js";import{u as W,b as X,c as Y}from"./use-vendor-BVkY4ik6.js";import{V as q}from"./VendorFormWithDevTool-DoUzh_Tl.js";import"./useQuery-CHXhWAD3.js";import"./useMutation-zANYyqi2.js";import"./types-COYF9DOj.js";import"./index.esm-BEVn_BIg.js";import"./Select-CHZo0vRs.js";import"./get-DUfpJk6H.js";import"./Form-C3r-G94t.js";import"./FormContainer-BGgz5_Mm.js";import"./BottomStickyBar-BXGKw0GG.js";import"./FormItem-CMq6_gnq.js";import"./Input-DdknTB-E.js";import"./isNil-DIm4sqGa.js";import"./react-number-format.es-DsWXID3J.js";import"./use-sub-categories-DR3T9xCp.js";import"./TaxonomyService-CjVCnwAe.js";import"./use-file-uploader-oT9Uv436.js";import"./FileService-CmsYJpEU.js";const pe=()=>{var b,N,k,C;const{t:s}=T(),{refreshSession:h}=E(),g=f.useRef(null),F=O(),[x,p]=f.useState(!1),[I,u]=f.useState(!1),{data:r,isLoading:P,error:n}=W(),j=X(),v=Y(),V=t=>{if(!t)return null;const a=t.categories&&typeof t.categories=="object"?Object.entries(t.categories).map(([o,c])=>({category:{value:o,label:o},subcategories:Array.isArray(c)?c.map(d=>({value:d,label:d})):[]})):[{category:{value:"",label:""},subcategories:[]}];return{displayName:t.displayName||"",description:t.description||"",categoryPairs:a,skills:t.skills||[],hourlyRate:t.hourlyRate||0,country:t.country||"Israel",city:t.city||"",languages:t.languages||[{name:"English",proficiency:"Fluent"}],experienceLevel:t.experienceLevel||"Beginner",profileImage:t.profileImage,coverImage:t.coverImage,planId:t.planId}},R=t=>{const a={};return t.categoryPairs.forEach(i=>{var d;const o=(d=i.category)==null?void 0:d.value;if(!o)return;const c=(i.subcategories||[]).map(y=>y.value).filter(y=>!!y);c.length>0&&(a[o]=c)}),{displayName:t.displayName,description:t.description,categories:a,skills:t.skills,hourlyRate:t.hourlyRate,country:t.country,city:t.city,languages:t.languages.map(i=>({name:i.name,proficiency:i.proficiency})),experienceLevel:t.experienceLevel,profileImage:t.profileImage,coverImage:t.coverImage,planId:t.planId}},w=async()=>{if(g.current)try{if(!await g.current.methods.trigger())return;const a=g.current.methods.getValues(),i=R(a);await j.mutateAsync(i),p(!1),await h()}catch(t){console.error("Failed to update vendor:",t)}},S=async()=>{try{await v.mutateAsync(),u(!1),await h()}catch(t){console.error("Failed to delete vendor:",t)}};return P?e.jsx(m,{children:e.jsx("div",{className:"flex justify-center items-center py-8",children:e.jsx(A,{loading:!0})})}):((b=n==null?void 0:n.response)==null?void 0:b.status)===404?e.jsx(m,{children:e.jsxs("div",{className:"text-center py-8 space-y-4",children:[e.jsx("p",{className:"text-gray-600",children:s("settings.vendor.onboardingRequired","You need to complete vendor onboarding to unlock your profile.")}),e.jsx(l,{variant:"solid",onClick:()=>F(L.vendor.onboarding),children:s("settings.vendor.goToOnboarding","Continue Freelancer Onboarding")})]})}):n?e.jsx(m,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-red-500 mb-4",children:s("settings.vendor.loadError","Failed to load vendor profile")}),e.jsx("p",{className:"text-sm text-gray-500",children:((k=(N=n.response)==null?void 0:N.data)==null?void 0:k.message)??n.message})]})}):!r&&!x?e.jsx(m,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-gray-500 mb-4",children:s("settings.vendor.noProfile","No vendor profile found")}),e.jsx(l,{variant:"solid",onClick:()=>p(!0),children:s("settings.vendor.createProfile","Create Freelancer Profile")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(m,{children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold",children:s("settings.vendor.title","Freelancer Profile")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mt-1",children:s("settings.vendor.description","Manage your freelancer profile information")})]}),e.jsx("div",{className:"flex gap-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(l,{variant:"solid",onClick:w,loading:j.isPending,icon:e.jsx(D,{}),children:s("settings.vendor.save","Save")}),e.jsx(l,{variant:"default",onClick:()=>p(!1),icon:e.jsx(M,{}),children:s("settings.vendor.cancel","Cancel")})]}):e.jsxs(e.Fragment,{children:[e.jsx(l,{variant:"twoTone",onClick:()=>p(!0),icon:e.jsx(H,{}),children:s("settings.vendor.edit","Edit")}),r&&e.jsx(l,{variant:"default",onClick:()=>u(!0),icon:e.jsx(B,{}),children:s("settings.vendor.delete","Delete")})]})})]}),x?e.jsx(q,{ref:g,defaultValues:V(r)||void 0,onFormSubmit:()=>{}},`vendor-form-${r==null?void 0:r.vendorId}-${x}`):r?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.displayName","Display Name")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:r.displayName||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.hourlyRate","Hourly Rate")}),e.jsxs("p",{className:"text-gray-900 dark:text-gray-100",children:["$",r.hourlyRate||0,"/hr"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.country","Country")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:r.country||"-"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.city","City")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:r.city||"-"})]})]}),r.description&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.description","Description")}),e.jsx("p",{className:"text-gray-900 dark:text-gray-100",children:r.description})]}),r.categories&&Object.keys(r.categories).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.categories","Categories")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.keys(r.categories).map((t,a)=>e.jsx("span",{className:"px-3 py-1 bg-purple-100 text-purple-800 rounded-full text-sm font-medium",children:t},a))})]}),((C=r.skills)==null?void 0:C.length)>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:s("settings.vendor.skills","Skills")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.skills.map((t,a)=>e.jsx("span",{className:"px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-sm",children:t},a))})]})]}):null]}),e.jsx($,{isOpen:I,type:"danger",title:s("settings.vendor.deleteConfirm.title","Delete Freelancer Profile"),confirmText:s("settings.vendor.deleteConfirm.confirm","Delete"),cancelText:s("settings.vendor.deleteConfirm.cancel","Cancel"),onConfirm:S,onCancel:()=>u(!1),confirmButtonProps:{loading:v.isPending},children:s("settings.vendor.deleteConfirm.message","Are you sure you want to delete your vendor profile? This action cannot be undone.")})]})};export{pe 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.