PageSourceSearch

https://www.joshlevinespeaks.com/_assets/admin.blog-BEMD7FL7.js

js joshlevinespeaks.com collected 2026-10-04 03:27:17 UTC 8,867 bytes, 1 lines download raw bytes

1import{o as C,af as R,y as T,z as m,ag as V,S as g,b as K,ah as _,E as v,r as J,j as e,A as $}from"./vendor-BBwjgOsN.js";import{u as G}from"./useBlogPosts-ua4KxVI8.js";import{g as W,h as X,a as Y,B as j,S as Z,F as ee,b as d,c as u,d as h,I as y,e as S}from"./index-sZjJd1A1.js";import{B as se}from"./Badge-BZUtzJYu.js";import{T as f}from"./Textarea-Bqv_Sf-x.js";import{S as P,a as A,b as B,c as N,d as p}from"./Select-CzblE_Vi.js";import{D as ae,a as te,b as ne,c as le}from"./Dialog-DZ4_shcw.js";const E=C({id:V().optional(),title:m().min(1),slug:m().min(1),h1:m().nullable().optional(),metaTitle:m().nullable().optional(),metaDescription:m().nullable().optional(),category:T(X),body:m().nullable().optional(),excerpt:m().nullable().optional(),coverImage:m().nullable().optional(),status:T(W),publishDate:R().nullable().optional()}),ie=async(i,c)=>{const o=E.parse(i),t=await fetch("/_api/blog/save",{method:"POST",body:g.stringify(o),...c,headers:{"Content-Type":"application/json"}});if(!t.ok){const r=g.parse(await t.text());throw new Error(r.error)}return g.parse(await t.text())},oe=C({id:V()}),re=async(i,c)=>{const o=oe.parse(i),t=await fetch("/_api/blog/delete",{method:"POST",body:g.stringify(o),...c,headers:{"Content-Type":"application/json"}});if(!t.ok){const r=g.parse(await t.text());throw new Error(r.error)}return g.parse(await t.text())},ce=()=>{const i=K(),c=_({mutationFn:async t=>(await ie(t)).post,onSuccess:()=>{i.invalidateQueries({queryKey:["blogPosts"]}),i.invalidateQueries({queryKey:["blogPost"]}),v.success("Blog post saved successfully.")},onError:t=>{v.error(t instanceof Error?t.message:"Failed to save blog post")}}),o=_({mutationFn:async t=>(await re({id:t})).success,onSuccess:()=>{i.invalidateQueries({queryKey:["blogPosts"]}),i.invalidateQueries({queryKey:["blogPost"]}),v.success("Blog post deleted successfully.")},onError:t=>{v.error(t instanceof Error?t.message:"Failed to delete blog post")}});return{saveBlogPost:c.mutateAsync,isSaving:c.isPending,deleteBlogPost:o.mutateAsync,isDeleting:o.isPending}},de=C({image:m().min(1,"Image base64 string is required")}),ue=async(i,c)=>{const o=de.parse(i),t=await fetch("/_api/blog/upload-cover-image",{method:"POST",body:g.stringify(o),...c,headers:{"Content-Type":"application/json"}});if(!t.ok){const r=g.parse(await t.text());throw new Error(r.error)}return g.parse(await t.text())};function he(){return _({mutationFn:i=>ue(i)})}const me="_page_ojybb_2",ge="_header_ojybb_8",xe="_tableContainer_ojybb_21",je="_table_ojybb_21",pe="_titleCell_ojybb_46",ve="_actions_ojybb_51",be="_editorDialog_ojybb_56",ye="_form_ojybb_64",fe="_grid_ojybb_72",_e="_tallTextarea_ojybb_78",Ce="_formActions_ojybb_84",we="_coverImageContainer_ojybb_90",Ie="_coverImagePreview_ojybb_96",De="_coverImageUpload_ojybb_110",Te="_hiddenInput_ojybb_115",l={page:me,header:ge,tableContainer:xe,table:je,titleCell:pe,actions:ve,editorDialog:be,form:ye,grid:fe,tallTextarea:_e,formActions:Ce,coverImageContainer:we,coverImagePreview:Ie,coverImageUpload:De,hiddenInput:Te};function Fe(){const{data:i,isFetching:c}=G(void 0,!0),{saveBlogPost:o,deleteBlogPost:t,isSaving:r}=ce(),{mutateAsync:F,isPending:w}=he(),[I,b]=J.useState(!1),a=Y({defaultValues:{id:void 0,title:"",slug:"",h1:"",metaTitle:"",metaDescription:"",category:"appraisal",body:"",excerpt:"",coverImage:"",status:"draft"},schema:E}),U=()=>{a.setValues({id:void 0,title:"",slug:"",h1:"",metaTitle:"",metaDescription:"",category:"appraisal",body:"",excerpt:"",coverImage:"",status:"draft"}),b(!0)},k=s=>{a.setValues({...s}),b(!0)},O=async s=>{confirm("Are you sure you want to delete this post?")&&await t(s)},M=async s=>{const n=s.status==="draft"?"published":"draft",x={...s,status:n};!x.publishDate&&x.status==="published"&&(x.publishDate=new Date),await o(x)},q=async s=>{!s.publishDate&&s.status==="published"&&(s.publishDate=new Date),await o(s),b(!1)},z=s=>{const n=s.target.files?.[0];if(!n)return;const x=new FileReader;x.onload=async H=>{const L=H.target?.result;try{const{url:D}=await F({image:L});a.setValues(Q=>({...Q,coverImage:D}))}catch{v.error("Failed to upload cover image")}},x.readAsDataURL(n)};return e.jsxs("div",{className:l.page,children:[e.jsxs($,{children:[e.jsx("meta",{name:"robots",content:"noindex, nofollow"}),e.jsx("title",{children:"Admin | Josh Levine Speaks"})]}),e.jsxs("div",{className:l.header,children:[e.jsx("h1",{children:"Blog Management"}),e.jsx(j,{onClick:U,children:"New Post"})]}),e.jsx("div",{className:l.tableContainer,children:c?e.jsx(Z,{style:{height:"300px"}}):e.jsxs("table",{className:l.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Title"}),e.jsx("th",{children:"Category"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:i?.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:l.titleCell,children:s.title}),e.jsx("td",{children:s.category}),e.jsx("td",{children:e.jsx(se,{variant:s.status==="published"?"success":"secondary",children:s.status})}),e.jsx("td",{children:s.publishDate?new Date(s.publishDate).toLocaleDateString():"-"}),e.jsx("td",{children:e.jsxs("div",{className:l.actions,children:[e.jsx(j,{variant:s.status==="draft"?"primary":"outline",size:"sm",onClick:()=>M(s),disabled:r,children:s.status==="draft"?"Publish":"Unpublish"}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>k(s),children:"Edit"}),e.jsx(j,{variant:"destructive",size:"sm",onClick:()=>O(s.id),children:"Delete"})]})})]},s.id))})]})}),I&&e.jsx(ae,{open:I,onOpenChange:b,children:e.jsxs(te,{className:l.editorDialog,children:[e.jsx(ne,{children:e.jsx(le,{children:a.values.id?"Edit Post":"New Post"})}),e.jsx(ee,{...a,children:e.jsxs("form",{onSubmit:a.handleSubmit(q),className:l.form,children:[e.jsxs("div",{className:l.grid,children:[e.jsxs(d,{name:"title",children:[e.jsx(u,{children:"Title"}),e.jsx(h,{children:e.jsx(y,{value:a.values.title,onChange:s=>a.setValues(n=>({...n,title:s.target.value}))})}),e.jsx(S,{})]}),e.jsxs(d,{name:"slug",children:[e.jsx(u,{children:"Slug"}),e.jsx(h,{children:e.jsx(y,{value:a.values.slug,onChange:s=>a.setValues(n=>({...n,slug:s.target.value}))})}),e.jsx(S,{})]})]}),e.jsxs(d,{name:"h1",children:[e.jsx(u,{children:"H1 Headline"}),e.jsx(h,{children:e.jsx(y,{value:a.values.h1||"",onChange:s=>a.setValues(n=>({...n,h1:s.target.value}))})})]}),e.jsxs("div",{className:l.grid,children:[e.jsxs(d,{name:"category",children:[e.jsx(u,{children:"Category"}),e.jsx(h,{children:e.jsxs(P,{value:a.values.category,onValueChange:s=>a.setValues(n=>({...n,category:s})),children:[e.jsx(A,{children:e.jsx(B,{})}),e.jsxs(N,{children:[e.jsx(p,{value:"appraisal",children:"Appraisal"}),e.jsx(p,{value:"dont_throw_that_away",children:"Don't Throw That Away"}),e.jsx(p,{value:"auction_tips",children:"Auction Tips"}),e.jsx(p,{value:"art_authentication",children:"Art Authentication"})]})]})})]}),e.jsxs(d,{name:"status",children:[e.jsx(u,{children:"Status"}),e.jsx(h,{children:e.jsxs(P,{value:a.values.status,onValueChange:s=>a.setValues(n=>({...n,status:s})),children:[e.jsx(A,{children:e.jsx(B,{})}),e.jsxs(N,{children:[e.jsx(p,{value:"draft",children:"Draft"}),e.jsx(p,{value:"published",children:"Published"})]})]})})]})]}),e.jsxs(d,{name:"metaTitle",children:[e.jsx(u,{children:"Meta Title"}),e.jsx(h,{children:e.jsx(y,{value:a.values.metaTitle||"",onChange:s=>a.setValues(n=>({...n,metaTitle:s.target.value}))})})]}),e.jsxs(d,{name:"metaDescription",children:[e.jsx(u,{children:"Meta Description"}),e.jsx(h,{children:e.jsx(f,{value:a.values.metaDescription||"",onChange:s=>a.setValues(n=>({...n,metaDescription:s.target.value}))})})]}),e.jsxs(d,{name:"excerpt",children:[e.jsx(u,{children:"Excerpt (2 sentences)"}),e.jsx(h,{children:e.jsx(f,{value:a.values.excerpt||"",onChange:s=>a.setValues(n=>({...n,excerpt:s.target.value}))})})]}),e.jsxs(d,{name:"coverImage",children:[e.jsx(u,{children:"Cover Image"}),e.jsx(h,{children:e.jsx("div",{className:l.coverImageContainer,children:a.values.coverImage?e.jsxs("div",{className:l.coverImagePreview,children:[e.jsx("img",{src:a.values.coverImage,alt:"Cover Preview"}),e.jsx(j,{variant:"destructive",size:"sm",onClick:()=>a.setValues(s=>({...s,coverImage:null})),children:"Remove"})]}):e.jsx("div",{className:l.coverImageUpload,children:e.jsx(j,{asChild:!0,variant:"outline",disabled:w,children:e.jsxs("label",{children:[w?"Uploading...":"Upload Cover Image",e.jsx("input",{type:"file",accept:"image/*",className:l.hiddenInput,onChange:z})]})})})})})]}),e.jsxs(d,{name:"body",children:[e.jsx(u,{children:"Body (Rich Text HTML)"}),e.jsx(h,{children:e.jsx(f,{className:l.tallTextarea,value:a.values.body||"",onChange:s=>a.setValues(n=>({...n,body:s.target.value}))})})]}),e.jsx("div",{className:l.formActions,children:e.jsx(j,{type:"submit",disabled:r,children:r?"Saving...":"Save Post"})})]})})]})})]})}export{Fe 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.