PageSourceSearch

https://kolabo.co.id/assets/use-socmed-contents-zY83vss0.js

js kolabo.co.id collected 2026-10-05 01:07:02 UTC 2,167 bytes, 1 lines download raw bytes

1import{u as b}from"./useQuery-BujisQX_.js";import{w,aa as _,D as s,Q as n}from"./index-CxTzo_i5.js";import{u}from"./useMutation-nYJy1ouO.js";function E(){const{currentBrand:i}=w(),t=i==null?void 0:i.id,c=_(),{data:r,isLoading:d,error:m,refetch:f}=b({queryKey:["socmed_contents",t],queryFn:async()=>{let e=s.from("socmed_contents").select("*").order("scheduled_at",{ascending:!0});t&&(e=e.eq("brand_id",t));const{data:o,error:a}=await e;if(a)throw a;return o},enabled:!!t}),h=u({mutationFn:async e=>{const{data:o,error:a}=await s.from("socmed_contents").insert({...e,brand_id:t}).select().single();if(a)throw a;return o},onSuccess:()=>{c.invalidateQueries({queryKey:["socmed_contents",t]}),n.success("Content berhasil ditambahkan")},onError:e=>{console.error("Error creating content:",e),n.error("Gagal menambahkan content")}}),g=u({mutationFn:async({id:e,...o})=>{const{data:a,error:l}=await s.from("socmed_contents").update(o).eq("id",e).select().single();if(l)throw l;return a},onSuccess:()=>{c.invalidateQueries({queryKey:["socmed_contents",t]}),n.success("Content berhasil diupdate")},onError:e=>{console.error("Error updating content:",e),n.error("Gagal mengupdate content")}}),y=u({mutationFn:async e=>{const{error:o}=await s.from("socmed_contents").delete().eq("id",e);if(o)throw o},onSuccess:()=>{c.invalidateQueries({queryKey:["socmed_contents",t]}),n.success("Content berhasil dihapus")},onError:e=>{console.error("Error deleting content:",e),n.error("Gagal menghapus content")}}),p={total:(r==null?void 0:r.length)??0,draft:(r==null?void 0:r.filter(e=>e.status==="Draft").length)??0,scheduled:(r==null?void 0:r.filter(e=>e.status==="Scheduled").length)??0,published:(r==null?void 0:r.filter(e=>e.status==="Published").length)??0,byPlatform:{TikTok:(r==null?void 0:r.filter(e=>e.platform==="TikTok").length)??0,Instagram:(r==null?void 0:r.filter(e=>e.platform==="Instagram").length)??0,Twitter:(r==null?void 0:r.filter(e=>e.platform==="Twitter").length)??0,Facebook:(r==null?void 0:r.filter(e=>e.platform==="Facebook").length)??0}};return{contents:r??[],isLoading:d,error:m,refetch:f,createContent:h,updateContent:g,deleteContent:y,stats:p}}export{E as u};

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.