PageSourceSearch

https://menpan.go.id/assets/AddFile-BWoAD9S0.js

js menpan.go.id collected 2026-10-01 12:17:05 UTC 6,047 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-mui-pzAHH9Px.js";import{a as l,h as B,L as E}from"./vendor-react-khHHqPIU.js";import{a3 as U,W as $,g as S,X as k}from"./index-BKlU2-ad.js";import{F as G}from"./FileMediaPickerDialog-Bc9FSbCT.js";import{B as c}from"./button-B__KXJKn.js";import{I as K}from"./input-Cb9axp0j.js";import{L as o}from"./label-D7RLqSGc.js";import{T as z}from"./textarea-CCr3lUdq.js";import{S as _,a as F,b as w,c as C,d as j}from"./select-BpN5RP8C.js";import{A as V}from"./arrow-left-V0gK9KL5.js";import{F as I}from"./file-_v1dgG1B.js";import{S as q}from"./save-D7xFBIg_.js";import"./dialog-D2gF9MQO.js";import"./index-Cr7U6S9d.js";import"./index-DvVtr4Gm.js";import"./tabs-VYX1X8Gh.js";import"./index-CEyMD-YA.js";import"./grid-3x3-Bvz94Oyx.js";import"./list-ClJT7LV-.js";import"./check-D2IyaXV3.js";import"./copy-3S_eot4d.js";import"./trash-2-KzCV3G7N.js";import"./upload-sZD4YXGI.js";import"./index-DM9HOgI6.js";import"./index-D2shsKci.js";import"./chevron-up-C5jj7mp5.js";const ve=()=>{const{showNotification:d}=U(),[s,m]=l.useState({file_category_id:"",title:"",status:"1",keterangan:""}),[t,v]=l.useState(null),[A,x]=l.useState(!1),[D,L]=l.useState([]),[p,h]=l.useState(!1),[u,P]=l.useState(null),f=B(),y=localStorage.getItem("token");y||f($),l.useEffect(()=>{const a=localStorage.getItem("user");try{a&&a!=="undefined"&&P(JSON.parse(a))}catch(r){console.error("Gagal parse data user:",r),localStorage.removeItem("user")}M()},[]);const M=async()=>{try{const r=await S.get("https://menpan.go.id/api/files/categories");L(r.data)}catch(a){console.error("Error:",a),d("Gagal memuat kategori file","error")}},N=a=>{m({...s,[a.target.name]:a.target.value})},O=a=>{v(a),x(!1)},T=async a=>{var n,i;if(a.preventDefault(),h(!0),!t){d("Silakan pilih file dari media","error"),h(!1);return}const r={file_category_id:s.file_category_id,user_id:(u==null?void 0:u.id)||"1",title:s.title,status:s.status,keterangan:s.keterangan,file_media_id:t.id,file:t.filepath};try{(await S.post("https://menpan.go.id/api/files",r,{headers:{"Content-Type":"application/json",Authorization:`Bearer ${y}`}})).data.success&&(d("File berhasil ditambahkan","success"),f("/admin/files"))}catch(g){console.error("Error:",g),d(((i=(n=g.response)==null?void 0:n.data)==null?void 0:i.message)||"Gagal menambahkan file","error")}finally{h(!1)}};function b(a,r=null,n=0){return a.filter(i=>i.parentId===r).flatMap(i=>[{id:i.id,name:`${"--".repeat(n)} ${i.name}`},...b(a,i.id,n+1)])}return p?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-500"})}):e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-card rounded-xl shadow-sm overflow-visible",children:[e.jsx("div",{className:"p-6 border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(E,{to:"/admin/files",className:"inline-flex items-center text-gray-600 hover:text-gray-900",children:e.jsx(V,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-800",children:"Upload File Baru"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Isi semua field di bawah ini untuk mengupload file baru."})]})]})}),e.jsxs("form",{onSubmit:T,className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs(o,{htmlFor:"title",children:["Nama File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(K,{id:"title",type:"text",name:"title",value:s.title,onChange:N,placeholder:"Masukkan nama file",required:!0})]}),e.jsxs("div",{children:[e.jsxs(o,{children:["File PDF ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(c,{type:"button",variant:"outline",onClick:()=>x(!0),className:"w-full justify-start",children:[e.jsx(I,{className:"mr-2 h-4 w-4 text-gray-400"}),t?t.original_filename:"Pilih file dari media"]}),t&&e.jsx("div",{className:"mt-2 p-3 bg-muted/50 rounded-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"text-red-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-gray-900",children:t.original_filename}),e.jsxs("p",{className:"text-xs text-gray-500",children:[(t.file_size/(1024*1024)).toFixed(2)," ","MB"]})]})]}),e.jsx(c,{type:"button",variant:"ghost",size:"sm",onClick:()=>v(null),className:"text-red-500 hover:text-red-700",children:e.jsx(k,{className:"h-4 w-4"})})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs(o,{htmlFor:"file_category_id",children:["Kategori File ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(_,{name:"file_category_id",value:s.file_category_id,onValueChange:a=>m({...s,file_category_id:a}),required:!0,children:[e.jsx(F,{id:"file_category_id",children:e.jsx(w,{placeholder:"-- Pilih Kategori --"})}),e.jsx(C,{children:b(D).map(a=>e.jsx(j,{value:a.id.toString(),children:a.name},a.id))})]})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"status",children:"Status"}),e.jsxs(_,{name:"status",value:s.status,onValueChange:a=>m({...s,status:a}),children:[e.jsx(F,{id:"status",children:e.jsx(w,{})}),e.jsxs(C,{children:[e.jsx(j,{value:"1",children:"Aktif"}),e.jsx(j,{value:"0",children:"Tidak Aktif"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"keterangan",children:"Keterangan"}),e.jsx(z,{id:"keterangan",name:"keterangan",value:s.keterangan,onChange:N,placeholder:"Keterangan file (opsional)",rows:3})]})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-4 pt-6 border-t border-gray-200",children:[e.jsxs(c,{type:"button",variant:"outline",onClick:()=>f("/admin/files"),children:[e.jsx(k,{className:"mr-2 h-4 w-4"}),"Cancel"]}),e.jsxs(c,{type:"submit",disabled:p||!t,children:[e.jsx(q,{className:"mr-2 h-4 w-4"}),p?"Menyimpan...":"Simpan File"]})]})]})]}),e.jsx(G,{open:A,onOpenChange:x,onSelect:O})]})};export{ve 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.