PageSourceSearch

https://www.bookbaker.com/assets/UserDetailPage-921d53ed.js

js bookbaker.com collected 2026-10-02 21:43:35 UTC 19,130 bytes, 115 lines download raw bytes

1import{a as ne,d as te,g as ae,i as f,M as de,r as k,j as i,e,h as d,F as u,m as q,c as x,f as re,I as g}from"./index-c165adff.js";import{U as le}from"./UserSubscription-80dbcd3a.js";import{g as se}from"./referralCode-841c80ab.js";import{t as v}from"./formatters-0fbef5f5.js";import"./stripe-c37b0379.js";import"./index-332181d9.js";const ce={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"UserDetail"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"userDetail"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"email"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"userPublicProfile"},arguments:[{kind:"Argument",name:{kind:"Name",value:"slugOrId"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"slugs"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"slug"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"oldSlug"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"userSubscription"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"kind"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"userAffiliateDetails"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"stripeAccountId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"stripeActiveAt"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"userCreditAccountDetails"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"activeAccountId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"holdAccountId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"expenseAccountId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"active"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"hold"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"expense"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"userGiftCreditPacks"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"creditPackId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"friendlyCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"toEmail"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"userReferralCodes"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"code"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"discountPercent"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"deletedAt"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:758,source:{body:`
2  query UserDetail($id: String!) {
3    userDetail(id: $id) {
4      id
5      email
6      createdAt
7    }
8    userPublicProfile(slugOrId: $id) {
9      id
10      slugs {
11        slug
12        oldSlug
13      }
14    }
15    userSubscription(id: $id) {
16      id
17      kind
18    }
19    userAffiliateDetails(id: $id) {
20      id
21      stripeAccountId
22      stripeActiveAt
23    }
24    userCreditAccountDetails(id: $id) {
25      activeAccountId
26      holdAccountId
27      expenseAccountId
28      active
29      hold
30      expense
31    }
32    userGiftCreditPacks(id: $id) {
33      id
34      state
35      creditPackId
36      friendlyCode
37      toEmail
38      createdAt
39    }
40    userReferralCodes(id: $id) {
41      id
42      code
43      discountPercent
44      createdAt
45      deletedAt
46    }
47  }
48`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},oe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"UserReferralCodeEntries"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"userReferralCodeEntries"},arguments:[{kind:"Argument",name:{kind:"Name",value:"referralCodeId"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"purchasingUserId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"chargeAmount"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"deletedAt"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:193,source:{body:`
49  query UserReferralCodeEntries($id: String!) {
50    userReferralCodeEntries(referralCodeId: $id) {
51      id
52      purchasingUserId
53      chargeAmount
54      createdAt
55      deletedAt
56    }
57  }
58`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},ue={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpdateCreditAccountBalance"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UpdateCreditAccountBalanceInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"updateCreditAccountBalance"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[]}]}}],loc:{start:0,end:141,source:{body:`
59  mutation UpdateCreditAccountBalance(
60    $input: UpdateCreditAccountBalanceInput!
61  ) {
62    updateCreditAccountBalance(input: $input)
63  }
64`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},me={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateReferralCode"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"CreateReferralCodeInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createReferralCode"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:126,source:{body:`
65  mutation CreateReferralCode($input: CreateReferralCodeInput!) {
66    createReferralCode(input: $input) {
67      id
68    }
69  }
70`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},ke={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteReferralCode"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteReferralCode"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:100,source:{body:`
71  mutation DeleteReferralCode($id: String!) {
72    deleteReferralCode(id: $id) {
73      id
74    }
75  }
76`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},ve={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteUserAffiliate"}
76,variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteUserAffiliate"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[]}]}}],loc:{start:0,end:85,source:{body:`
77  mutation DeleteUserAffiliate($id: String!) {
78    deleteUserAffiliate(id: $id)
79  }
80`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},Ae=({id:r})=>{var L,B,G;const Q=r,{hasRole:H}=ne(),{navPopup:j,setNavPopup:I}=te(),{data:n,refetch:h}=ae(ce,{variables:{id:r}}),[Y,{loading:N}]=f(ue),[z,{loading:b}]=f(me),[J,{loading:U}]=f(ke),[K,{loading:W}]=f(ve),[X]=de(oe),[A,w]=k.useState("0"),[y,P]=k.useState(""),[C,V]=k.useState(""),[S,Z]=k.useState("5"),T=(n==null?void 0:n.userGiftCreditPacks)??[],$=(n==null?void 0:n.userReferralCodes)??[],M=(L=n==null?void 0:n.userPublicProfile.slugs)==null?void 0:L.slug,O=(B=n==null?void 0:n.userPublicProfile.slugs)==null?void 0:B.oldSlug,[ee,D]=k.useState(new Map);return i(u,{children:[j==="mod-user-subscription"&&e(le,{id:r,onClose:()=>{I(""),h()}}),e(re.Metadata,{title:"User Detail",description:"User Detail page"}),e("p",{children:e(d.Link,{to:d.routes.contentModUsers(),children:"< Back"})}),e("h1",{children:"User Detail"}),n&&i(u,{children:[i("h3",{children:["Email: ",n.userDetail.email||e("em",{children:"None"})]}),i("p",{children:["Id: ",e("code",{children:r})," (",e("code",{children:r.substr(-6)}),")"]}),i("p",{children:["Username:"," ",i("a",{target:"_blank",href:d.routes.userSlug({langCode:"en",userSlug:`@${M||r}`}),rel:"noreferrer",children:["@",M||e("em",{children:"None"})]}),O&&`, old username: @${O}`]}),((G=n.userAffiliateDetails)==null?void 0:G.id)&&e("p",{children:e("table",{children:i("tr",{children:[e("td",{style:{verticalAlign:"top"},children:"Affiliate:"}),i("td",{children:[e("code",{children:n.userAffiliateDetails.id}),n.userAffiliateDetails.stripeAccountId&&i(u,{children:[e("br",{}),e("code",{children:n.userAffiliateDetails.stripeAccountId})]}),n.userAffiliateDetails.stripeActiveAt&&i(u,{children:[e("br",{}),v(n.userAffiliateDetails.stripeActiveAt)]}),H("admin")&&i(u,{children:[e("br",{}),e("button",{disabled:W,type:"button",className:"btn btn-secondary",onClick:async()=>{if(!confirm("Are you sure you want to delete the affiliate account?"))return;const{data:{deleteUserAffiliate:t}}=await K({variables:{id:r}});t||alert("Failed to delete"),h()},children:"Delete"})]})]})]})})}),e("h2",{style:{marginTop:"40px"},children:"Credits"}),i("table",{className:"table-data",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Account"}),e("th",{children:"Balance"}),e("th",{children:"Description"})]})}),i("tbody",{children:[i("tr",{children:[e("td",{children:e(d.Link,{to:d.routes.contentModCreditEntry({id:n.userCreditAccountDetails.activeAccountId,back:d.routes.contentModUserDetail({id:r})}),children:"Active"})}),i("td",{children:[n.userCreditAccountDetails.active," credits"]}),e("td",{children:"How many credits the user sees in their account"})]}),i("tr",{children:[e("td",{children:e(d.Link,{to:d.routes.contentModCreditEntry({id:n.userCreditAccountDetails.holdAccountId,back:d.routes.contentModUserDetail({id:r})}),children:"Hold"})}),i("td",{children:[n.userCreditAccountDetails.hold," credits"]}),e("td",{children:"How many credits are in the process of being used"})]}),i("tr",{children:[e("td",{children:e(d.Link,{to:d.routes.contentModCreditEntry({id:n.userCreditAccountDetails.expenseAccountId,back:d.routes.contentModUserDetail({id:r})}),children:"Expense"})}),i("td",{children:[n.userCreditAccountDetails.expense," credits"]}),e("td",{children:"How many credits the user has spent (all time)"})]})]})]})]}),e("p",{children:e("button",{type:"button",className:"btn btn-secondary",onClick:()=>{I("mod-user-subscription")},children:"Buy Credit Packs"})}),i(q,{onSubmit:async()=>{const t=parseFloat(A);if(isNaN(t)){alert("Invalid amount");return}if(t===0)return;const{data:{updateCreditAccountBalance:a}}=await Y({variables:{input:{userId:r,amount:t,reason:y.trim()}}});h(),a==="success"?(w("0"),P("")):alert(`Failed to update account balance: ${a}`)},children:[e("p",{children:"Manually credit/debit user’s credits:"}),e("p",{children:"Do not adjust credits if refunding from stripe -- we do that automatically."}),i("div",{css:x`
81            display: flex;
82            flex-flow: row nowrap;
83            gap: 10px;
84
85            & > div {
86              line-height: 48px;
87            }
88
89            & > input {
90              max-width: 150px;
91
92              &.reason {
93                max-width: 300px;
94              }
95            }
96          `,children:[e("div",{children:"Amount:"}),e(g,{value:A,onInput:w,disabled:N}),e("div",{children:"Reason:"}),e(g,{value:y,onInput:P,disabled:N,className:"reason"}),e("button",{type:"submit",className:"btn btn-secondary",disabled:N||isNaN(parseFloat(A))||!y.trim(),children:"Apply"})]})]}),e("h2",{style:{marginTop:"40px"},children:"Referral Codes"}),i("table",{className:"table-data",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Code"}),e("th",{children:"Discount"}),e("th",{children:"Created At"}),e("th",{})]})}),i("tbody",{children:[$.length<=0&&e("tr",{children:e("td",{colSpan:4,children:e("p",{style:{margin:"20px",textAlign:"center"},children:"No results"})})}
96),$.map(({id:t,code:a,discountPercent:F,createdAt:R,deletedAt:m})=>{const s=ee.get(t),c=s==null?void 0:s.results,_=(s==null?void 0:s.loading)??!1;return i(k.Fragment,{children:[i("tr",{children:[e("td",{children:m?e("code",{style:{textDecoration:"line-through"},children:a}):e("a",{href:d.routes.setReferralCode({referral:a}),target:"_blank",rel:"noreferrer",children:e("code",{children:a})})}),i("td",{children:[F,"%"]}),i("td",{children:[v(R),m&&i(u,{children:[e("br",{}),"Deleted: ",v(m)]})]}),i("td",{children:[e("button",{type:"button",className:"btn btn-secondary",disabled:_||U,onClick:async()=>{if(c)D(p=>{const l=new Map(p);return l.delete(t),l});else{D(l=>{const o=new Map(l);return o.set(t,{loading:!0,results:[]}),o});const{data:{userReferralCodeEntries:p}}=await X({variables:{id:t}});D(l=>{const o=new Map(l);return o.set(t,{loading:!1,results:p}),o})}},children:"Entries"})," ",e("button",{type:"button",className:"btn btn-danger",disabled:U||m,onClick:async()=>{confirm(`Are you sure you want to delete the referral code?
97
98${a}`)&&(await J({variables:{id:t}}),h())},children:"Delete"})]})]}),c&&e("tr",{children:e("td",{colSpan:4,children:i("table",{className:"table-data",children:[e("thead",{children:i("tr",{children:[e("th",{children:"User"}),e("th",{children:"Charge Amount"}),e("th",{children:"Created At"})]})}),i("tbody",{children:[c.length<=0&&e("tr",{children:e("td",{colSpan:3,children:e("p",{style:{margin:"20px",textAlign:"center"},children:_?"Loading...":"No results"})})}),c.map(({id:p,purchasingUserId:l,chargeAmount:o,createdAt:ie,deletedAt:E})=>i("tr",{children:[e("td",{children:l===Q?"Myself":e("a",{target:"_blank",href:d.routes.contentModUserDetail({id:l}),rel:"noreferrer",children:e("code",{children:l.substr(-6)})})}),i("td",{style:E?{textDecoration:"line-through"}:void 0,children:["$",(o/100).toFixed(2)]}),i("td",{children:[v(ie),E&&i(u,{children:[e("br",{}),"Deleted: ",v(E)]})]})]},p))]})]})})})]},t)})]})]}),i(q,{css:x`
99          input[type='text'] {
100            display: inline-block;
101            width: 100px;
102          }
103        `,onSubmit:async()=>{try{await z({variables:{input:{userId:r,code:C,discountPercent:parseFloat(S)}}}),V(""),h()}catch{alert("Failed to create referral code. Is it already used somewhere else?")}},children:[e("p",{children:"Create referral code:"}),i("div",{css:x`
104            display: flex;
105            flex-flow: row nowrap;
106            gap: 10px;
107
108            & > div {
109              line-height: 48px;
110            }
111
112            & > input {
113              max-width: 150px;
114            }
115          `,children:[e("div",{children:"Code:"}),e(g,{value:C,onInput:V,disabled:b}),e("div",{children:"Discount (percent):"}),e(g,{value:S,onInput:Z,disabled:b}),e("button",{type:"submit",className:"btn btn-secondary",disabled:b||isNaN(parseFloat(S))||!C.trim(),children:"Add"})]})]}),e("h2",{style:{marginTop:"40px"},children:"Gift Cards"}),i("table",{className:"table-data",children:[e("thead",{children:i("tr",{children:[e("th",{children:"Status"}),e("th",{children:"Gift Code"}),e("th",{children:"Credits"}),e("th",{children:"Recipient"}),e("th",{children:"Purchase Date"})]})}),i("tbody",{children:[T.length<=0&&e("tr",{children:e("td",{colSpan:5,children:e("p",{style:{margin:"20px",textAlign:"center"},children:"No results"})})}),T.map(({id:t,state:a,friendlyCode:F,toEmail:R,creditPackId:m,createdAt:s})=>{var c;return i("tr",{children:[e("td",{children:a==="CREATED"?"Unpaid":a==="ERROR"?"Refunded/disputed":a==="PURCHASED"?"Paid (not redeemed)":a==="REDEEMED"?"Paid (redeemed)":a}),e("td",{children:e("code",{style:a!=="PURCHASED"?{opacity:.5}:void 0,children:F})}),e("td",{children:((c=se(m))==null?void 0:c.credits)??e("em",{children:"Unknown"})}),e("td",{children:R||e("em",{children:"No email provided"})}),e("td",{children:v(s)})]},t)})]})]})]})};export{Ae as default};

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.