(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[248],{5526:function(e,s,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/Manager/Files",function(){return r(9469)}])},9413:function(e,s,r){"use strict";var l=r(5893),i=r(1664),n=r.n(i),t=r(1163);let d=e=>{let{title:s,children:r,create:i}=e,d=(0,t.useRouter)();return(0,l.jsxs)("div",{className:"m-5 shadow rounded-3xl hover:shadow-2xl",children:[(0,l.jsxs)("div",{className:"border-b border-gray-200 py-3 px-4 flex justify-between",children:[(0,l.jsx)("h1",{className:"font-bold text-gray-900",children:s}),i&&(0,l.jsx)(n(),{href:d.route+"/Create",passHref:!0,legacyBehavior:!0,children:(0,l.jsx)("a",{className:"hover:text-green-600",children:(0,l.jsx)("span",{children:"افزودن"})})})]}),(0,l.jsx)("div",{className:"p-4 lg:h-[80vh] overflow-y-auto",children:r})]})};s.Z=d},9469:function(e,s,r){"use strict";r.r(s),r.d(s,{__N_SSP:function(){return w},default:function(){return g}});var l=r(5893),i=r(4184),n=r(9413),t=r(5675),d=r.n(t),a=r(1872),c=r(1664),o=r.n(c),h=r(1163),x=r.n(h),u=r(7294),j=r(2920),p=r(8523),f=r(9552),m=r.n(f);let v=e=>{let{upload_path:s}=e,[r,i]=(0,u.useState)([]),[n,t]=(0,u.useState)(!1),d=(0,u.useCallback)(e=>{t(!0),i(e.map(e=>Object.assign(e,{preview:URL.createObjectURL(e)})));let r=new FormData;for(let l of e)r.append("files",l);let n=m().get("token");fetch(s,{body:r,method:"POST",headers:{Authorization:"bearer "+n}}).then(async e=>{201===e.status?(await e.json(),j.Am.success("با موفقیت افزوده شد."),x().reload(window.location.pathname)):j.Am.error("خطا!")})},[]),{acceptedFiles:a,fileRejections:c,getRootProps:o,getInputProps:h,isDragActive:f}=(0,p.uI)({onDrop:d}),v=a.map(e=>(0,l.jsx)("div",{className:"w-2/12",children:(0,l.jsx)("div",{className:"p-1",children:(0,l.jsx)("img",{alt:e.name,src:e.preview,onLoad:()=>{URL.revokeObjectURL(e.preview)}})})},e.name)),y=c.map(e=>{let{file:s,errors:r}=e;return(0,l.jsx)("li",{children:(0,l.jsx)("ul",{children:r.map(e=>(0,l.jsx)("li",{children:e.message},e.code))})},s.name)});return(0,l.jsxs)("div",{children:[n?(0,l.jsx)("div",{className:"text-center bg-yellow-200 border border-yellow-600 rounded-xl py-2 my-3",children:(0,l.jsx)("p",{children:"در حال آپلود فایل ها..."})}):null,(0,l.jsxs)("div",{...o(),className:"flex w-full justify-center items-center cursor-pointer hover:bg-white border border-dashed border-second rounded-xl h-[300px] overflow-hidden",children:[(0,l.jsx)("input",{...h()}),f?(0,l.jsx)("p",{children:"فایل ها رها کنید"}):(0,l.jsx)("p",{children:"فایل ها را داخل اینجا رها کنید"})]}),(0,l.jsx)("div",{className:"flex flex-row flex-wrap mt-4",children:v}),(0,l.jsx)("div",{className:"flex flex-row flex-wrap mt-4",children:(0,l.jsx)("ul",{children:y})})]})},y=e=>{let{status:s,data:r}=e,{query:t}=(0,h.useRouter)();return(0,l.jsx)(i.Z,{title:"فایل ها",children:(0,l.jsxs)(n.Z,{title:"لیست فایل ها",children:[(0,l.jsx)("div",{children:(0,l.jsx)(v,{upload_path:"/api/file/upload"})}),(0,l.jsxs)("div",{className:"grid gap-10 mb-5 "+(t.type?"grid-cols-4":"grid-cols-3"),children:[(0,l.jsx)(o(),{href:{query:{type:"image"}},children:(0,l.jsxs)("div",{className:"rounded-xl bg-yellow-300 py-3 flex justify-center items-center hover:scale-105",children:[(0,l.jsx)(a.Z30,{size:40}),(0,l.jsx)("span",{children:"تصاویر"})]})}),(0,l.jsx)(o(),{href:{query:{type:"video"}},children:(0,l.jsxs)("div",{className:"rounded-xl bg-pink-300 py-3 flex justify-center items-center hover:scale-105",children:[(0,l.jsx)(a._pN,{size:40}),(0,l.jsx)("span",{children:"ویدئوها"})]})}),(0,l.jsx)(o(),{href:{query:{type:"document"}},children:(0,l.jsxs)("div",{className:"rounded-xl bg-blue-300 py-3 flex justify-center items-center hover:scale-105",children:[(0,l.jsx)(a.NFo,{size:40}),(0,l.jsx)("span",{children:"دیگر"})]})}),t.type&&(0,l.jsx)(o(),{href:{query:null},children:(0,l.jsxs)("div",{className:"rounded-xl bg-gray-300 py-3 flex justify-center items-center hover:scale-105",children:[(0,l.jsx)("span",{children:"بازگشت"}),(0,l.jsx)(a.Nek,{size:40})]})})]}),(0,l.jsx)("div",{className:"grid grid-cols-6 gap-2",children:r.map((e,s)=>{let r="http://localhost:8000/files/"+e.path;return(0,l.jsx)(o(),{href:"/Files/Edit/"+e.id,children:"image"===e.type?(0,l.jsx)(d(),{loader:()=>r,src:r,alt:e.alt,width:300,height:300,priority:!0},e.id):"video"===e.type?(0,l.jsx)("video",{width:300,height:"auto",controls:!0,children:(0,l.jsx)("source",{src:r+"?dl=0"})},e.id):(0,l.jsx)("div",{children:"file"},e.id)},s)})})]})})};var w=!0,g=y}},function(e){e.O(0,[4617,1057,3874,994,699,8523,4184,9774,2888,179],function(){return e(e.s=5526)}),_N_E=e.O()}]);