Files
Shifted/.next/static/chunks/app/admin/printful/page-38a1fcfffa4337cf.js
2026-02-10 01:14:19 +00:00

1 line
2.2 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[221],{3517:function(e,t,a){Promise.resolve().then(a.bind(a,5983))},5983:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return i}});var n=a(7437),r=a(2265);function i(){let[e,t]=(0,r.useState)(""),[a,i]=(0,r.useState)(""),[l,u]=(0,r.useState)(""),[s,c]=(0,r.useState)(""),[o,d]=(0,r.useState)(""),[p,h]=(0,r.useState)(""),[v,f]=(0,r.useState)(""),[m,g]=(0,r.useState)(!1);async function x(t){t.preventDefault(),g(!0),f("");try{var n;let t={sync_product:{name:e,external_id:a||void 0,thumbnail:l||void 0},sync_variants:[{variant_id:Number(s),retail_price:o,files:p?[{type:"default",url:p}]:[]}]},r=await fetch("/api/printful/sync-products",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),i=await r.json();if(!r.ok)throw Error(i.error||"Failed to create product.");f("Created sync product: ".concat((null===(n=i.result)||void 0===n?void 0:n.id)||"ok"))}catch(e){f(e.message||"Failed to create product.")}finally{g(!1)}}return(0,n.jsx)("main",{className:"auth-page",children:(0,n.jsx)("section",{className:"section",children:(0,n.jsxs)("div",{className:"container auth-page__inner",children:[(0,n.jsx)("h1",{className:"page-title",children:"Printful Admin"}),(0,n.jsxs)("form",{className:"auth-card",onSubmit:x,children:[(0,n.jsx)("input",{type:"text",placeholder:"Product name",value:e,onChange:e=>t(e.target.value),required:!0}),(0,n.jsx)("input",{type:"text",placeholder:"External ID (optional)",value:a,onChange:e=>i(e.target.value)}),(0,n.jsx)("input",{type:"text",placeholder:"Thumbnail URL (optional)",value:l,onChange:e=>u(e.target.value)}),(0,n.jsx)("input",{type:"number",placeholder:"Printful variant ID",value:s,onChange:e=>c(e.target.value),required:!0}),(0,n.jsx)("input",{type:"text",placeholder:"Retail price (e.g. 29.99)",value:o,onChange:e=>d(e.target.value),required:!0}),(0,n.jsx)("input",{type:"text",placeholder:"Print file URL (optional)",value:p,onChange:e=>h(e.target.value)}),(0,n.jsx)("button",{className:"btn",type:"submit",disabled:m,children:m?"Creating...":"Create Sync Product"}),v?(0,n.jsx)("div",{className:"connect-message",children:v}):null]})]})})})}}},function(e){e.O(0,[971,117,744],function(){return e(e.s=3517)}),_N_E=e.O()}]);