Spaces:
Running
Running
import{r as d,j as a,N as B,H as we,O as h,z as f,n as t,I as S}from"./index-C_hAuRbb.js";import{u as Fe}from"./useAdmin-B_kWg5HW.js";const ke="_adminContainer_j11pf_5",Te="_adminHeader_j11pf_13",Ae="_adminSection_j11pf_20",Ie="_modelSelectionArea_j11pf_29",Pe="_modelSelectionRow_j11pf_36",$e="_modelsTable_j11pf_89",Le="_promptSubsection_j11pf_97",Ee="_promptSubsectionTitle_j11pf_109",Be="_modelCode_j11pf_152",Oe="_modelId_j11pf_157",Re="_modelActions_j11pf_163",De="_addModelButtonContainer_j11pf_169",Ue="_addModelForm_j11pf_177",ze="_addModelFormTitle_j11pf_185",He="_addModelFormGrid_j11pf_193",Ge="_addModelFormField_j11pf_206",Ve="_addModelFormCheckbox_j11pf_250",Je="_addModelFormActions_j11pf_268",Ke="_modalOverlay_j11pf_277",We="_modalContent_j11pf_291",qe="_modalBody_j11pf_302",Ye="_modalTitle_j11pf_312",Qe="_modalText_j11pf_320",Xe="_modalTextLeft_j11pf_332",Ze="_modalButtons_j11pf_355",ea="_modalForm_j11pf_363",aa="_formField_j11pf_372",la="_formLabel_j11pf_376",sa="_formInput_j11pf_385",oa="_textarea_j11pf_407",l={adminContainer:ke,adminHeader:Te,adminSection:Ae,modelSelectionArea:Ie,modelSelectionRow:Pe,modelsTable:$e,promptSubsection:Le,promptSubsectionTitle:Ee,modelCode:Be,modelId:Oe,modelActions:Re,addModelButtonContainer:De,addModelForm:Ue,addModelFormTitle:ze,addModelFormGrid:He,addModelFormField:Ge,addModelFormCheckbox:Ve,addModelFormActions:Je,modalOverlay:Ke,modalContent:We,modalBody:qe,modalTitle:Ye,modalText:Qe,modalTextLeft:Xe,modalButtons:Ze,modalForm:ea,formField:aa,formLabel:la,formInput:sa,textarea:oa},w="selectedVlmModel";function ia(){const{isAuthenticated:F,isLoading:X,login:Z,logout:ee}=Fe(),[k,O]=d.useState(""),[R,u]=d.useState(""),[D,U]=d.useState(!1),[z,H]=d.useState([]),[ae,b]=d.useState(""),[G,le]=d.useState([]),[se,oe]=d.useState([]),[te,y]=d.useState(!1),[de,N]=d.useState(!1),[ie,T]=d.useState(null),[C,A]=d.useState(null),[n,r]=d.useState({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1}),[V,I]=d.useState(!1),[ne,P]=d.useState(!1),[$,L]=d.useState(null),[o,c]=d.useState({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),[re,M]=d.useState(!1),[ce,E]=d.useState(!1),[me,p]=d.useState(!1),[J,K]=d.useState(""),[he,pe]=d.useState(""),[_e,_]=d.useState(""),[ue,j]=d.useState(""),x=d.useCallback(()=>{fetch("/api/models").then(e=>e.json()).then(e=>{console.log("Models data received:",e),H(e.models||[]);const s=localStorage.getItem(w);if(e.models&&e.models.length>0)if(s==="random")b("random");else if(s&&e.models.find(i=>i.m_code===s&&i.is_available))b(s);else{const i=e.models.find(m=>m.is_available)||e.models[0];b(i.m_code),localStorage.setItem(w,i.m_code)}}).catch(()=>{})},[]),v=d.useCallback(()=>{console.log("=== fetchPrompts called ==="),fetch("/api/prompts").then(e=>e.json()).then(e=>{console.log("Prompts data received:",e),le(e||[]),console.log("State update triggered with:",e||[])}).catch(e=>{console.error("Error fetching prompts:",e)})},[]),W=d.useCallback(()=>{fetch("/api/image-types").then(e=>e.json()).then(e=>{console.log("Image types data received:",e),oe(e||[])}).catch(()=>{})},[]);d.useEffect(()=>{F&&(x(),v(),W())},[F,x,v,W]);const q=e=>{A(e),r({p_code:e.p_code,label:e.label||"",metadata_instructions:e.metadata_instructions||"",image_type:e.image_type||"crisis_map",is_active:e.is_active||!1}),y(!0)},je=async()=>{try{if(!C){alert("No prompt selected for editing");return}const e=await fetch(`/api/prompts/${C.p_code}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({label:n.label,metadata_instructions:n.metadata_instructions,image_type:n.image_type,is_active:n.is_active})});if(e.ok)v(),y(!1),A(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to update prompt: ${s.error||"Unknown error"}`)}}catch{alert("Error updating prompt")}},Y=async(e,s)=>{try{const i=await fetch(`/api/prompts/${e}/toggle-active?image_type=${s}`,{method:"POST",headers:{"Content-Type":"application/json"}});if(i.ok)v();else{const m=await i.json();alert(`Failed to toggle prompt active status: ${m.detail||"Unknown error"}`)}}catch{alert("Error toggling prompt active status")}},Q=e=>{T(e),r({p_code:"",label:"",metadata_instructions:"",image_type:e,is_active:!1}),N(!0)},xe=async()=>{try{const e=await fetch("/api/prompts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(e.ok)v(),N(!1),T(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1});else{const s=await e.json();alert(`Failed to create prompt: ${s.detail||"Unknown error"}`)}}catch{alert("Error creating prompt")}},ve=async(e,s)=>{try{const i=await fetch(`/api/models/${e}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_available:!s})});if(i.ok)H(m=>m.map(g=>g.m_code===e?{...g,is_available:!s}:g));else{const m=await i.json();alert(`Failed to toggle model availability: ${m.error||"Unknown error"}`)}}catch{alert("Error toggling model availability")}},ge=e=>{b(e),e==="random"?localStorage.setItem(w,"random"):localStorage.setItem(w,e)},fe=async()=>{try{const e=await fetch("/api/admin/models",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(o)});if(e.ok){const s=` | |
Model "${o.label}" added successfully! | |
β οΈ IMPORTANT: Model will NOT work until you complete these steps: | |
1. π Ensure API key is set and valid. | |
2. π Verify model_id format. | |
3. π Check model specific documentation for details. | |
`;pe(s),E(!0),I(!1),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),x()}else{const s=await e.json();alert(`Failed to add model: ${s.detail||"Unknown error"}`)}}catch{alert("Error adding model")}},be=e=>{L(e),c({m_code:e.m_code,label:e.label,model_type:e.model_type||"custom",provider:e.provider||e.config?.provider||"huggingface",model_id:e.model_id||e.config?.model_id||e.m_code,is_available:e.is_available}),P(!0)},ye=async()=>{try{console.log("Updating model with data:",o);const e={label:o.label,model_type:o.model_type,provider:o.provider,model_id:o.model_id,is_available:o.is_available};if(console.log("Update payload:",e),!$){alert("No model selected for editing");return}const s=await fetch(`/api/admin/models/${$.m_code}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("adminToken")}`},body:JSON.stringify(e)});if(console.log("Update response status:",s.status),s.ok){const i=await s.json();console.log("Update successful:",i),P(!1),L(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1}),console.log("Refreshing models..."),x()}else{const i=await s.json();console.error("Update failed:",i),alert(`Failed to update model: ${i.detail||"Unknown error"}`)}}catch(e){console.error("Update error:",e),alert("Error updating model")}},Ne=async e=>{K(e),M(!0)},Ce=async()=>{try{const e=await fetch(`/api/admin/models/${J}`,{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}});if(e.ok)M(!1),K(""),x();else{const s=await e.json();alert(`Failed to delete model: ${s.detail||"Unknown error"}`)}}catch{alert("Error deleting model")}},Me=async e=>{if(e.preventDefault(),!k.trim()){u("Please enter a password");return}U(!0),u("");try{await Z(k)||u("Invalid password")}catch{u("Login failed. Please try again.")}finally{U(!1)}},Se=()=>{ee(),O(""),u("")};return X?a.jsx(B,{children:a.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-ifrcRed mx-auto mb-4"}),a.jsx("p",{className:"text-gray-600",children:"Loading..."})]})})}):F?a.jsxs(B,{children:[a.jsxs("div",{className:l.adminContainer,children:[a.jsx("div",{className:l.adminHeader,children:a.jsx(t,{name:"logout",variant:"secondary",onClick:Se,children:"Logout"})}),a.jsxs("div",{className:l.adminSection,children:[a.jsx(f,{heading:"VLM Model Selection",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelSelectionArea,children:[a.jsx("p",{className:"text-gray-700",children:"Select which Vision Language Model to use for caption generation."}),a.jsx("div",{className:l.modelSelectionRow,children:a.jsx(S,{label:"Model",name:"selected-model",value:ae,onChange:e=>ge(e||""),options:[{value:"random",label:"Random"},...z.filter(e=>e.is_available).map(e=>({value:e.m_code,label:e.label}))],keySelector:e=>e.value,labelSelector:e=>e.label})})]})}),a.jsx(f,{heading:"Model Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Provider"}),a.jsx("th",{children:"Model ID"}),a.jsx("th",{children:"Available"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:z.map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.m_code}),a.jsx("td",{children:e.label}),a.jsx("td",{children:e.provider||e.config?.provider||"huggingface"}),a.jsx("td",{className:l.modelId,children:e.model_id||e.config?.model_id||e.m_code||"N/A"}),a.jsx("td",{children:a.jsx(t,{name:`toggle-${e.m_code}`,variant:e.is_available?"primary":"secondary",size:1,onClick:()=>ve(e.m_code,e.is_available),children:e.is_available?"Enabled":"Disabled"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(t,{name:`edit-${e.m_code}`,variant:"secondary",size:1,onClick:()=>be(e),children:"Edit"}),a.jsx(t,{name:`delete-${e.m_code}`,variant:"secondary",size:1,onClick:()=>Ne(e.m_code),children:"Delete"})]})})]},e.m_code))})]})}),!V&&a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"show-add-form",variant:"primary",onClick:()=>I(!0),children:"Add New Model"})}),V&&a.jsxs("div",{className:l.addModelForm,children:[a.jsx("h4",{className:l.addModelFormTitle,children:"Add New Model"}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(S,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(t,{name:"save-model",variant:"primary",onClick:fe,disabled:!o.m_code||!o.label||!o.model_id,children:"Save Model"}),a.jsx(t,{name:"cancel-add",variant:"secondary",onClick:()=>I(!1),children:"Cancel"})]})]}),ne&&a.jsxs("div",{className:l.addModelForm,children:[a.jsxs("h4",{className:l.addModelFormTitle,children:["Edit Model: ",$?.label]}),a.jsxs("div",{className:l.addModelFormGrid,children:[a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Model Code",name:"model-code",value:o.m_code,onChange:e=>c({...o,m_code:e||""}),placeholder:"e.g., NEW_MODEL_123",disabled:!0})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Label",name:"model-label",value:o.label,onChange:e=>c({...o,label:e||""}),placeholder:"e.g., New Model Name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(S,{label:"Provider",name:"model-provider",value:o.provider,onChange:e=>c({...o,provider:e||"huggingface"}),options:[{value:"huggingface",label:"HuggingFace"},{value:"openai",label:"OpenAI"},{value:"google",label:"Google"}],keySelector:e=>e.value,labelSelector:e=>e.label})}),a.jsx("div",{className:l.addModelFormField,children:a.jsx(h,{label:"Model ID",name:"model-id",value:o.model_id,onChange:e=>c({...o,model_id:e||""}),placeholder:"e.g., org/model-name"})}),a.jsx("div",{className:l.addModelFormField,children:a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:o.is_available,onChange:e=>c({...o,is_available:e.target.checked})}),a.jsx("span",{children:"Available for use"})]})})]}),a.jsxs("div",{className:l.addModelFormActions,children:[a.jsx(t,{name:"update-model",variant:"primary",onClick:ye,disabled:!o.m_code||!o.label||!o.model_id,children:"Update Model"}),a.jsx(t,{name:"cancel-edit",variant:"secondary",onClick:()=>{P(!1),L(null),c({m_code:"",label:"",model_type:"custom",provider:"huggingface",model_id:"",is_available:!1})},children:"Cancel"})]})]})]})}),a.jsx(f,{heading:"Prompt Management",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:l.modelManagementArea,children:[a.jsxs("div",{className:l.promptSubsection,children:[a.jsx("h4",{className:l.promptSubsectionTitle,children:"Crisis Maps"}),a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Status"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:G.filter(e=>e.image_type==="crisis_map").sort((e,s)=>e.p_code.localeCompare(s.p_code)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.p_code}),a.jsx("td",{className:l.promptLabel,children:e.label||"No label"}),a.jsx("td",{children:a.jsx(t,{name:`toggle-crisis-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>Y(e.p_code,"crisis_map"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(t,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{_(`=== Prompt Details === | |
Code: ${e.p_code} | |
Label: ${e.label} | |
Image Type: ${e.image_type} | |
Active: ${e.is_active} | |
Metadata Instructions: | |
${e.metadata_instructions||"No instructions available"}`),j(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(t,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>q(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"add-crisis-prompt",variant:"primary",onClick:()=>Q("crisis_map"),children:"Add New Crisis Map Prompt"})})]}),a.jsxs("div",{className:l.promptSubsection,children:[a.jsx("h4",{className:l.promptSubsectionTitle,children:"Drone Images"}),a.jsx("div",{className:l.modelsTable,children:a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Code"}),a.jsx("th",{children:"Label"}),a.jsx("th",{children:"Status"}),a.jsx("th",{children:"Actions"})]})}),a.jsx("tbody",{children:G.filter(e=>e.image_type==="drone_image").sort((e,s)=>e.p_code.localeCompare(s.p_code)).map(e=>a.jsxs("tr",{children:[a.jsx("td",{className:l.modelCode,children:e.p_code}),a.jsx("td",{className:l.promptLabel,children:e.label||"No label"}),a.jsx("td",{children:a.jsx(t,{name:`toggle-drone-${e.p_code}`,variant:e.is_active?"primary":"secondary",size:1,onClick:()=>Y(e.p_code,"drone_image"),children:e.is_active?"Active":"Inactive"})}),a.jsx("td",{children:a.jsxs("div",{className:l.modelActions,children:[a.jsx(t,{name:`view-${e.p_code}`,variant:"secondary",size:1,onClick:()=>{_(`=== Prompt Details === | |
Code: ${e.p_code} | |
Label: ${e.label} | |
Image Type: ${e.image_type} | |
Active: ${e.is_active} | |
Metadata Instructions: | |
${e.metadata_instructions||"No instructions available"}`),j(`Prompt: ${e.p_code}`),p(!0)},children:"View"}),a.jsx(t,{name:`edit-${e.p_code}`,variant:"secondary",size:1,onClick:()=>q(e),children:"Edit"})]})})]},e.p_code))})]})}),a.jsx("div",{className:l.addModelButtonContainer,children:a.jsx(t,{name:"add-drone-prompt",variant:"primary",onClick:()=>Q("drone_image"),children:"Add New Drone Image Prompt"})})]})]})}),a.jsx(f,{heading:"Utilities",headingLevel:2,withHeaderBorder:!0,withInternalPadding:!0,children:a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsx(t,{name:"test-connection",variant:"secondary",onClick:async()=>{_("Testing API connection..."),j("Connection Test Results");try{const e=await fetch("/api/models");if(e.ok){const s=await e.json(),i=`β API connection successful! | |
Found ${s.models?.length||0} models in database. | |
Available models: | |
${s.models?.filter(m=>m.is_available).map(m=>`- ${m.label} (${m.m_code})`).join(` | |
`)||"None"}`;_(i)}else{const s=`β API connection failed: HTTP ${e.status}`;_(s)}p(!0)}catch(e){const s=`β Connection error: ${e}`;_(s),p(!0)}},children:"Test Connection"}),a.jsx(t,{name:"view-schemas",variant:"secondary",onClick:()=>{fetch("/api/schemas",{headers:{Authorization:`Bearer ${localStorage.getItem("adminToken")}`}}).then(e=>e.json()).then(e=>{console.log("Schemas Response:",e);let s="",i="Schemas Response";e&&Array.isArray(e)?(s=`Found ${e.length} schemas: | |
`,e.forEach((m,g)=>{s+=`=== Schema ${g+1} === | |
`,s+=JSON.stringify(m,null,2),s+=` | |
`})):e&&typeof e=="object"?s=`Prompts Response: | |
Response type: ${typeof e} | |
Keys: ${Object.keys(e).join(", ")} | |
Raw data: | |
${JSON.stringify(e,null,2)}`:s=`Prompts Response: | |
Unexpected data type: ${typeof e} | |
Value: ${e}`,_(s),j(i),p(!0)}).catch(e=>{console.error("Schemas Error:",e);const s=`Failed to fetch prompts: ${e.message||"Unknown error"}`;_(s),j("Schemas Error"),p(!0)})},children:"View Schemas"})]})})]})]}),re&&a.jsx("div",{className:l.modalOverlay,onClick:()=>M(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Delete Model"}),a.jsxs("p",{className:l.modalText,children:["Are you sure you want to delete model ",a.jsx("span",{className:l.modelCode,children:J}),"? This action cannot be undone."]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(t,{name:"cancel-delete",variant:"tertiary",onClick:()=>M(!1),children:"Cancel"}),a.jsx(t,{name:"confirm-delete",variant:"secondary",onClick:Ce,children:"Delete"})]})]})})}),ce&&a.jsx("div",{className:l.modalOverlay,onClick:()=>E(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:"Model Added Successfully!"}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:he}),a.jsx("div",{className:l.modalButtons,children:a.jsx(t,{name:"close-setup-instructions",variant:"secondary",onClick:()=>E(!1),children:"Got it!"})})]})})}),me&&a.jsx("div",{className:l.modalOverlay,onClick:()=>p(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsx("h3",{className:l.modalTitle,children:ue}),a.jsx("div",{className:`${l.modalText} ${l.modalTextLeft}`,children:a.jsx("div",{className:"whitespace-pre-wrap font-mono text-sm leading-relaxed",children:_e})}),a.jsx("div",{className:l.modalButtons,children:a.jsx(t,{name:"close-test-results",variant:"secondary",onClick:()=>p(!1),children:"Close"})})]})})}),te&&a.jsx("div",{className:l.modalOverlay,onClick:()=>y(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Edit Prompt: ",C?.p_code]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(h,{name:"prompt-code",value:C?.p_code,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(h,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(S,{name:"prompt-image-type",value:n.image_type,onChange:e=>r(s=>({...s,image_type:e||"crisis_map"})),options:se,keySelector:e=>e.image_type,labelSelector:e=>e.label})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(t,{name:"cancel-edit-prompt",variant:"tertiary",onClick:()=>{y(!1),A(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(t,{name:"save-prompt",variant:"primary",onClick:je,children:"Save Changes"})]})]})})}),de&&a.jsx("div",{className:l.modalOverlay,onClick:()=>N(!1),children:a.jsx("div",{className:l.modalContent,onClick:e=>e.stopPropagation(),children:a.jsxs("div",{className:l.modalBody,children:[a.jsxs("h3",{className:l.modalTitle,children:["Add New ",ie==="crisis_map"?"Crisis Map":"Drone Image"," Prompt"]}),a.jsxs("div",{className:l.modalForm,children:[a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Code:"}),a.jsx(h,{name:"prompt-code",value:n.p_code,onChange:e=>r(s=>({...s,p_code:e||""})),placeholder:"e.g., CUSTOM_CRISIS_MAP_001",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Label:"}),a.jsx(h,{name:"prompt-label",value:n.label,onChange:e=>r(s=>({...s,label:e||""})),placeholder:"Enter prompt description...",className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Image Type:"}),a.jsx(h,{name:"prompt-image-type",value:n.image_type,onChange:()=>{},disabled:!0,className:l.formInput})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Active Status:"}),a.jsxs("div",{className:l.addModelFormCheckbox,children:[a.jsx("input",{type:"checkbox",checked:n.is_active,onChange:e=>r(s=>({...s,is_active:e.target.checked}))}),a.jsx("span",{children:"Active for this image type"})]})]}),a.jsxs("div",{className:l.formField,children:[a.jsx("label",{className:l.formLabel,children:"Metadata Instructions:"}),a.jsx("textarea",{name:"prompt-instructions",value:n.metadata_instructions,onChange:e=>r(s=>({...s,metadata_instructions:e.target.value})),placeholder:"Enter metadata extraction instructions...",className:`${l.formInput} ${l.textarea}`,rows:8})]})]}),a.jsxs("div",{className:l.modalButtons,children:[a.jsx(t,{name:"cancel-add-prompt",variant:"tertiary",onClick:()=>{N(!1),T(null),r({p_code:"",label:"",metadata_instructions:"",image_type:"crisis_map",is_active:!1})},children:"Cancel"}),a.jsx(t,{name:"save-new-prompt",variant:"primary",onClick:xe,disabled:!n.p_code||!n.label,children:"Create Prompt"})]})]})})})]}):a.jsx(B,{children:a.jsxs("div",{className:"mx-auto max-w-md px-4 sm:px-6 lg:px-8 py-6 sm:py-10",children:[a.jsx("div",{className:"text-center mb-8",children:a.jsx(we,{level:2,children:"Admin Login"})}),a.jsxs("form",{onSubmit:Me,className:"space-y-6",children:[a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-2",children:"Password"}),a.jsx(h,{id:"password",name:"password",type:"password",value:k,onChange:e=>O(e||""),placeholder:"Enter admin password",required:!0,className:"w-full"})]}),R&&a.jsx("div",{className:"bg-ifrcRed/10 border border-ifrcRed/20 rounded-md p-3",children:a.jsx("p",{className:"text-sm text-ifrcRed font-medium",children:R})}),a.jsx("div",{className:"flex justify-center",children:a.jsx(f,{withInternalPadding:!0,className:"p-2",children:a.jsx(t,{name:"login",type:"submit",variant:"primary",size:2,disabled:D,children:D?"Logging in...":"Login"})})})]})]})})}export{ia as default}; | |