1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8563],{10255:(e,t,s)=>{"use strict";function a(e){let{moduleIds:t}=e;return null}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PreloadChunks",{enumerable:!0,get:function(){return a}}),s(95155),s(47650),s(85744),s(20589)},17828:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorageInstance",{enumerable:!0,get:function(){return a}});let a=(0,s(64054).createAsyncLocalStorage)()},32941:(e,t,s)=>{"use strict";s.d(t,{mc:()=>n,wn:()=>l,xA:()=>i,zY:()=>r});var a=s(95155);function r(e){let{title:t,subtitle:s,actions:r}=e;return(0,a.jsx)("div",{className:"mb-8",children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-4xl font-display tracking-tight text-white mb-2",children:t}),s&&(0,a.jsx)("p",{className:"text-text-muted text-lg max-w-3xl",children:s})]}),r&&(0,a.jsx)("div",{className:"flex items-center gap-3",children:r})]})})}function l(e){let{children:t,className:s=""}=e;return(0,a.jsx)("section",{className:"section-spacing ".concat(s),children:t})}function n(e){let{children:t,className:s=""}=e;return(0,a.jsx)("div",{className:"container-custom ".concat(s),children:t})}function i(e){let{children:t,cols:s=3,gap:r="md",className:l=""}=e;return(0,a.jsx)("div",{className:"grid ".concat({1:"grid-cols-1",2:"grid-cols-1 md:grid-cols-2",3:"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",4:"grid-cols-1 md:grid-cols-2 lg:grid-cols-4"}[s]," ").concat({sm:"gap-4",md:"gap-6",lg:"gap-8"}[r]," ").concat(l),children:t})}s(12115)},36645:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return r}});let a=s(88229)._(s(67357));function r(e,t){var s;let r={};"function"==typeof e&&(r.loader=e);let l={...r,...t};return(0,a.default)({...l,modules:null==(s=l.loadableGenerated)?void 0:s.modules})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},49903:(e,t,s)=>{"use strict";s.d(t,{$n:()=>n,z9:()=>i});var a=s(95155),r=s(6874),l=s.n(r);function n(e){let{variant:t="primary",size:s="md",isLoading:r=!1,children:l,className:n="",disabled:i,...o}=e;return(0,a.jsx)("button",{className:"".concat({primary:"btn-primary",secondary:"btn-secondary",ghost:"btn-ghost",danger:"btn bg-red-500 hover:bg-red-600 text-white"}[t]," ").concat({sm:"px-3 py-1.5 text-sm",md:"px-4 py-2",lg:"px-6 py-3 text-lg"}[s]," ").concat(n," ").concat(r?"opacity-75 cursor-wait":""),disabled:i||r,...o,children:r?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"spinner w-4 h-4"}),"Loading..."]}):l})}function i(e){let{variant:t="primary",size:s="md",children:r,className:n="",href:i="#",...o}=e;return(0,a.jsx)(l(),{href:i,className:"".concat({primary:"btn-primary",secondary:"btn-secondary",ghost:"btn-ghost"}[t]," ").concat({sm:"px-3 py-1.5 text-sm",md:"px-4 py-2",lg:"px-6 py-3 text-lg"}[s]," ").concat(n),...o,children:r})}s(12115)},51689:(e,t,s)=>{Promise.resolve().then(s.bind(s,98308))},62146:(e,t,s)=>{"use strict";function a(e){let{reason:t,children:s}=e;return s}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"BailoutToCSR",{enumerable:!0,get:function(){return a}}),s(45262)},64054:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var s in t)Object.defineProperty(e,s,{enumerable:!0,get:t[s]})}(t,{bindSnapshot:function(){return n},createAsyncLocalStorage:function(){return l},createSnapshot:function(){return i}});let s=Object.defineProperty(Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available"),"__NEXT_ERROR_CODE",{value:"E504",enumerable:!1,configurable:!0});class a{disable(){throw s}getStore(){}run(){throw s}exit(){throw s}enterWith(){throw s}static bind(e){return e}}let r="undefined"!=typeof globalThis&&globalThis.AsyncLocalStorage;function l(){return r?new r:new a}function n(e){return r?r.bind(e):a.bind(e)}function i(){return r?r.snapshot():function(e,...t){return e(...t)}}},66766:(e,t,s)=>{"use strict";s.d(t,{default:()=>r.a});var a=s(71469),r=s.n(a)},67357:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return o}});let a=s(95155),r=s(12115),l=s(62146);function n(e){return{default:e&&"default"in e?e.default:e}}s(10255);let i={loader:()=>Promise.resolve(n(()=>null)),loading:null,ssr:!0},o=function(e){let t={...i,...e},s=(0,r.lazy)(()=>t.loader().then(n)),o=t.loading;function c(e){let n=o?(0,a.jsx)(o,{isLoading:!0,pastDelay:!0,error:null}):null,i=!t.ssr||!!t.loading,c=i?r.Suspense:r.Fragment,d=t.ssr?(0,a.jsxs)(a.Fragment,{children:[null,(0,a.jsx)(s,{...e})]}):(0,a.jsx)(l.BailoutToCSR,{reason:"next/dynamic",children:(0,a.jsx)(s,{...e})});return(0,a.jsx)(c,{...i?{fallback:n}:{},children:d})}return c.displayName="LoadableComponent",c}},70627:(e,t,s)=>{"use strict";s.d(t,{A:()=>o});var a=s(95155),r=s(12115);let{useUploadThing:l,uploadFiles:n}=(0,s(38897).KB)();var i=s(87481);function o(e){var t,s;let{endpoint:n,onUploadComplete:o,className:c}=e,[d,u]=(0,r.useState)(!1),{startUpload:p,permittedFileInfo:h}=l(n,{onClientUploadComplete:e=>{u(!1),e&&e[0]&&(null==o||o(e[0].url,new File([],e[0].name)),(0,i.o)({title:"Success",description:"File uploaded successfully!",status:"success"}))},onUploadError:e=>{u(!1),(0,i.o)({title:"Error",description:"Upload failed: ".concat(e.message),status:"error"})},onUploadBegin:()=>{u(!0)}});return(0,a.jsxs)("div",{className:c,children:[(0,a.jsx)("div",{className:"flex items-center justify-center w-full",children:(0,a.jsxs)("label",{className:"flex flex-col items-center justify-center w-full h-64 border-2 border-dashed border-text-muted rounded-lg cursor-pointer bg-bg-light hover:bg-bg-light/50 transition-colors",children:[(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[(0,a.jsx)("svg",{className:"w-8 h-8 mb-4 text-text-muted","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 16",children:(0,a.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"})}),(0,a.jsxs)("p",{className:"mb-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Click to upload"})," or drag and drop"]}),(0,a.jsx)("p",{className:"text-xs text-text-muted",children:(null==h||null==(t=h.config.image)?void 0:t.maxFileSize)||(null==h||null==(s=h.config.video)?void 0:s.maxFileSize)||"Any file type"})]}),(0,a.jsx)("input",{type:"file",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];s&&p([s]).catch(e=>{(0,i.o)({title:"Error",description:"Upload failed. Please try again.",status:"error"})})},disabled:d})]})}),d&&(0,a.jsx)("p",{className:"text-text-muted mt-2 text-center",children:"Uploading..."})]})}},71469:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),!function(e,t){for(var s in t)Object.defineProperty(e,s,{enumerable:!0,get:t[s]})}(t,{default:function(){return o},getImageProps:function(){return i}});let a=s(88229),r=s(38883),l=s(33063),n=a._(s(51193));function i(e){let{props:t}=(0,r.getImgProps)(e,{defaultLoader:n.default,imgConf:{deviceSizes:[640,750,828,1080,1200,1920,2048,3840],imageSizes:[16,32,48,64,96,128,256,384],path:"/_next/image",loader:"default",dangerouslyAllowSVG:!1,unoptimized:!1}});for(let[e,s]of Object.entries(t))void 0===s&&delete t[e];return{props:t}}let o=l.Image},85744:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"workAsyncStorage",{enumerable:!0,get:function(){return a.workAsyncStorageInstance}});let a=s(17828)},87481:(e,t,s)=>{"use strict";s.d(t,{d:()=>d,o:()=>c});var a=s(12115);let r={ADD_TOAST:"ADD_TOAST",UPDATE_TOAST:"UPDATE_TOAST",DISMISS_TOAST:"DISMISS_TOAST",REMOVE_TOAST:"REMOVE_TOAST"},l=0,n=[],i={toasts:[]};function o(e){i=((e,t)=>{switch(t.type){case r.ADD_TOAST:return{...e,toasts:[t.toast,...e.toasts].slice(0,3)};case r.DISMISS_TOAST:{let{toastId:s}=t;return{...e,toasts:e.toasts.map(e=>e.id===s?{...e,status:"error"}:e)}}case r.REMOVE_TOAST:return{...e,toasts:e.toasts.filter(e=>e.id!==t.toastId)}}})(i,e),n.forEach(e=>{e(i)})}function c(e){var t;let{...s}=e,a=(l=(l+1)%Number.MAX_SAFE_INTEGER).toString();return o({type:r.ADD_TOAST,toast:{...s,id:a,status:null!=(t=s.status)?t:"info",title:s.title,description:s.description,action:s.action}}),{id:a,dismiss:()=>o({type:r.DISMISS_TOAST,toastId:a}),update:e=>o({type:r.UPDATE_TOAST,toast:{...e,id:a}})}}function d(){let[e,t]=a.useState(i);return a.useEffect(()=>(n.push(t),()=>{let e=n.indexOf(t);e>-1&&n.splice(e,1)}),[e]),{...e,toast:c,dismiss:e=>o({type:r.DISMISS_TOAST,toastId:e})}}},98308:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>f});var a=s(95155),r=s(12115),l=s(35695),n=s(12108),i=s(36645),o=s.n(i),c=s(66766),d=s(70627),u=s(87481),p=s(32941),h=s(49903);let m=o()(()=>Promise.all([s.e(8827),s.e(9581),s.e(7078)]).then(s.bind(s,77078)).then(e=>e.default),{loadableGenerated:{webpack:()=>[null]},ssr:!1});function f(){let{data:e,status:t}=(0,n.useSession)(),s=(0,l.useRouter)(),[i,o]=(0,r.useState)([]),[f,g]=(0,r.useState)(!0),[x,b]=(0,r.useState)(null),[j,y]=(0,r.useState)(!1),[v,w]=(0,r.useState)("");(0,r.useEffect)(()=>{"loading"!==t&&(e||s.push("/admin/login"))},[e,t,s]),(0,r.useEffect)(()=>{let t=async()=>{try{let e=await fetch("/api/blog");if(!e.ok)throw Error("Failed to fetch blog posts");let t=await e.json();o(t)}catch(e){console.error("Error fetching blog posts:",e)}finally{g(!1)}};e&&t()},[e]);let N=async e=>{if(confirm("Are you sure you want to delete this post?"))try{if(!(await fetch("/api/blog/".concat(e),{method:"DELETE"})).ok)throw Error("Failed to delete post");let t=async()=>{try{let e=await fetch("/api/blog");if(!e.ok)throw Error("Failed to fetch blog posts");let t=await e.json();o(t)}catch(e){console.error("Error fetching blog posts:",e)}};await t(),(0,u.o)({title:"Success",description:"Post deleted successfully",status:"success"})}catch(e){console.error("Error deleting post:",e),(0,u.o)({title:"Error",description:"Failed to delete post",status:"error"})}},S=async e=>{if(e.preventDefault(),x)try{let e;if(!(e=x.id?await fetch("/api/blog/".concat(x.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,tags:v.split(",").map(e=>e.trim()).filter(e=>e),readTime:Math.ceil(x.content.split(" ").length/200)})}):await fetch("/api/blog",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...x,tags:v.split(",").map(e=>e.trim()).filter(e=>e),readTime:Math.ceil(x.content.split(" ").length/200)})})).ok){let t=await e.json();throw Error(t.error||"Failed to save post")}let t=async()=>{try{let e=await fetch("/api/blog");if(!e.ok)throw Error("Failed to fetch blog posts");let t=await e.json();o(t)}catch(e){console.error("Error fetching blog posts:",e)}};await t(),y(!1),b(null),w(""),(0,u.o)({title:"Success",description:"Post saved successfully",status:"success"})}catch(e){console.error("Error saving post:",e),(0,u.o)({title:"Error",description:"Failed to save post",status:"error"})}},T=async e=>{try{let t=i.find(t=>t.id===e);if(!t)return;if(!(await fetch("/api/blog/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,published:!t.published})})).ok)throw Error("Failed to update post");let s=async()=>{try{let e=await fetch("/api/blog");if(!e.ok)throw Error("Failed to fetch blog posts");let t=await e.json();o(t)}catch(e){console.error("Error fetching blog posts:",e)}};await s(),(0,u.o)({title:"Success",description:"Post updated successfully",status:"success"})}catch(e){console.error("Error updating post:",e),(0,u.o)({title:"Error",description:"Failed to update post",status:"error"})}};return"loading"===t||f?(0,a.jsx)("div",{className:"flex items-center justify-center min-h-[40vh]",children:(0,a.jsx)("span",{className:"spinner w-8 h-8"})}):(0,a.jsxs)("div",{children:[(0,a.jsx)(p.zY,{title:"Manage Blog Posts",subtitle:"Write, edit, and publish articles.",actions:(0,a.jsx)(h.$n,{onClick:()=>{var t;b({id:"",title:"",slug:"",excerpt:"",content:"",featuredImage:"",author:(null==e||null==(t=e.user)?void 0:t.name)||"Admin",date:new Date().toISOString().split("T")[0],tags:[],readTime:0,published:!1}),w(""),y(!0)},children:"Create New Post"})}),(0,a.jsx)("div",{className:"space-y-4",children:0===i.length?(0,a.jsx)("div",{className:"text-center py-12 text-text-muted",children:"No blog posts yet. Create your first post!"}):i.sort((e,t)=>new Date(t.date).getTime()-new Date(e.date).getTime()).map(e=>{var t;return(0,a.jsx)("div",{className:"card",children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{className:"flex-grow",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold text-white",children:e.title}),(0,a.jsx)("p",{className:"text-text-muted text-sm mt-1",children:e.excerpt}),(0,a.jsxs)("div",{className:"flex items-center space-x-4 mt-2 text-sm text-text-muted",children:[(0,a.jsx)("span",{children:(null==(t=e.author)?void 0:t.name)||e.author}),(0,a.jsx)("span",{children:"•"}),(0,a.jsx)("span",{children:new Date(e.date).toLocaleDateString()}),(0,a.jsx)("span",{children:"•"}),(0,a.jsxs)("span",{children:[e.readTime," min read"]}),(0,a.jsx)("span",{children:"•"}),(0,a.jsx)("span",{className:e.published?"text-green-400":"text-yellow-400",children:e.published?"Published":"Draft"})]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:e.tags.map(e=>(0,a.jsx)("span",{className:"badge",children:e},e))})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,a.jsx)(h.$n,{variant:e.published?"secondary":"primary",onClick:()=>T(e.id),children:e.published?"Unpublish":"Publish"}),(0,a.jsx)(h.$n,{variant:"secondary",onClick:()=>{b(e),w(e.tags.join(", ")),y(!0)},children:"Edit"}),(0,a.jsx)(h.$n,{variant:"danger",onClick:()=>N(e.id),children:"Delete"})]})]})},e.id)})}),j&&x&&(0,a.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-6",onClick:e=>{e.target===e.currentTarget&&(y(!1),b(null),w(""))},children:(0,a.jsxs)("div",{className:"bg-bg-light rounded-lg p-6 max-w-4xl w-full max-h-[90vh] overflow-y-auto",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold mb-6",children:x.id?"Edit Post":"Create New Post"}),(0,a.jsxs)("form",{onSubmit:S,className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Title"}),(0,a.jsx)("input",{type:"text",value:x.title,onChange:e=>b({...x,title:e.target.value}),className:"input",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Excerpt"}),(0,a.jsx)("textarea",{value:x.excerpt,onChange:e=>b({...x,excerpt:e.target.value}),className:"input",rows:2,required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Featured Image"}),x.featuredImage&&(0,a.jsx)("div",{className:"relative w-full h-48 mb-2 rounded-lg overflow-hidden",children:(0,a.jsx)(c.default,{src:x.featuredImage,alt:"Featured image preview",fill:!0,className:"object-cover"})}),(0,a.jsx)(d.A,{endpoint:"imageUploader",onUploadComplete:e=>b({...x,featuredImage:e}),className:"mb-2"}),(0,a.jsx)("input",{type:"text",value:x.featuredImage,onChange:e=>b({...x,featuredImage:e.target.value}),className:"input",placeholder:"Or enter URL manually"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Author"}),(0,a.jsx)("input",{type:"text",value:x.author,onChange:e=>b({...x,author:e.target.value}),className:"input",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Date"}),(0,a.jsx)("input",{type:"date",value:x.date,onChange:e=>b({...x,date:e.target.value}),className:"input",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Tags (comma separated)"}),(0,a.jsx)("input",{type:"text",value:v,onChange:e=>w(e.target.value),className:"input",placeholder:"VFX, Animation, Tutorial"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Content (Markdown)"}),(0,a.jsx)("div",{className:"bg-bg-dark rounded","data-color-mode":"dark",children:(0,a.jsx)(m,{value:x.content,onChange:e=>b({...x,content:e||""}),height:400,preview:"edit"})})]}),(0,a.jsxs)("div",{className:"flex justify-end gap-3 pt-4",children:[(0,a.jsx)(h.$n,{type:"button",variant:"ghost",onClick:()=>{y(!1),b(null),w("")},children:"Cancel"}),(0,a.jsx)(h.$n,{type:"submit",children:"Save Post"})]})]})]})})]})}}},e=>{e.O(0,[6874,3063,6454,8897,8441,5964,7358],()=>e(e.s=51689)),_N_E=e.O()}]); |