PageSourceSearch

https://hansai.art/_next/static/chunks/pages/admin/super/store-listings-48dbf1f0262c0443.js

js hansai.art collected 2026-10-07 20:20:21 UTC 31,107 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[48067],{76729:(e,t,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/super/store-listings",function(){return r(62242)}])},13302:(e,t,r)=>{"use strict";r.d(t,{A:()=>m});var n=r(2445),l=r(27006),i=r(61032),a=r(96540),o=r(6442),s=r(99624),c=r(10767),d=r(79871),u=r(8548);let h=e=>{let{onAuthLoaded:t,onUserLoaded:r}=e,n=(0,c.A)(),{data:l}=(0,s.aB)(n);return(0,a.useEffect)(()=>{n&&l&&(t(n),r(l))},[n,l]),null},p=e=>{let{onImpress:t}=e,r=(0,d.A)(t);return(0,n.Y)("div",{ref:r})},m=e=>{let{isOpen:t,onClose:r,title:s,body:c,confirm:d,cancel:m="",onConfirm:g,onCancle:f,checkPhrase:Y,passwordConfirm:b,colorScheme:S,size:v,onDialogImpress:y=null,textAlign:x="center"}=e,w=(0,o.A)(),[C,D]=(0,a.useState)(),[F,A]=(0,a.useState)(),k=(0,a.useMemo)(()=>null==C?void 0:C.providerData.some(e=>{let{providerId:t}=e;return"google.com"===t}),[null==C?void 0:C.providerData]),[T,I]=(0,a.useState)(""),[M,z]=(0,a.useState)(),[E,N]=(0,a.useState)(),[B,O]=(0,a.useState)(!Y),W=(0,a.useRef)(),L=async()=>{if(k){let e=new i.GoogleAuthProvider;try{if((await (0,i.signInWithPopup)(F,e)).user.uid!==C.uid){z(w.formatMessage({defaultMessage:"Google帳號不符",id:"admin.shared.confirmDialog.Google帳號不符"})),N(!1);return}}catch(e){console.error(e),N(!1);return}}else try{let e=i.EmailAuthProvider.credential(F.currentUser.email,T);await (0,i.reauthenticateWithCredential)(C,e)}catch(e){"auth/wrong-password"===e.code&&z(w.formatMessage({defaultMessage:"密碼錯誤",id:"admin.shared.confirmDialog.密碼錯誤"})),N(!1);return}},_=async()=>{N(!0),b&&await L();try{await g(),W.current&&(N(!1),r())}catch(e){console.error(e),W.current&&N(!1)}},H=(0,a.useMemo)(()=>B&&(!b||T.length>=6||k),[B,T]);return(0,n.FD)(n.FK,{children:[(0,n.Y)(l.AlertDialog,{isOpen:t,leastDestructiveRef:W,onClose:r,isCentered:!0,returnFocusOnClose:!1,motionPreset:"none",size:v,blockScrollOnMount:!1,children:(0,n.Y)(l.AlertDialogOverlay,{children:(0,n.FD)(l.AlertDialogContent,{children:[y&&(0,n.Y)(p,{onImpress:y}),(0,n.Y)(l.AlertDialogHeader,{fontSize:"lg",fontWeight:"bold",textAlign:x,children:s||w.formatMessage({defaultMessage:"注意",id:"admin.shared.confirmDialog.注意"})}),(0,n.FD)(l.AlertDialogBody,{as:l.VStack,children:[(0,n.Y)(l.Box,{whiteSpace:"pre-wrap",textAlign:x,children:c||w.formatMessage({defaultMessage:"確認執行此動作",id:"admin.shared.confirmDialog.確認執行此動作"})}),Y&&(0,n.FD)(l.FormControl,{isRequired:!0,children:[(0,n.FD)(l.FormLabel,{children:[w.formatMessage({defaultMessage:"請輸入",id:"admin.shared.confirmDialog.請輸入"}),(0,n.Y)(l.Code,{colorScheme:"red",fontWeight:"bold",children:Y}),w.formatMessage({defaultMessage:"來確認執行",id:"admin.shared.confirmDialog.來確認執行"})]}),(0,n.Y)(l.Input,{onChange:e=>{Y&&O(e.target.value===Y)},focusBorderColor:"red.500",onKeyUp:e=>{"Enter"===e.key&&H&&_()}})]}),b&&!k&&(0,n.FD)(l.FormControl,{isRequired:!0,isInvalid:M,children:[(0,n.Y)(l.FormLabel,{children:w.formatMessage({defaultMessage:"請輸入您的密碼",id:"admin.shared.confirmDialog.請輸入您的密碼"})}),(0,n.Y)(l.Input,{onChange:e=>I(e.target.value),type:"password",autoComplete:"new-password",onKeyUp:e=>{"Enter"===e.key&&H&&_()}}),(0,n.Y)(l.FormErrorMessage,{children:M})]})]}),(0,n.FD)(l.AlertDialogFooter,{justifyContent:"center",children:[(0,n.Y)(u.A,{colorScheme:"gray",ref:W,onClick:()=>{r(),"function"==typeof f&&f()},isLoading:E,rounded:"full",children:m||w.formatMessage({defaultMessage:"取消",id:"admin.shared.confirmDialog.取消"})}),(0,n.Y)(u.A,{rounded:"full",colorScheme:S||"green",onClick:_,ml:3,isLoading:E,isDisabled:!H,children:d||w.formatMessage({defaultMessage:"確認",id:"admin.shared.confirmDialog.確認"})})]})]})})}),b&&(0,n.Y)(h,{onUserLoaded:D,onAuthLoaded:A})]})}},69235:(e,t,r)=>{"use strict";r.d(t,{A:()=>c});var n=r(2445),l=r(27006),i=r(58156),a=r.n(i),o=r(58065),s=r(7817);let c=e=>{let{role:t,children:r}=e,i=(0,s.A)(),c=(Array.isArray(t)?t:[t]).some(e=>a()(i,e));return i?c?r:(0,n.Y)(l.Center,{children:(0,n.Y)(l.Text,{fontSize:"xl",fontWeight:"bold",color:"red.500",children:(0,n.Y)(o.A,{id:"admin.shared.權限不足",defaultMessage:"權限不足"})})}):(0,n.Y)(l.Center,{children:(0,n.Y)(l.Spinner,{})})}},91711:(e,t,r)=>{"use strict";r.d(t,{A:()=>s,_:()=>a});var n=r(2445),l=r(22405),i=r(49177);let a=e=>e instanceof l.Timestamp?e.toDate():new Date(e instanceof Date?+e:e&&"object"==typeof e?"number"==typeof e._seconds?1e3*e._seconds:"number"==typeof e.seconds?1e3*e.seconds:NaN:"string"!=typeof e||/^\d+$/.test(e.trim())?+e:e),o=e=>{let{value:t,children:r,timeFormat:n="yy/MM/dd"}=e,l=t||r;if(!l)return null;try{return(0,i.b6)(a(l),n)||null}catch(e){return console.error(e),null}};o.DateTime=e=>(0,n.Y)(o,{timeFormat:"yy/MM/dd HH:mm",...e});let s=o},3748:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});var n=r(2445),l=r(18854),i=r(96540);let a=function(e){var t;let{labels:r,column:a,withCount:o=!1,valueGetter:s}=e,{filterValue:c,setFilter:d,preFilteredRows:u,id:h}=a,[p,m]=(0,i.useMemo)(()=>{let e={},t=new Set;return u.forEach(r=>{let n=s?s(r.original,r):r.values[h],l=null==n?"":String(n);o&&(e[l]=(e[l]||0)+1),t.add(l)}),[Array.from(t).sort((t,r)=>o?(e[r]||0)-(e[t]||0):t.localeCompare(r)),e]},[h,u,s,o]),g=null!=c?c:"";return(0,n.FD)(l.l,{size:"sm",value:g,name:h,onChange:e=>{d(e.target.value||void 0)},children:[(0,n.Y)("option",{value:"",children:"All"}),g&&!p.includes(g)&&(0,n.Y)("option",{value:g,children:null!==(t=null==r?void 0:r[g])&&void 0!==t?t:g}),p.map(e=>{var t;return(0,n.FD)("option",{value:e,children:[r&&null!==(t=r[e])&&void 0!==t?t:e,o?" (".concat(m[e]||0,")"):""]},e)})]})}},8972:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(2445),l=r(18854);let i=function(e){let{labels:t,column:r,options:i}=e,{filterValue:a,setFilter:o,id:s}=r;return(0,n.FD)(l.l,{size:"sm",value:null!=a?a:"",name:s,onChange:e=>{o(e.target.value||void 0)},children:[(0,n.Y)("option",{value:"",children:"All"}),i.map(e=>{var r;return(0,n.Y)("option",{value:e,children:t&&null!==(r=t[String(e)])&&void 0!==r?r:e},e)})]})}},66351:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});var n=r(2445),l=r(27006);function i(e){let{getInputProps:t,getCheckboxProps:r}=(0,l.useRadio)(e),i=t(),a=r();return(0,n.FD)(l.Box,{as:"label",children:[(0,n.Y)("input",{...i}),(0,n.Y)(l.Box,{...a,cursor:"pointer",whiteSpace:"nowrap",borderLeft:"4px solid transparent",_checked:{borderLeftColor:"teal.500",color:"teal.500"},px:"3",py:"1",children:e.children})]})}let a=e=>{let{options:t,onChange:r,defaultValue:a}=e,{getRootProps:o,getRadioProps:s}=(0,l.useRadioGroup)({defaultValue:a,onChange:r}),c=o();return(0,n.FD)(n.FK,{children:[(0,n.Y)(l.Select,{display:{base:"block",lg:"none"},w:"full",defaultValue:a,onChange:e=>r(e.target.value),children:t.map(e=>{let{value:t,label:r}=e;return(0,n.Y)("option",{value:t,children:r},t)})}),(0,n.Y)(l.Stack,{display:{base:"none",lg:"flex"},...c,children:t.map(e=>{let{value:t,label:r}=e,l=s({value:t});return(0,n.Y)(i,{...l,children:r},t)})})]})}},22061:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});var n=r(2445),l=r(27006),i=r(86715),a=r(38146),o=r(69235),s=r(66351),c=r(68296);let d=e=>{let{tabs:t=[],allTabs:r=[],requiredRole:d=!1,title:u=""}=e,h=(0,i.useRouter)(),p=h.asPath.split("?")[0],m=r.findIndex(e=>"/admin/super/".concat(e.name)===p),g=t.findIndex(e=>e.query===h.query.tab),f=(0,n.FD)(l.Tabs,{variant:"soft-rounded",colorScheme:"teal",isLazy:!0,defaultIndex:g>=0?g:0,onChange:e=>{let r=t[e].query;window.history.pushState({},"","".concat(window.location.pathname).concat(r?"?tab=".concat(r):""))},children:[(0,n.Y)(l.TabList,{overflow:"auto",display:"block",whiteSpace:"nowrap",children:t.map((e,t)=>(0,n.Y)(l.Tab,{display:"inline-flex",children:e.label},t))}),(0,n.Y)(l.TabPanels,{children:t.map((e,t)=>(0,n.Y)(l.TabPanel,{children:(0,n.Y)(a.A,{children:e.comp})},t))})]});return(0,n.Y)(c.A,{children:(0,n.FD)(l.VStack,{children:[u&&(0,n.Y)(l.Heading,{as:"h1",size:"lg",mb:"4",textAlign:"left",w:"full",children:u}),(0,n.FD)(l.Stack,{direction:{base:"column",lg:"row"},alignItems:"flex-start",spacing:{base:4,lg:8},divider:(0,n.Y)(l.StackDivider,{}),w:"full",children:[r.length>1&&(0,n.Y)(l.Box,{flexShrink:0,minW:0,w:{base:"full",lg:"auto"},pos:{lg:"sticky"},top:"4",children:(0,n.Y)(s.A,{options:r.map((e,t)=>({label:e.label,value:"".concat(t)})),onChange:e=>{h.push("/admin/super/".concat(r[e].name))},defaultValue:"".concat(m)})}),(0,n.Y)(l.Box,{flex:"1",w:"full",minW:0,children:d?(0,n.Y)(o.A,{role:d,children:f}):f})]})]})})}},97184:(e,t,r)=>{"use strict";r.d(t,{m:()=>n});let n=[{name:"profit-offer-requests",label:"推廣申請"},{name:"store-listings",label:"推廣商品"},{name:"customer-promotion",label:"購買者推廣"},{name:"profit-offer-creators",label:"創作者名單"},{name:"store-management",label:"Store 設定"}]},2793:(e,t,r)=>{"use strict";r.d(t,{$U:()=>i,DD:()=>u,H_:()=>a,MA:()=>d,Og:()=>n,bW:()=>o,id:()=>c,tw:()=>s,ur:()=>l});let n=4,l=1,i="default",a=.3,o=["ai","software","career","self-growth","language","mindfulness","social-media","finance","travel","health"],s={ai:"AI 應用",software:"軟體與工具",career:"職涯與工作","self-growth":"自我成長",language:"語言學習",mindfulness:"心靈成長","social-media":"社群經營",finance:"理財與投資",travel:"旅遊",health:"健康與醫療"},c={ai:"purple.500",software:"blue.500",career:"teal.500","self-growth":"orange.300",language:"cyan.600",mindfulness:"pink.500","
1social-media":"red.400",finance:"green.600",travel:"yellow.600",health:"messenger.500"},d=["social-media","software","finance","career","ai","self-growth","language","mindfulness","travel","health"],u={"social-media":{name:"社群經營",description:"實用社群經營教學與案例解析,協助你建立穩定且有黏著度的社群。"},software:{name:"軟體與工具",description:"精選 Notion、Procreate、Excel 等軟體工具應用,幫你加速創作與工作流程。"},finance:{name:"理財與投資",description:"瀏覽理財講座、財務筆記與投資分析,輕鬆探索理財規劃與被動收入。"},career:{name:"職涯與工作",description:"集結求職、面試與履歷撰寫資源,協助你在職場中穩健成長。"},ai:{name:"AI 應用",description:"從求職技巧到工具應用,瀏覽熱門 AI 應用筆記、實戰教學與延伸課程資源。"},"self-growth":{name:"自我成長",description:"探索職涯規劃、心理調適與自我激勵資源,打造專屬的個人成長路線。"},language:{name:"語言學習",description:"精選英文、日文及多國語言學習資源,陪你建立穩定的語言能力。"},mindfulness:{name:"心靈成長",description:"蒐集冥想練習、情緒管理與心理健康資源,幫助你安定身心、照顧自我。"},travel:{name:"旅遊",description:"彙整旅行規劃、海外生活與數位遊牧經驗,陪你開啟下一段旅程。"},health:{name:"健康與醫療",description:"蒐集運動、飲食與保健資源,幫你建立日常健康的生活節奏。"}}},10767:(e,t,r)=>{"use strict";r.d(t,{A:()=>a});var n=r(96540),l=r(99624),i=r(36795);let a=()=>{let{addSdk:e,activeSDK:t}=(0,n.useContext)(i.A);return(0,n.useEffect)(()=>{t.includes("auth")||setTimeout(()=>e("auth"))},[t]),t.includes("auth")&&(0,l.As)()}},11335:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});var n=r(55364),l=r.n(n),i=r(96540),a=r(8519),o=r(10767);let s=new Map,c=["auth/id-token-expired","auth/id-token-revoked","auth/argument-error"],d=()=>{let e=(0,i.useRef)(0),t=(0,o.A)();return(0,i.useCallback)(async(r,n)=>{var i,o,d;let u="".concat("portaly:firebaseToken",":").concat(null===(i=t.currentUser)||void 0===i?void 0:i.uid),h=null!==(d=null===(o=(0,a.A)("session"))||void 0===o?void 0:o.getItem(u))&&void 0!==d?d:s.get(u),p=async()=>{h=await t.currentUser.getIdToken(!0),(0,a.F)(u,h,"session"),s.set(u,h)};h||await p();let m=async()=>{let t=await fetch(r,l()({},n,h&&{headers:{Authorization:"Bearer ".concat(h)}}));if(t.ok)return e.current=0,204===t.status?null:t.json();let i=await t.text();if(c.includes(i)&&e.current<3)return e.current+=1,await p(),m();let a=Error(i);return a.response=t,Promise.reject(a)};return m()},[t])}},15953:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(96540),l=r(11335);let i=()=>{let e=(0,l.A)();return(0,n.useCallback)(t=>{e("/api/revalidate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:"store",...t?{profileId:t}:{}})}).catch(()=>{})},[e])}},62242:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>M});var n=r(2445),l=r(22061),i=r(97184),a=r(27006),o=r(96540),s=r(59324),c=r(13302),d=r(58323),u=r(91711),h=r(3748),p=r(8972),m=r(11335),g=r(15953),f=r(2793);let Y=e=>{let{value:t,onChange:r}=e,[l,i]=(0,o.useState)({}),s=new Set(t.map(e=>e.id)),c=f.bW.filter(e=>!s.has(e)),d=e=>i(t=>{if(!(e in t))return t;let r={...t};return delete r[e],r}),u=(e,n)=>{void 0!==n.id&&d(t[e].id),r(t.map((t,r)=>r===e?{...t,...n}:t))},h=e=>{d(t[e].id),r(t.filter((t,r)=>r!==e))};return(0,n.FD)(a.VStack,{align:"stretch",spacing:2,w:"full",children:[t.map((e,t)=>{var r;let o=f.bW.filter(t=>t===e.id||!s.has(t));return(0,n.FD)(a.HStack,{spacing:2,children:[(0,n.Y)(a.Select,{flex:"1",size:"sm",value:e.id,onChange:e=>u(t,{id:e.target.value}),children:o.map(e=>(0,n.Y)("option",{value:e,children:f.tw[e]},e))}),(0,n.Y)(a.Box,{w:"96px",children:(0,n.Y)(a.Input,{size:"sm",inputMode:"decimal",value:null!==(r=l[e.id])&&void 0!==r?r:String(e.score),onChange:r=>{let n=r.target.value;(""===n||/^(0(\.\d{0,2})?|1(\.0{0,2})?)$/.test(n))&&(i(t=>({...t,[e.id]:n})),u(t,{score:""===n?0:Number(n)}))},onBlur:()=>d(e.id),isInvalid:!Number.isFinite(e.score)||e.score<0||e.score>1})}),(0,n.Y)(a.IconButton,{"aria-label":"移除標籤",size:"sm",variant:"ghost",colorScheme:"red",icon:(0,n.Y)(a.Text,{fontSize:"lg",children:"\xd7"}),onClick:()=>h(t)})]},e.id)}),!t.length&&(0,n.Y)(a.Text,{fontSize:"xs",color:"GUI.gray.500",children:"尚無標籤"}),(0,n.Y)(a.Button,{size:"xs",variant:"outline",alignSelf:"flex-start",onClick:()=>{c.length&&r([...t,{id:c[0],score:.5}])},isDisabled:!c.length,children:"+ 新增標籤"}),(0,n.Y)(a.Text,{fontSize:"xs",color:"GUI.gray.500",children:"分數 0-1,數值越高代表越相關"})]})},b=e=>{let{label:t,children:r,hint:l}=e;return(0,n.FD)(a.HStack,{alignItems:"flex-start",w:"full",spacing:4,children:[(0,n.FD)(a.Box,{width:"120px",flexShrink:0,children:[(0,n.Y)(a.Text,{fontWeight:700,children:t}),l&&(0,n.Y)(a.Text,{fontSize:"xs",color:"GUI.gray.500",children:l})]}),(0,n.Y)(a.Box,{flex:"1",minW:"0",children:r})]})};var S=r(46494);let v=new Intl.NumberFormat("en-US"),y=e=>{if(e)try{let t=new URL(e);return"".concat(window.location.origin).concat(t.pathname).concat(t.search).concat(t.hash)}catch(t){return e}},x=e=>{let{isOpen:t,onClose:r,categoryOptions:l,onAdded:i}=e,s=(0,a.useToast)(),c=(0,m.A)(),d=(0,g.A)(),[u,h]=(0,o.useState)(!1),[p,f]=(0,o.useState)(!1),[x,w]=(0,o.useState)(""),[C,D]=(0,o.useState)(null),[F,A]=(0,o.useState)(""),[k,T]=(0,o.useState)(String(S.wT)),[I,M]=(0,o.useState)([]),z=Number(k),E=/^\d+(\.\d+)?$/.test(k)&&z>=S.Xk&&z<=100,N=I.every(e=>Number.isFinite(e.score)&&e.score>=0&&e.score<=1),B=()=>{w(""),D(null),A(""),T(String(S.wT)),M([]),h(!1),f(!1)},O=()=>{B(),r()},W=async()=>{let e=x.trim();if(e){h(!0);try{let t=await c("/api/super/store-listings/lookup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({productUrl:e})});D(t),M(t.contentTags||[])}catch(e){s({status:"error",title:"查無商品",description:e instanceof Error?e.message:void 0})}finally{h(!1)}}},L=async()=>
1{if(C){if(!E){s({status:"error",title:"分潤比例不合法"});return}if(!N){s({status:"error",title:"標籤分數需為 0-1"});return}f(!0);try{await c("/api/super/store-listings/listing",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:C.profileId,productId:C.productId,rebateRate:z,categoryId:F||null,contentTags:I})}),s({status:"success",title:"已上架"}),d(),null==i||i(),O()}catch(e){s({status:"error",title:"上架失敗",description:e instanceof Error?e.message:void 0})}finally{f(!1)}}};return(0,n.FD)(a.Modal,{isOpen:t,onClose:O,size:"lg",isCentered:!0,children:[(0,n.Y)(a.ModalOverlay,{}),(0,n.FD)(a.ModalContent,{maxW:{base:"100%",md:"720px"},minW:{base:"100%",md:"560px"},children:[(0,n.Y)(a.ModalHeader,{fontWeight:700,children:"上架商品"}),(0,n.Y)(a.ModalCloseButton,{}),(0,n.Y)(a.ModalBody,{children:(0,n.FD)(a.Stack,{spacing:6,align:"stretch",children:[(0,n.FD)(a.Stack,{spacing:2,children:[(0,n.Y)(a.Text,{fontWeight:700,children:"商品網址"}),(0,n.FD)(a.HStack,{children:[(0,n.Y)(a.Input,{value:x,onChange:e=>{w(e.target.value),D(null)},onKeyDown:e=>{"Enter"===e.key&&!u&&x.trim()&&W()},placeholder:"https://portaly.cc/{slug}/product/{productId}"}),(0,n.Y)(a.Button,{colorScheme:"green",onClick:W,isLoading:u,isDisabled:!x.trim(),children:"確認"})]})]}),C&&(0,n.FD)(n.FK,{children:[(0,n.FD)(a.Stack,{spacing:3,borderWidth:"1px",borderColor:"GUI.gray.300",rounded:"md",p:"4",children:[(0,n.Y)(b,{label:"商品",children:(()=>{let e=y(C.productUrl);return e?(0,n.Y)(a.Link,{href:e,isExternal:!0,color:"GUI.green.500",fontWeight:"semibold",noOfLines:1,children:C.productName||"-"}):(0,n.Y)(a.Text,{noOfLines:1,children:C.productName||"-"})})()}),(0,n.Y)(b,{label:"創作者",children:C.profileSlug?(0,n.Y)(a.Link,{href:y("https://portaly.cc/".concat(C.profileSlug)),isExternal:!0,color:"GUI.green.500",fontWeight:"semibold",children:C.profileSlug}):(0,n.Y)(a.Text,{fontFamily:"mono",children:C.profileId})}),(0,n.Y)(b,{label:"價格",children:(()=>{let{productPrice:e,productFinalPrice:t}=C,r=null!=t?t:e;if("number"!=typeof r)return(0,n.Y)(a.Text,{children:"-"});let l="number"==typeof e&&void 0!==t&&t<e;return(0,n.FD)(a.HStack,{spacing:2,children:[l&&(0,n.FD)(a.Text,{as:"s",color:"GUI.gray.500",fontSize:"sm",children:["NT$ ",v.format(e)]}),(0,n.FD)(a.Text,{color:l?"red.500":void 0,fontWeight:l?"semibold":void 0,children:["NT$ ",v.format(r)]})]})})()}),(0,n.Y)(b,{label:"已啟用商品數",children:(0,n.Y)(a.Text,{children:C.activeProductCount})}),C.alreadyListed&&(0,n.Y)(a.Text,{fontSize:"sm",color:"red.500",fontWeight:"semibold",children:"此商品已在推廣列表中,無法重複上架"})]}),(0,n.Y)(b,{label:"類別",children:(0,n.Y)(a.Select,{value:F,onChange:e=>A(e.target.value),placeholder:"未分類",children:l.map(e=>(0,n.Y)("option",{value:e.id,children:e.name},e.id))})}),(0,n.Y)(b,{label:"分潤比例",children:(0,n.FD)(a.Box,{children:[(0,n.FD)(a.InputGroup,{maxW:"32",children:[(0,n.Y)(a.Input,{inputMode:"decimal",value:k,onChange:e=>{let t=e.target.value;(""===t||/^\d+(\.\d{0,2})?$/.test(t))&&T(t)},isInvalid:!E}),(0,n.Y)(a.InputRightElement,{pointerEvents:"none",color:"GUI.gray.500",children:"%"})]}),!E&&(0,n.FD)(a.Text,{fontSize:"xs",color:"red.500",mt:"1",children:["請輸入 ",S.Xk,"-100 的數字"]})]})}),(0,n.Y)(b,{label:"標籤",hint:"種類與分數",children:(0,n.Y)(Y,{value:I,onChange:M})})]})]})}),(0,n.Y)(a.ModalFooter,{children:(0,n.FD)(a.HStack,{spacing:3,children:[(0,n.Y)(a.Button,{variant:"outline",onClick:O,children:"取消"}),C&&(0,n.Y)(a.Button,{colorScheme:"green",onClick:L,isLoading:p,isDisabled:C.alreadyListed||!E||!N,children:"上架"})]})})]})]})},w=e=>{var t;let{isOpen:r,onClose:l,item:i,categoryOptions:s,onUpdated:c}=e,d=(0,a.useToast)(),u=(0,m.A)(),h=(0,g.A)(),[p,f]=(0,o.useState)(!1),[v,y]=(0,o.useState)(i.categoryId||""),[x,w]=(0,o.useState)(i.contentTags||[]),[C,D]=(0,o.useState)(String(null!==(t=i.rebateRate)&&void 0!==t?t:S.wT)),F=Number(C),A=/^\d+(\.\d+)?$/.test(C)&&F>=S.Xk&&F<=100,[k,T]=(0,o.useState)(i.adminStoreEnabled),[I,M]=(0,o.useState)(i.adminProfitEnabled),z=i.creatorPromotionEnabled,E=x.every(e=>Number.isFinite(e.score)&&e.score>=0&&e.score<=1),N=async()=>
1{if(!A){d({status:"error",title:"分潤比例不合法"});return}if(!E){d({status:"error",title:"標籤分數需為 0-1"});return}f(!0);try{await u("/api/super/store-listings/".concat(i.productId),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({rebateRate:F,adminStoreEnabled:k,adminProfitEnabled:I,categoryId:v||null,contentTags:x})}),d({status:"success",title:"已更新"}),h(),null==c||c(),l()}catch(e){d({status:"error",title:"更新失敗",description:e instanceof Error?e.message:void 0})}finally{f(!1)}};return(0,n.FD)(a.Modal,{isOpen:r,onClose:l,size:"lg",isCentered:!0,children:[(0,n.Y)(a.ModalOverlay,{}),(0,n.FD)(a.ModalContent,{maxW:{base:"100%",md:"720px"},minW:{base:"100%",md:"560px"},children:[(0,n.Y)(a.ModalHeader,{fontWeight:700,children:"編輯商品"}),(0,n.Y)(a.ModalCloseButton,{}),(0,n.Y)(a.ModalBody,{children:(0,n.FD)(a.Stack,{spacing:6,align:"stretch",children:[(0,n.Y)(b,{label:"商品",children:(0,n.Y)(a.Text,{noOfLines:1,children:i.productName})}),(0,n.Y)(b,{label:"創作者",children:i.profileSlug?(0,n.Y)(a.Link,{href:"".concat(window.location.origin,"/").concat(i.profileSlug),isExternal:!0,color:"GUI.green.500",fontWeight:"semibold",children:i.profileSlug}):(0,n.Y)(a.Text,{fontFamily:"mono",fontSize:"sm",children:i.profileId})}),(0,n.Y)(b,{label:"類別",children:(0,n.Y)(a.Select,{value:v,onChange:e=>y(e.target.value),placeholder:"未分類",children:s.map(e=>(0,n.Y)("option",{value:e.id,children:e.name},e.id))})}),(0,n.Y)(b,{label:"分潤比例",children:(0,n.FD)(a.Box,{children:[(0,n.FD)(a.InputGroup,{maxW:"32",children:[(0,n.Y)(a.Input,{inputMode:"decimal",value:C,onChange:e=>{let t=e.target.value;(""===t||/^\d+(\.\d{0,2})?$/.test(t))&&D(t)},isInvalid:!A}),(0,n.Y)(a.InputRightElement,{pointerEvents:"none",color:"GUI.gray.500",children:"%"})]}),!A&&(0,n.FD)(a.Text,{fontSize:"xs",color:"red.500",mt:"1",children:["請輸入 ",S.Xk,"-100 的數字"]})]})}),(0,n.Y)(b,{label:"創作者推廣意願",children:(0,n.FD)(a.HStack,{spacing:2,children:[(0,n.Y)(a.Box,{as:"span",px:"2",py:"0.5",rounded:"md",bg:z?"green.100":"gray.100",color:z?"green.700":"gray.600",fontSize:"sm",fontWeight:"semibold",children:z?"已開啟":"未開啟"}),!z&&(0,n.Y)(a.Text,{fontSize:"xs",color:"GUI.gray.500",children:"創作者未開啟平台推廣,即使下方開關開啟也不會上架"})]})}),(0,n.Y)(b,{label:"Store 啟用",children:(0,n.Y)(a.Checkbox,{isChecked:k,onChange:e=>{let t=e.target.checked;T(t),t||M(!1)},colorScheme:"teal",children:"允許在 Store 上架"})}),(0,n.Y)(b,{label:"營利模式啟用",children:(0,n.Y)(a.Tooltip,{label:"需先啟用 Store,才能開啟營利模式",isDisabled:k,hasArrow:!0,children:(0,n.Y)(a.Box,{display:"inline-block",children:(0,n.Y)(a.Checkbox,{isChecked:I,onChange:e=>M(e.target.checked),isDisabled:!k,colorScheme:"teal",children:"允許在營利模式出現"})})})}),(0,n.Y)(b,{label:"標籤",hint:"種類與分數",children:(0,n.Y)(Y,{value:x,onChange:w})})]})}),(0,n.Y)(a.ModalFooter,{children:(0,n.FD)(a.HStack,{spacing:3,children:[(0,n.Y)(a.Button,{variant:"outline",onClick:l,children:"取消"}),(0,n.Y)(a.Button,{colorScheme:"green",onClick:N,isLoading:p,isDisabled:!A||!E,children:"儲存"})]})})]})]})},C=d.A,D=e=>e?Date.parse(e):void 0,F=e=>{if(!e)return!1;try{return new URL(e).hostname.endsWith("portaly.cc")}catch(e){return!1}},A=e=>{if(e){if(!F(e))return e;try{let t=new URL(e);return"".concat(window.location.origin).concat(t.pathname).concat(t.search).concat(t.hash)}catch(t){return e}}},k={airtable:"Airtable",creator_request:"創作者申請",whitelist:"白名單",admin:"Admin 手動新增"},T=(e,t,r)=>r?e.filter(e=>{let n=e.values[t[0]];return"string"==typeof n&&n.split(" ").includes(r)}):e;T.autoRemove=e=>!e;let I=()=>{let e=(0,m.A)(),t=(0,g.A)(),{data:r,isLoading:l,mutate:i}=(0,s.Ay)("/api/super/store-listings",e),{data:d}=(0,s.Ay)("/api/super/store-listings/categories",e),[Y,b]=(0,o.useState)(null),[v,y]=(0,o.useState)(null),F=(0,a.useDisclosure)(),I=(0,a.useDisclosure)(),M=(0,a.useDisclosure)(),z=(0,a.useToast)(),E=(0,o.useCallback)(e=>{y(e),M.onOpen()},[M]),N=(0,o.useCallback)(async()=>
1{if(v)try{await e("/api/super/store-listings/".concat(v.productId),{method:"DELETE"}),z({status:"success",title:"已下架"}),t(),i()}catch(e){throw z({status:"error",title:"下架失敗",description:e instanceof Error?e.message:void 0}),e}},[e,v,z,i,t]),B=(0,o.useMemo)(()=>[{Header:"商品",id:"productName",accessor:"productName",disableFilters:!0,Cell:e=>{let{row:{original:t}}=e,r=A(t.productUrl);return r?(0,n.Y)(a.Link,{href:r,isExternal:!0,color:"GUI.green.500",fontWeight:"semibold",noOfLines:1,children:t.productName}):(0,n.Y)(a.Text,{fontWeight:"semibold",noOfLines:1,children:t.productName})}},{Header:"創作者",accessor:"profileSlug",disableFilters:!0,Cell:e=>{let{row:{original:t}}=e,r=t.profileSlug;if(!r)return(0,n.Y)(a.Text,{fontSize:"xs",fontFamily:"mono",children:t.profileId});let l="".concat(window.location.origin,"/").concat(r);return(0,n.Y)(a.Link,{href:l,isExternal:!0,color:"GUI.green.500",children:r})}},{Header:"來源",id:"source",accessor:e=>k[e.source]||e.source,filter:"equals",Filter:e=>(0,n.Y)(h.A,{...e}),Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:t||"-"})}},{Header:"推廣數量",accessor:"promotionCount",disableFilters:!0,w:"96px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:Number(null!=t?t:0).toLocaleString()})}},{Header:"推廣金額",accessor:"promotionAmount",disableFilters:!0,w:"120px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:"$".concat(Number(null!=t?t:0).toLocaleString())})}},{Header:"分潤比例",accessor:"rebateRate",disableFilters:!0,w:"96px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:"".concat(null!=t?t:S.wT,"%")})}},{Header:"分潤金額",accessor:"commissionAmount",disableFilters:!0,w:"120px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:"$".concat(Number(null!=t?t:0).toLocaleString())})}},{Header:"類別",id:"categoryName",accessor:e=>e.categoryName||"-",filter:"equals",Filter:e=>(0,n.Y)(h.A,{...e}),Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",children:t||"-"})}},{Header:"標籤",id:"contentTags",accessor:e=>{var t;return(null===(t=e.contentTags)||void 0===t?void 0:t.map(e=>f.tw[e.id]||e.id).join(" "))||""},filter:T,Filter:e=>(0,n.Y)(p.A,{...e,options:Object.values(f.tw)}),Cell:e=>{var t;let{row:{original:r}}=e;return(0,n.Y)(a.Wrap,{spacing:"1",children:(null===(t=r.contentTags)||void 0===t?void 0:t.length)?r.contentTags.map(e=>{let t=f.tw[e.id]||e.id,r="number"==typeof e.score?e.score.toFixed(2):"";return(0,n.Y)(a.WrapItem,{children:(0,n.Y)(a.Tooltip,{label:"".concat(e.id," \xb7 ").concat(r),children:(0,n.FD)(a.Box,{as:"span",display:"inline-flex",alignItems:"center",gap:"1",px:"2",py:"0.5",rounded:"md",bg:f.id[e.id]||"GUI.purple.500",color:"white",fontSize:"xs",fontWeight:"semibold",children:[(0,n.Y)(a.Text,{as:"span",children:t}),r&&(0,n.Y)(a.Text,{as:"span",opacity:.7,fontWeight:"normal",children:r})]})})},e.id)}):(0,n.Y)(a.Text,{fontSize:"xs",color:"GUI.gray.500",children:"-"})})}},{Header:"創作者推廣",id:"creatorPromotionEnabled",accessor:e=>e.creatorPromotionEnabled?"已開啟":"未開啟",filter:"equals",Filter:e=>(0,n.Y)(p.A,{...e,options:["已開啟","未開啟"]}),w:"120px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"sm",color:"已開啟"===t?"green.600":"GUI.gray.500",children:t})}},{Header:"Store",id:"enablePortalyAds",accessor:e=>e.enablePortalyAds?"啟用":"未啟用",filter:"equals",Filter:e=>(0,n.Y)(p.A,{...e,options:["啟用","未啟用"]}),w:"120px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"md",children:"啟用"===t?"✅":"-"})}},{Header:"營利模式",id:"enableProfit",accessor:e=>e.enableProfit?"啟用":"未啟用",filter:"equals",Filter:e=>(0,n.Y)(p.A,{...e,options:["啟用","未啟用"]}),w:"128px",Cell:e=>{let{value:t}=e;return(0,n.Y)(a.Text,{fontSize:"md",children:"啟用"===t?"✅":"-"})}},{Header:"建立時間",id:"createdAt",accessor:e=>D(e.createdAt),Cell:u.A.DateTime,disableFilters:!0,isDate:!0,w:"192px"},{Header:"操作",id:"action",accessor:"productId",disableFilters:!0,disableSortBy:!0,w:"160px",Cell:e=>{let{row:{original:t}}=e;return(0,n.FD)(a.HStack,{spacing:2,children:[(0,n.Y)(a.Button,{size:"sm",colorScheme:"green",variant:"outline",onClick:()=>{b(t),F.onOpen()},children:"編輯"}),(0,n.Y)(a.Button,{size:"sm",colorScheme:"red",variant:"outline",onClick:()=>E(t),children:"下架"})]})}}],[F,E]);return l?(0,n.Y)(a.Flex,{justify:"center",py:"10",children:(0,n.Y)(a.Spinner,{})}):(0,n.FD)(a.Box,{children:[(0,n.Y)(a.Flex,{justify:"flex-end",mb:"4",children:(0,n.Y)(a.Button,{colorScheme:"green",onClick:I.onOpen,children:"上架商品"})}
1),(0,n.Y)(C,{data:r||[],columns:B,storageKey:"profitOfferPool",defaultSortBy:[{id:"createdAt",desc:!0}],enableFilters:!0,disableSortRemove:!0}),Y&&(0,n.Y)(w,{isOpen:F.isOpen,onClose:()=>{F.onClose(),b(null)},item:Y,categoryOptions:d||[],onUpdated:()=>i()}),(0,n.Y)(x,{isOpen:I.isOpen,onClose:I.onClose,categoryOptions:d||[],onAdded:()=>i()}),(0,n.Y)(c.A,{isOpen:M.isOpen,onClose:()=>{M.onClose(),y(null)},title:"下架商品",body:v?"確定下架「".concat(v.productName,"」?下架後該商品將從 Portaly Store 及營利模式移除。"):"",confirm:"下架",cancel:"取消",colorScheme:"red",onConfirm:N})]})},M=()=>(0,n.Y)(l.A,{title:"商品推廣",requiredRole:"admin",allTabs:i.m,tabs:[{label:"Active 商品",comp:(0,n.Y)(I,{})}]})},18854:(e,t,r)=>{"use strict";r.d(t,{l:()=>h});var n=r(74651),l=r(99139),i=r(15284),a=r(54443),o=r(34906),s=r(81943),c=r(29857),d=r(96540),u=r(74848),h=(0,i.R)((e,t)=>{var r;let i=(0,a.o5)("Select",e),{rootProps:d,placeholder:h,icon:p,color:m,height:f,h:Y,minH:b,minHeight:S,iconColor:v,iconSize:y,...x}=(0,o.MN)(e),[w,C]=function(e,t){let r={},n={};for(let[l,i]of Object.entries(e))t.includes(l)?r[l]=i:n[l]=i;return[r,n]}(x,o.GF),D=(0,l.t)(C),F={paddingEnd:"2rem",...i.field,_focus:{zIndex:"unset",...null==(r=i.field)?void 0:r._focus}};return(0,u.jsxs)(s.B.div,{className:"chakra-select__wrapper",__css:{width:"100%",height:"fit-content",position:"relative",color:m},...w,...d,children:[(0,u.jsx)(n.z,{ref:t,height:null!=Y?Y:f,minH:null!=b?b:S,placeholder:h,...D,__css:F,children:e.children}),(0,u.jsx)(g,{"data-disabled":(0,c.sE)(D.disabled),...(v||m)&&{color:v||m},__css:i.icon,...y&&{fontSize:y},children:p})]})});h.displayName="Select";var p=e=>(0,u.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,u.jsx)("path",{fill:"currentColor",d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),m=(0,s.B)("div",{baseStyle:{position:"absolute",display:"inline-flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",top:"50%",transform:"translateY(-50%)"}}),g=e=>{let{children:t=(0,u.jsx)(p,{}),...r}=e,n=(0,d.cloneElement)(t,{role:"presentation",className:"chakra-select__icon",focusable:!1,"aria-hidden":!0,style:{width:"1em",height:"1em",color:"currentColor"}});return(0,u.jsx)(m,{...r,className:"chakra-select__icon-wrapper",children:(0,d.isValidElement)(t)?n:null})};g.displayName="SelectIcon"}},e=>{var t=t=>e(e.s=t);e.O(0,[19883,28505,58247,67690,87551,81544,53958,80971,64065,99624,13404,77381,90585,47533,57716,59324,50211,64190,45915,90636,46593,38792],()=>t(76729)),_N_E=e.O()}]);

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.