File manager - Edit - /home/webapp69.cm.in.th/u69319090023/Shop23/_next/static/chunks/3oe_6htvpki1-.js
Back
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,99738,e=>{"use strict";let t=(0,e.i(56420).default)("shopping-cart",[["circle",{cx:"8",cy:"21",r:"1",key:"jimo8o"}],["circle",{cx:"19",cy:"21",r:"1",key:"13723u"}],["path",{d:"M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12",key:"9zh506"}]]);e.s(["ShoppingCart",0,t],99738)},23067,e=>{"use strict";let t=()=>{let e=window.location.pathname;return e.includes("/u69319090023/Shop23")?"/u69319090023/Shop23/api":e.includes("/Shop23")?"/Shop23/api":e.includes("/CMTC SHOP")||e.includes("/CMTC%20SHOP")?"/CMTC%20SHOP/api":"/api"},s=e=>Array.isArray(e)?e.filter(e=>{var t;return e&&e.id&&!((t=e.id)&&(t.startsWith("prod_170000000000")||t.startsWith("prod_tshirt_")||t.startsWith("prod_polo_")||t.startsWith("prod_hoodie_")||t.startsWith("prod_shop_")||t.startsWith("prod_cap_")||t.startsWith("prod_belt_")||t.startsWith("prod_badge_")||t.startsWith("prod_jacket_")||t.startsWith("prod_amulet_")||t.startsWith("prod_bag_")||t.startsWith("prod_backpack_")||!/^prod_\d+$/.test(t)))&&!e.id.startsWith("prod_170000000000")&&"เสื้อเกราะ"!==e.name&&"รถมอเตอร์ไซค์ไฟฟ้า"!==e.name&&"รถมอเตอร์ไซค์"!==e.name}):[],a=()=>{let e=localStorage.getItem("ctc_products"),t=[];if(e)try{t=JSON.parse(e)}catch{t=[]}let a=s(t);return a.length!==t.length&&(t=a,localStorage.setItem("ctc_products",JSON.stringify(t))),t},r=e=>{let t=s(e);localStorage.setItem("ctc_products",JSON.stringify(t)),window.dispatchEvent(new Event("storage"))},i=class{static async getProducts(){let e=a();try{let a=t(),i=await fetch(`${a}/products.php`,{cache:"no-store"});if(i.ok){let t=await i.json();if(t&&t.success&&Array.isArray(t.data)&&t.data.length>0){let a=s(t.data),i=new Map;a.forEach(e=>i.set(e.id,e)),e.forEach(e=>{i.has(e.id)||i.set(e.id,e)});let l=Array.from(i.values());return r(l),l}}}catch(e){}return e}static async getRecommendedProducts(){let e=await this.getProducts();if(!e||0===e.length)return[];let t=e.filter(e=>e.isRecommended);return t.length>=3?t:[...t,...e.filter(e=>!e.isRecommended)]}static async getProductById(e){let s=a(),i=s.find(t=>t.id===e);if(i)return i;try{let a=t(),i=await fetch(`${a}/products.php?id=${encodeURIComponent(e)}`,{cache:"no-store"});if(i.ok){let t=await i.json();if(t&&t.success&&t.data){let a=t.data,i=[a,...s.filter(t=>t.id!==e)];return r(i),a}}}catch{}}static async getProductBySlug(e){let s=a(),i=s.find(t=>t.slug===e);if(i)return i;try{let a=t(),i=await fetch(`${a}/products.php?slug=${encodeURIComponent(e)}`,{cache:"no-store"});if(i.ok){let e=await i.json();if(e&&e.success&&e.data){let t=e.data,a=[t,...s.filter(e=>e.id!==t.id)];return r(a),t}}}catch{}}static async saveProduct(e){let s=a();r(-1!==s.findIndex(t=>t.id===e.id)?s.map(t=>t.id===e.id?e:t):[e,...s]);try{let s=t();await fetch(`${s}/products.php`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(e){console.warn("Backend sync failed, saved locally:",e)}return e}static async deleteProduct(e){r(a().filter(t=>t.id!==e));try{let s=t();await fetch(`${s}/products.php?id=${encodeURIComponent(e)}`,{method:"DELETE"})}catch(e){console.warn("Backend delete sync failed:",e)}return!0}static async updateProducts(e){return r(e),!0}static async updateProductStock(e,s,i){let l=a(),c=l.findIndex(t=>t.id===e);if(-1!==c){l[c].inStock=s,void 0!==i&&(l[c].stockCount=i),r(l);try{let a=t();await fetch(`${a}/products.php`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,inStock:s,stockCount:i})})}catch(e){}return!0}return!1}};e.s(["default",0,i])},73474,e=>{"use strict";let t=(0,e.i(56420).default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);e.s(["Trash2",0,t],73474)},11241,e=>{"use strict";let t=(0,e.i(56420).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["ArrowLeft",0,t],11241)},84949,e=>{"use strict";var t=e.i(43476),s=e.i(71645),a=e.i(57688),r=e.i(22016),i=e.i(18566),l=e.i(11241),c=e.i(73474),n=e.i(63448),o=e.i(68109),d=e.i(99738),h=e.i(23067),p=e.i(93123);e.s(["default",0,function(){let e=(0,i.useRouter)(),{addItem:u}=(0,p.useCart)(),[x,m]=(0,s.useState)([]),[f,g]=(0,s.useState)(!0),[y,b]=(0,s.useState)(null),w=e=>{b(e),setTimeout(()=>{b(null)},2500)},j=()=>{try{let e=JSON.parse(localStorage.getItem("wishlist")||"[]");h.default.getProducts().then(t=>{let s=t.filter(t=>e.includes(t.id));m(s),g(!1);let a=s.map(e=>e.id);a.length!==e.length&&(localStorage.setItem("wishlist",JSON.stringify(a)),window.dispatchEvent(new Event("storage")))})}catch(e){console.error("Failed to load wishlist:",e),g(!1)}};return((0,s.useEffect)(()=>(j(),window.addEventListener("storage",j),()=>window.removeEventListener("storage",j)),[]),f)?(0,t.jsx)("div",{className:"min-h-screen bg-[#F8F9FA] flex items-center justify-center font-prompt pt-24",children:(0,t.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[(0,t.jsx)("div",{className:"w-10 h-10 border-4 border-[#800A0A] border-t-transparent rounded-full animate-spin"}),(0,t.jsx)("p",{className:"text-xs text-gray-500 font-bold",children:"กำลังโหลดรายการโปรดของคุณ..."})]})}):(0,t.jsxs)("div",{className:"min-h-screen bg-[#F8F9FA] font-prompt pt-24 pb-16",children:[(0,t.jsxs)("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:[(0,t.jsx)("div",{className:"flex mb-6 justify-start",children:(0,t.jsxs)("button",{onClick:()=>e.back(),className:"flex items-center space-x-2 text-xs font-bold text-gray-500 hover:text-black transition-colors bg-transparent border-none cursor-pointer",children:[(0,t.jsx)(l.ArrowLeft,{className:"w-4 h-4"}),(0,t.jsx)("span",{children:"ย้อนกลับ"})]})}),(0,t.jsx)("div",{className:"flex items-center justify-between pb-5 border-b border-gray-200/80 mb-8",children:(0,t.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,t.jsx)(o.Heart,{className:"w-6 h-6 text-red-500 fill-red-500"}),(0,t.jsxs)("h1",{className:"text-xl sm:text-2xl font-black text-gray-900 leading-none",children:["สินค้าโปรดของฉัน (",x.length,")"]})]})}),0===x.length?(0,t.jsxs)("div",{className:"bg-white border border-gray-100 rounded-3xl p-12 text-center shadow-xs max-w-lg mx-auto mt-8 flex flex-col items-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-full bg-red-50 flex items-center justify-center text-red-500 mb-4",children:(0,t.jsx)(o.Heart,{className:"w-8 h-8"})}),(0,t.jsx)("h2",{className:"text-base font-bold text-gray-800 mb-2",children:"ยังไม่มีสินค้าโปรด"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 max-w-xs leading-relaxed mb-6",children:"เลือกดูสินค้าที่คุณสนใจแล้วกดปุ่มหัวใจสีแดงเพื่อเก็บรายการสินค้าที่ถูกใจไว้ดูในภายหลังได้ที่นี่"}),(0,t.jsxs)(r.default,{href:"/products",className:"inline-flex items-center justify-center bg-black hover:bg-gray-900 text-white font-bold text-xs px-6 py-3.5 rounded-full transition-all active:scale-95 cursor-pointer shadow-sm select-none",children:[(0,t.jsx)(d.ShoppingCart,{className:"w-4 h-4 mr-2"}),(0,t.jsx)("span",{children:"เริ่มช้อปสินค้า"})]})]}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6",children:x.map(e=>(0,t.jsxs)(r.default,{href:`/products/${e.id}`,className:"group relative flex flex-col justify-between h-full bg-white border border-gray-150/70 rounded-3xl p-4 hover:shadow-lg hover:-translate-y-1 transition-all duration-300",children:[(0,t.jsx)("button",{type:"button",onClick:t=>((e,t)=>{t.preventDefault(),t.stopPropagation();try{let t=JSON.parse(localStorage.getItem("wishlist")||"[]").filter(t=>t!==e);localStorage.setItem("wishlist",JSON.stringify(t)),m(t=>t.filter(t=>t.id!==e)),window.dispatchEvent(new Event("storage")),w("นำออกจากสินค้าโปรดแล้ว")}catch(e){console.error(e)}})(e.id,t),className:"absolute top-6 right-6 z-20 w-8 h-8 rounded-full bg-white/90 shadow-sm border border-gray-100 hover:bg-red-50 hover:text-red-500 transition-all flex items-center justify-center text-gray-450 cursor-pointer",title:"ลบออกจากรายการโปรด",children:(0,t.jsx)(c.Trash2,{className:"w-4 h-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"relative aspect-square w-full rounded-2xl overflow-hidden bg-[#F8F9FA] mb-4 flex items-center justify-center select-none",children:(0,t.jsx)(a.default,{src:e.images[0],alt:e.name,fill:!0,className:"object-contain p-4 mix-blend-multiply transition-transform duration-300 group-hover:scale-105"})}),(0,t.jsxs)("div",{className:"space-y-1 text-left px-1",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold text-gray-450 uppercase tracking-wider block",children:"cat_tshirt"===e.categoryId?"เสื้อยืด คอกลม":"cat_polo"===e.categoryId?"เสื้อโปโลวิทยาลัย":"cat_hoodie"===e.categoryId?"เสื้อฮู้ดดี้กันหนาว":"cat_jacket"===e.categoryId?"เสื้อแจ็คเก็ต":"cat_accessory"===e.categoryId?"อุปกรณ์เสริม":"หมวดหมู่สินค้า"}),(0,t.jsx)("h3",{className:"text-xs sm:text-sm font-bold text-gray-800 line-clamp-2 min-h-[36px] leading-snug",children:e.name})]})]}),(0,t.jsxs)("div",{className:"mt-4 pt-3 border-t border-gray-50 text-left px-1 space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,t.jsxs)("span",{className:"text-sm font-black text-gray-900",children:["฿",e.price.toLocaleString()]}),e.compareAtPrice&&(0,t.jsxs)("span",{className:"text-[10px] font-medium text-gray-400 line-through",children:["฿",e.compareAtPrice.toLocaleString()]})]}),(0,t.jsx)("div",{className:"flex flex-col gap-2 w-full pt-1",children:(0,t.jsxs)("button",{type:"button",onClick:t=>{let s;return t.preventDefault(),t.stopPropagation(),s=e.sizes.length>0?e.sizes[0]:"Free Size",void(u(e,1,s),w(`เพิ่ม "${e.name}" ลงในตะกร้าแล้ว!`))},disabled:!e.inStock,className:`w-full py-2.5 rounded-full flex items-center justify-center space-x-1.5 font-bold text-[10px] transition-all cursor-pointer ${e.inStock?"bg-black text-white hover:bg-gray-900":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:[(0,t.jsx)(n.ShoppingBag,{className:"w-3.5 h-3.5"}),(0,t.jsx)("span",{children:e.inStock?"หยิบใส่ตะกร้า":"สินค้าหมด"})]})})]})]},e.id))})]}),y&&(0,t.jsxs)("div",{className:"fixed bottom-6 left-1/2 -translate-x-1/2 bg-black/90 backdrop-blur-md text-white text-xs font-bold px-5 py-3 rounded-full shadow-xl border border-white/10 z-[100] animate-in fade-in slide-in-from-bottom-4 duration-300 flex items-center space-x-2",children:[(0,t.jsx)("span",{children:"🔔"}),(0,t.jsx)("span",{children:y})]})]})}])}]);
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings