PageSourceSearch

https://white-yak-197240.hostingersite.com/build/assets/EditResearch-DS3TG6mI.js

js white-yak-197240.hostingersite.com collected 2026-10-03 04:58:32 UTC 8,302 bytes, 1 lines download raw bytes

1import{r as h,j as o,L as O,S as X}from"./app-B835LByG.js";import{B as p}from"./button-sl7Azlq-.js";import{C as G,d as H}from"./card-Dm36Qk8i.js";import{I as l,L as J}from"./label-C_2sIW9U.js";import{T as Q,S as W}from"./textarea-BcPLA1C1.js";import{T as Y,a as Z,b as C,c as b}from"./tabs-B68Idpks.js";import{A as ee}from"./AuthenticatedLayout-By2Fn9Dj.js";import{S as D}from"./sweetalert2.esm.all-B0Dix5B2.js";import{X as te}from"./x-BghNlfR7.js";import"./index-DO-rpKIa.js";import"./index-CWLFM8D5.js";import"./utils-DgjiVB1k.js";import"./index-dx6lgo4y.js";import"./index-CE0Ai7XB.js";import"./index-BR9hBgqN.js";import"./index-DDkadIbr.js";import"./index-DDeWC3bn.js";import"./createLucideIcon-Z4j02yTi.js";const v=({title:s,children:u})=>o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-lg font-semibold",children:s}),o.jsx(W,{}),o.jsx("div",{className:"space-y-4",children:u})]}),a=({label:s,children:u})=>o.jsxs("div",{className:"space-y-1",children:[o.jsx(J,{children:s}),u]}),N=({src:s,alt:u,className:c="h-24 w-auto rounded object-cover"})=>o.jsx("div",{className:"mb-2",children:o.jsx("img",{src:`/storage/images/${s}`,alt:u,className:c})}),je=({research:s})=>{var y;const u={title:s.title||"",description:s.description||"",date:s.date||"",cover:null,keywords:s.keywords?s.keywords.map(t=>t.name).join(", "):"",products:(y=s.products)!=null&&y.length?L(s.products):[j()],documentation:[],existingDocumentation:s.documentation||[],documentationToDelete:[]},[c,n]=h.useState(u),[g,m]=h.useState(!1),[x,P]=h.useState([]),d=t=>{const{name:e,value:r,type:i,files:_}=t.target;i==="file"?w(e,_):e.includes("product_name_")||e.includes("product_url_")?$(e,r):n({...c,[e]:r})},w=(t,e)=>{if(t==="documentation")n({...c,[t]:e});else if(t.includes("product_cover_")){const r=parseInt(t.split("_").pop());T(r,e[0])}else if(t.includes("product_file_")){const r=parseInt(t.split("_").pop());S(r,e[0])}else n({...c,[t]:e[0]})},$=(t,e)=>{const r=t.split("_"),i=parseInt(r[r.length-1]),_=r.slice(0,-1).join("_"),f=[...c.products];f[i]={...f[i],[_]:e},n({...c,products:f})},T=(t,e)=>{const r=[...c.products];r[t]={...r[t],product_cover:e,product_old_cover:r[t].product_old_cover},n({...c,products:r})},S=(t,e)=>{const r=[...c.products];r[t]={...r[t],product_file:e},n({...c,products:r})},F=(t,e)=>{const r=[...c.products];r[t]={...r[t],input_type:e,...e==="url"?{product_file:null}:{product_url:""}},n({...c,products:r})},I=(t,e)=>{e&&e.preventDefault();const r=[...c.existingDocumentation],i=r.splice(t,1)[0];i.id?n({...c,existingDocumentation:r,documentationToDelete:[...c.documentationToDelete,i.id]}):n({...c,existingDocumentation:r})},E=t=>{t.preventDefault(),n({...c,products:[...c.products,j()]})},R=(t,e)=>{e&&e.preventDefault();const r=[...c.products],i=r.splice(t,1)[0];i.product_id&&P([...x,i.product_id]),n({...c,products:r})},k=t=>{t.preventDefault(),m(!0);const e=q();X.post(`/dashboard/research/update/${s.id}`,e,{forceFormData:!0,onSuccess:()=>{m(!1),D.fire({icon:"success",title:"Success!",text:"Research updated successfully!",confirmButtonColor:"#3085d6"})},onError:r=>{m(!1),D.fire({icon:"error",title:"Error!",text:Object.values(r)[0],confirmButtonColor:"#d33"})}})};function j(){return{product_name:"",product_cover:null,product_url:"",product_file:null,input_type:"url"}}function L(t){return t.map(e=>({product_id:e.id,product_name:e.name||"",product_cover:null,product_old_cover:e.cover,product_url:e.url||"",product_file:null,input_type:e.file_product?"file":"url",product_old_file:e.file_product||null}))}function q(){const t=new FormData;return t.append("title",c.title),t.append("description",c.description),t.append("date",c.date),t.append("keywords",c.keywords),c.cover&&t.append("cover",c.cover),B(t),x.forEach((e,r)=>{t.append(`removed_products[${r}]`,e)}),A(t),t}function B(t){c.products.filter(e=>e.product_name.trim()!=="").forEach((e,r)=>{t.append(`products[${r}][product_id]`,e.product_id||""),t.append(`products[${r}][product_name]`,e.product_name),t.append(`products[${r}][input_type]`,e.input_type),e.input_type==="url"?t.append(`products[${r}][product_url]`,e.product_url||"#"):e.input_type==="file"&&(e.product_file?t.append(`products[${r}][product_file]`,e.product_file):e.product_old_file&&t.append(`products[${r}][product_old_file]`,e.product_old_file)),e.product_cover?t.append(`products[${r}][product_cover]`,e.product_cover):e.product_old_cover&&t.append(`products[${r}][product_old_cover]`,e.product_old_cover)})}function A(t){if(c.documentation.length>0)for(let e=0;e<c.documentation.length;e++)t.append("documentation[]",c.documentation[e]);c.existingDocumentation.forEach((e,r)=>{t.append(`existing_documentation[${r}]`,e.id)}),c.documentationToDelete.forEach((e,r)=>{t.append(`documentation_to_delete[${r}]`,e)})}const U=()=>o.jsxs(v,{title:"Basic Information",children:[o.jsx(a,{label:"Title",children:o.jsx(l,{type:"text",name:"title",value:c.title,onChange:d,required:!0})}),o.jsx(a,{label:"Description",children:o.jsx(Q,{name:"description",value:c.description,onChange:d,rows:6,required:!0})}),o.jsx(a,{label:"Date",children:o.jsx(l,{type:"date",name:"date",value:c.date,onChange:d,required:!0})}),o.jsx(a,{label:"Current Cover Image",children:s.cover&&o.jsx(N,{src:s.cover,alt:"Current cover"})}),o.jsx(a,{label:"Upload New Cover Image",children:o.jsx(l,{type:"file",name:"cover",onChange:d,accept:"image/*"})}),o.jsx(a,{label:"Keywords",children:o.jsx(l,{type:"text",name:"keywords",value:c.keywords,onChange:d,placeholder:"e.g. AI, Machine Learning",required:!0})})]}),z=(t,e)=>
1o.jsxs(H,{className:"space-y-4 rounded-md border p-6",children:[o.jsx(a,{label:"Product Name",children:o.jsx(l,{type:"text",name:`product_name_${e}`,value:t.product_name,onChange:d,required:!0})}),o.jsxs(a,{label:"Product Cover Image",children:[t.product_old_cover&&o.jsx(N,{src:t.product_old_cover,alt:`Product ${e+1} cover`}),o.jsx(l,{type:"file",name:`product_cover_${e}`,onChange:d,accept:"image/*"})]}),o.jsx(a,{label:"URL product or file product",children:o.jsxs(Y,{defaultValue:t.input_type,className:"w-full",onValueChange:r=>F(e,r),children:[o.jsxs(Z,{className:"grid w-full grid-cols-2",children:[o.jsx(C,{value:"url",children:"URL"}),o.jsx(C,{value:"file",children:"File"})]}),o.jsx(b,{value:"url",className:"mt-2",children:o.jsx(l,{type:"text",name:`product_url_${e}`,value:t.product_url,onChange:d,placeholder:"https://example.com/product",required:t.input_type==="url"})}),o.jsxs(b,{value:"file",className:"mt-2",children:[t.product_old_file&&o.jsx("div",{className:"mb-2",children:o.jsxs("p",{className:"text-sm",children:["Current file: ",t.product_old_file]})}),o.jsx(l,{type:"file",name:`product_file_${e}`,onChange:d,accept:".pdf",required:t.input_type==="file"&&!t.product_old_file})]})]})}),o.jsx(p,{variant:"destructive",onClick:r=>R(e,r),children:"Remove"})]},e),V=()=>o.jsxs(v,{title:"Research Products",children:[o.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.products.map(z)}),o.jsx(p,{onClick:E,children:"+ Add Product"})]}),K=(t,e)=>o.jsxs("div",{className:"group relative rounded-md border p-2",children:[o.jsx("div",{className:"absolute right-1 top-1 z-10",children:o.jsx(p,{variant:"destructive",size:"icon",className:"h-6 w-6 rounded-full opacity-0 transition-opacity group-hover:opacity-100",onClick:r=>I(e,r),children:o.jsx(te,{className:"h-4 w-4"})})}),o.jsx("img",{src:`/storage/images/${t.image}`,alt:`Documentation ${e+1}`,className:"h-24 w-full rounded object-cover"}),o.jsx("p",{className:"mt-1 truncate text-xs",children:t.name})]},e),M=()=>o.jsxs(v,{title:"Research Documentation",children:[c.existingDocumentation.length>0&&o.jsx(a,{label:"Current Documentation",children:o.jsx("div",{className:"grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-4",children:c.existingDocumentation.map(K)})}),o.jsx(a,{label:"Upload New Documentation",children:o.jsx(l,{type:"file",name:"documentation",onChange:d,accept:"image/*",multiple:!0})})]});return o.jsxs(ee,{header:"Edit Research",children:[o.jsx(O,{title:"Edit Research"}),o.jsx(G,{className:"p-6",children:o.jsxs("form",{onSubmit:k,encType:"multipart/form-data",className:"space-y-6",children:[U(),V(),M(),o.jsx(p,{type:"submit",className:"w-full",disabled:g,children:g?"Saving...":"Save Research"})]})})]})};export{je 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.