PageSourceSearch

https://synergeticshippingsolutions.com/static/js/5035.cdca5b2b.chunk.js

js synergeticshippingsolutions.com collected 2026-10-10 01:22:41 UTC 11,589 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunksynergeticsolutions=self.webpackChunksynergeticsolutions||[]).push([[5035],{1487:(t,a,e)=>{e.d(a,{_:()=>i});var s=e(89379);async function n(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const e=t.startsWith("http")?t:"".concat("https://synergeticshippingsolutions.com/backendservices/api/v1","/").concat(t);let n;try{const t=a.body instanceof FormData?{}:{"Content-Type":"application/json"};n=await fetch(e,(0,s.A)((0,s.A)({},a),{},{headers:(0,s.A)((0,s.A)({},t),a.headers)}))}catch(i){const t=i.message||"Network error.";throw Object.assign(new Error(t),{response:null})}const o=await n.json().catch(()=>({}));if(!n.ok){const t=o.message||o.error||(o.errors&&"object"===typeof o.errors?Object.entries(o.errors).map(t=>{let[a,e]=t;return"".concat(a,": ").concat(Array.isArray(e)?e.join(", "):e)}).join("; "):null)||"Request failed (".concat(n.status,")");throw Object.assign(new Error(t),{response:{data:o}})}return o}function o(t){if(!t)return t;const a=(0,s.A)({},t);return a.category&&"object"===typeof a.category&&(a.category_name=a.category.name,a.category_slug=a.category.slug),a}const i={getList:async function(){var t,a,e;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{category:i,page:c=1,limit:l=10,status:r,search:d}=s,g=new URLSearchParams;r&&"all"!==r&&g.set("status",r),d&&g.set("search",d);const u="number"===typeof i?i:parseInt(i,10);if(i&&!Number.isNaN(u)){return function(t){var a,e,s,n,i;const c=Array.isArray(t.data)?t.data.map(o):[];return{success:!0,data:c,pagination:t.pagination?{page:null!==(a=null!==(e=t.pagination.current_page)&&void 0!==e?e:t.pagination.page)&&void 0!==a?a:1,total_pages:null!==(s=null!==(n=t.pagination.last_page)&&void 0!==n?n:t.pagination.total_pages)&&void 0!==s?s:1,total:null!==(i=t.pagination.total)&&void 0!==i?i:0,per_page:t.pagination.per_page}:{page:1,total_pages:1,total:c.length},message:t.message}}(await n("get-blog-posts-by-category/".concat(u)))}const p=i&&"string"===typeof i;p?(g.set("per_page",500),g.set("page",1)):(c&&g.set("page",c),l&&g.set("per_page",l));const m=g.toString(),h=await n("get-all-blog-posts".concat(m?"?".concat(m):""));let b=Array.isArray(h.data)?h.data:[];if(p){const t=i.toLowerCase().trim(),a=t=>String(t||"").toLowerCase().trim();b=b.filter(e=>[a(e.category_slug),a(e.category_name),"string"===typeof e.category?a(e.category):"",e.category&&"object"===typeof e.category?a(e.category.slug):"",e.category&&"object"===typeof e.category?a(e.category.name):""].includes(t));const e=l||9,s=c||1,n=b.length,r=Math.max(1,Math.ceil(n/e)),d=(s-1)*e;return{success:!0,data:b.slice(d,d+e).map(o),pagination:{page:s,total_pages:r,total:n,per_page:e},message:h.message}}const y=h.pagination?{page:null!==(t=h.pagination.current_page)&&void 0!==t?t:1,total_pages:null!==(a=h.pagination.last_page)&&void 0!==a?a:1,total:null!==(e=h.pagination.total)&&void 0!==e?e:b.length,per_page:h.pagination.per_page}:{page:1,total_pages:1,total:b.length};return{success:!0,data:b.map(o),pagination:y,message:h.message}},getBySlug:async t=>{const a=encodeURIComponent(t||""),e=await n("get-blog-post/".concat(a)),s=e.data||e.post||e.success&&e;if(!s)throw Object.assign(new Error("Blog post not found"),{response:{data:{message:"Post not found"}}});return{success:!0,data:o(s),message:e.message}},getById:async t=>{const a=await n("get-blog-post-by-id/".concat(t));return{success:!0,data:o(a.data),message:a.message}},create:async t=>{let a;if(t&&t.featured_image&&"undefined"!==typeof File&&t.featured_image instanceof File){const e=new FormData;Object.entries(t).forEach(t=>{let[a,s]=t;void 0!==s&&null!==s&&("featured_image"===a?e.append("featured_image",s):e.append(a,String(s)))}),a=await n("create-blog-post",{method:"POST",body:e})}else a=await n("create-blog-post",{method:"POST",body:JSON.stringify(t)});return{success:!0,data:o(a.data),message:a.message}},update:async(t,a)=>{let e;if(a&&a.featured_image&&"undefined"!==typeof File&&a.featured_image instanceof File){const s=new FormData;Object.entries(a).forEach(t=>{let[a,e]=t;void 0!==e&&null!==e&&("featured_image"===a?s.append("featured_image",e):s.append(a,String(e)))}),e=await n("update-blog-post/".concat(t),{method:"POST",body:s})}else e=await n("update-blog-post/".concat(t),{method:"POST",body:JSON.stringify(a)});return{success:!0,data:e.data?o(e.data):void 0,message:e.message}},delete:async t=>({success:!0,message:(await n("delete-blog-post/".concat(t),{method:"POST"})).message})}},55035:(t,a,e)=>{e.r(a),e.d(a,{default:()=>r});var s=e(89379),n=e(65043),o=e(1045),i=e(1487),c=e(90424),l=e(70579);
1function r(){const[t,a]=(0,n.useState)([]),[e,r]=(0,n.useState)([]),[d,g]=(0,n.useState)(!0),[u,p]=(0,n.useState)(""),[m,h]=(0,n.useState)(""),[b,y]=(0,n.useState)(""),[f,j]=(0,n.useState)(1),[v,x]=(0,n.useState)({page:1,total_pages:1,total:0}),[w,_]=(0,n.useState)(null),[S,N]=(0,n.useState)(null),A=(0,n.useCallback)(async()=>{try{const t=await c.Z.getForDropdown();t.success&&t.data&&r(t.data)}catch(t){r([])}},[]),O=(0,n.useCallback)(async()=>{g(!0),p("");try{const t={status:"all",page:f,limit:10};m&&(t.category=m),b.trim()&&(t.search=b.trim());const e=await i._.getList(t);e.success?(a(e.data||[]),x(e.pagination||{page:1,total_pages:1,total:0})):p(e.message||"Failed to load blogs")}catch(s){var t,e;p((null===(t=s.response)||void 0===t||null===(e=t.data)||void 0===e?void 0:e.message)||s.message||"Network error"),a([])}finally{g(!1)}},[m,b,f]);(0,n.useEffect)(()=>{A()},[A]),(0,n.useEffect)(()=>{O()},[O]);return(0,l.jsxs)("div",{className:"admin-blogs",children:[(0,l.jsxs)("div",{className:"admin-blogs-head",children:[(0,l.jsx)("h2",{className:"admin-blogs-title",children:"Blogs"}),(0,l.jsx)(o.N_,{to:"/admin/dashboard/add-blog",className:"admin-blogs-add-btn",children:"Add Blog"})]}),(0,l.jsxs)("div",{className:"admin-blogs-toolbar",children:[(0,l.jsxs)("form",{onSubmit:t=>{t.preventDefault(),j(1),O()},className:"admin-blogs-search-form",children:[(0,l.jsx)("input",{type:"text",placeholder:"Search by title\u2026",value:b,onChange:t=>y(t.target.value),className:"admin-blogs-search-input"}),(0,l.jsx)("button",{type:"submit",className:"admin-blogs-search-btn",children:"Search"})]}),(0,l.jsxs)("select",{value:m,onChange:t=>{h(t.target.value),j(1)},className:"admin-blogs-category-select",children:[(0,l.jsx)("option",{value:"",children:"All categories"}),e.map(t=>(0,l.jsx)("option",{value:t.slug,children:t.name},t.id))]})]}),u&&(0,l.jsx)("div",{className:"admin-blogs-error",role:"alert",children:u}),d?(0,l.jsxs)("div",{className:"admin-blogs-loading",children:[(0,l.jsx)("span",{className:"admin-blogs-spinner"})," Loading\u2026"]}):0===t.length?(0,l.jsxs)("div",{className:"admin-blogs-empty",children:[(0,l.jsx)("p",{children:"No blogs found."}),(0,l.jsx)(o.N_,{to:"/admin/dashboard/add-blog",children:"Add your first blog"})]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"admin-blogs-table-wrap",children:(0,l.jsxs)("table",{className:"admin-blogs-table",children:[(0,l.jsx)("thead",{children:(0,l.jsxs)("tr",{children:[(0,l.jsx)("th",{children:"Title"}),(0,l.jsx)("th",{children:"Category"}),(0,l.jsx)("th",{children:"Author"}),(0,l.jsx)("th",{children:"Status"}),(0,l.jsx)("th",{children:"Date"}),(0,l.jsx)("th",{children:"Actions"})]})}),(0,l.jsx)("tbody",{children:t.map(t=>(0,l.jsxs)("tr",{children:[(0,l.jsx)("td",{children:(0,l.jsx)("strong",{children:t.title})}),(0,l.jsx)("td",{children:t.category_name||"\u2014"}),(0,l.jsx)("td",{children:t.author_name||"\u2014"}),(0,l.jsx)("td",{children:(0,l.jsx)("span",{className:"admin-blogs-status admin-blogs-status--".concat(t.status),children:t.status})}),(0,l.jsx)("td",{children:t.created_at?new Date(t.created_at).toLocaleDateString():"\u2014"}),(0,l.jsxs)("td",{children:[(0,l.jsx)(o.N_,{to:"/admin/dashboard/blogs/edit/".concat(t.id),className:"admin-blogs-action",children:"Edit"}),(0,l.jsx)("button",{type:"button",className:"admin-blogs-action admin-blogs-action-btn",onClick:()=>(async t=>{const a="published"===t.status?"draft":"published";N(t.id);try{await i._.update(t.id,(0,s.A)((0,s.A)({},t),{},{status:a})),O()}catch(o){var e,n;p((null===(e=o.response)||void 0===e||null===(n=e.data)||void 0===n?void 0:n.message)||o.message||"Update failed")}finally{N(null)}})(t),disabled:S===t.id,children:S===t.id?"\u2026":"published"===t.status?"Unpublish":"Publish"}),(0,l.jsx)("button",{type:"button",className:"admin-blogs-action admin-blogs-action-btn admin-blogs-action--danger",onClick:()=>(async t=>{if(window.confirm("Are you sure you want to delete this blog?")){_(t);try{const a=await i._.delete(t);a.success?O():p(a.message||"Delete failed")}catch(s){var a,e;p((null===(a=s.response)||void 0===a||null===(e=a.data)||void 0===e?void 0:e.message)||s.message||"Delete failed")}finally{_(null)}}})(t.id),disabled:w===t.id,children:w===t.id?"\u2026":"Delete"})]})]},t.id))})]})}),v.total_pages>1&&(0,l.jsxs)("div",{className:"admin-blogs-pagination",children:[(0,l.jsx)("button",{type:"button",className:"admin-blogs-page-btn",disabled:f<=1,onClick:()=>j(t=>t-1),children:"Previous"}),(0,l.jsxs)("span",{className:"admin-blogs-page-info",children:["Page ",f," of ",v.total_pages," (",v.total," total)"]}),(0,l.jsx)("button",{type:"button",className:"admin-blogs-page-btn",disabled:f>=v.total_pages,onClick:()=>j(t=>t+1),children:"Next"})]})]})]})}},90424:(t,a,e)=>{e.d(a,{Z:()=>o,g:()=>i});var s=e(89379);async function n(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const e=t.startsWith("http")?t:"".concat("https://synergeticshippingsolutions.
1com/backendservices/api/v1","/").concat(t),n=await fetch(e,(0,s.A)((0,s.A)({},a),{},{headers:(0,s.A)({"Content-Type":"application/json"},a.headers)})),o=await n.json().catch(()=>({}));if(!n.ok)throw Object.assign(new Error(o.message||"Request failed"),{response:{data:o}});return o}const o={getAll:function(){const t=new URLSearchParams(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).toString();return n("get-all-categories".concat(t?"?".concat(t):"")).then(t=>({success:!0,data:t.data||[],pagination:t.pagination}))},getForDropdown:()=>n("get-categories-for-dropdown").then(t=>({success:!0,data:t.data||[]})),getById:t=>n("get-category-by-id/".concat(t)).then(t=>({success:!0,data:t.data})),create:t=>n("create-category",{method:"POST",body:JSON.stringify({name:t.name,slug:t.slug,description:t.description||"",status:void 0!==t.status?t.status:1})}).then(t=>({success:!0,data:t.data})),update:(t,a)=>n("update-category/".concat(t),{method:"POST",body:JSON.stringify({name:a.name,slug:a.slug,description:a.description||"",status:void 0!==a.status?a.status:1})}).then(t=>({success:!0,data:t.data})),delete:t=>n("delete-category/".concat(t),{method:"POST"}).then(()=>({success:!0}))},i={getAll:function(){const t=new URLSearchParams(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).toString();return n("get-all-tags".concat(t?"?".concat(t):"")).then(t=>({success:!0,data:t.data||[],pagination:t.pagination}))},getForDropdown:()=>n("get-tags-for-dropdown").then(t=>({success:!0,data:t.data||[]})),getById:t=>n("get-tag-by-id/".concat(t)).then(t=>({success:!0,data:t.data})),create:t=>n("create-tag",{method:"POST",body:JSON.stringify({name:t.name,slug:t.slug||t.name})}).then(t=>({success:!0,data:t.data})),update:(t,a)=>n("update-tag/".concat(t),{method:"POST",body:JSON.stringify({name:a.name,slug:a.slug||a.name})}).then(t=>({success:!0,data:t.data})),delete:t=>n("delete-tag/".concat(t),{method:"POST"}).then(()=>({success:!0}))}}}]);
2//# sourceMappingURL=5035.cdca5b2b.chunk.js.map

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.