@mercurjs/vendor 2.0.2 → 2.1.0-canary.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{[id]-DCCF7277.js → [id]-57VYN5YF.js} +2 -3
  2. package/dist/{[id]-UAOAQVEM.js → [id]-FWI6NCSF.js} +3 -4
  3. package/dist/{[id]-6WYSWXWC.js → [id]-IQNYVYZU.js} +1 -2
  4. package/dist/{[id]-LZPT5Y55.js → [id]-KCUHMQWF.js} +1 -2
  5. package/dist/{[id]-ENTJSLN2.js → [id]-KMRB5RAW.js} +3 -3
  6. package/dist/{[id]-PHS2WYFX.js → [id]-LCMQBEOS.js} +2 -3
  7. package/dist/{[id]-OGHRZ2VY.js → [id]-LJJPLKJ6.js} +5 -4
  8. package/dist/{[id]-VKG2WEIR.js → [id]-M3PNP527.js} +1 -2
  9. package/dist/{[id]-EJAHMOOE.js → [id]-MZOT4GAO.js} +2 -3
  10. package/dist/{[id]-TLZZ53G7.js → [id]-WYIWRY5O.js} +2 -2
  11. package/dist/{[province_id]-XGA44S7P.js → [province_id]-2MRNXHKU.js} +1 -2
  12. package/dist/{add-7ZTE42IE.js → add-RDOKD6CX.js} +2 -2
  13. package/dist/{add-AKC7LTK3.js → add-W7ATBCKS.js} +2 -3
  14. package/dist/{add-customer-groups-BRC3DKQ2.js → add-customer-groups-ZZVSJJH3.js} +1 -2
  15. package/dist/{add-products-ZSULNZVI.js → add-products-PINICUAZ.js} +2 -3
  16. package/dist/{add-promotions-TNFVT5ST.js → add-promotions-W57766OG.js} +3 -3
  17. package/dist/{address-3DSJESKM.js → address-MQS4I2N6.js} +58 -71
  18. package/dist/{breadcrumb-ZMVHXCOX.js → breadcrumb-A3XUO3R2.js} +2 -3
  19. package/dist/{breadcrumb-UH7FAYU2.js → breadcrumb-MPXARU5F.js} +1 -2
  20. package/dist/{breadcrumb-D6QNYOAO.js → breadcrumb-Q5KJBAPD.js} +1 -2
  21. package/dist/{chunk-CUMY2VZ5.js → chunk-5LKZCG77.js} +1 -96
  22. package/dist/{chunk-7XC7ZRG7.js → chunk-5VBEGZ5W.js} +1 -1
  23. package/dist/{chunk-573EQEW2.js → chunk-6HPF5UZA.js} +1 -1
  24. package/dist/{chunk-RV5UTYBG.js → chunk-EQQ3BLQ3.js} +2 -2
  25. package/dist/{chunk-LA6XSPQG.js → chunk-FI2RBY7M.js} +287 -309
  26. package/dist/{chunk-RMBCBXWD.js → chunk-GQFNE5VL.js} +1 -1
  27. package/dist/chunk-HFRHHT36.js +98 -0
  28. package/dist/{chunk-O7E4KQAK.js → chunk-I4F7UYZE.js} +1 -1
  29. package/dist/chunk-JWB2HSCJ.js +30 -0
  30. package/dist/{chunk-FNG7ZA7N.js → chunk-NCQBAHWT.js} +1 -1
  31. package/dist/{chunk-T7LEJIIM.js → chunk-PT3UQCSN.js} +1 -1
  32. package/dist/chunk-TLE6YHGH.js +26 -0
  33. package/dist/{chunk-JRT2U4UI.js → chunk-TRKJKAM6.js} +130 -33
  34. package/dist/{chunk-ASEVHHCT.js → chunk-UDG47AEE.js} +1 -1
  35. package/dist/{chunk-XZG2HZYW.js → chunk-WFE6CT6M.js} +1 -1
  36. package/dist/{chunk-N2WKLVUX.js → chunk-XF3W2U3Q.js} +1 -1
  37. package/dist/{chunk-JKKRKFCS.js → chunk-YPSJN3XT.js} +29 -32
  38. package/dist/{chunk-NYRRRCJS.js → chunk-ZCJ737TR.js} +66 -21
  39. package/dist/{collections-2M4RFH4P.js → collections-NNFGWUTW.js} +2 -3
  40. package/dist/{create-D4F457BD.js → create-GCSVAMEH.js} +1 -2
  41. package/dist/{create-2TUWGQ2D.js → create-N3WNCW7U.js} +1 -2
  42. package/dist/{create-QK2SSLZK.js → create-T73PSKIV.js} +3 -4
  43. package/dist/{create-OF2OZ7EI.js → create-TXBY6W3X.js} +1 -2
  44. package/dist/{create-6IRE6AMF.js → create-V3TFI4BJ.js} +8 -7
  45. package/dist/{create-IFMEEHN4.js → create-VPG7P53M.js} +2 -3
  46. package/dist/{create-YITFTHMA.js → create-WY4KXB66.js} +1 -2
  47. package/dist/{create-3WUTLUJO.js → create-YCOR6HY3.js} +1 -2
  48. package/dist/{edit-SGEECDCR.js → edit-2QUFOE5S.js} +1 -2
  49. package/dist/{edit-UQAQVEUI.js → edit-62WJ7SBJ.js} +27 -10
  50. package/dist/{edit-QRJIWTU2.js → edit-B245OLC7.js} +1 -2
  51. package/dist/{edit-PIE7Y73J.js → edit-CPVFMQEI.js} +3 -4
  52. package/dist/{edit-ONSN756P.js → edit-F4F6EQDZ.js} +1 -1
  53. package/dist/{edit-Z7EZRPUP.js → edit-JGBH64CC.js} +1 -1
  54. package/dist/{edit-J5SC7GHQ.js → edit-KWSXWWOA.js} +1 -2
  55. package/dist/{edit-ZEIL7EQW.js → edit-QYKH2ZZA.js} +1 -2
  56. package/dist/{edit-stocks-and-prices-543AYFDJ.js → edit-stocks-and-prices-Y233WVZ3.js} +1 -2
  57. package/dist/{fulfillment-5LNFBSBS.js → fulfillment-FBF3MITY.js} +1 -2
  58. package/dist/{fulfillment-providers-U7Z7QMOQ.js → fulfillment-providers-Y2YOREHX.js} +2 -3
  59. package/dist/index.css +35 -29
  60. package/dist/index.js +86 -87
  61. package/dist/invite-G7WOO5RZ.js +368 -0
  62. package/dist/{invite-SI2KIPWI.js → invite-Y2TACGCW.js} +3 -5
  63. package/dist/{login-QDS5UXKV.js → login-3U4XGDAD.js} +3 -3
  64. package/dist/{media-RDXCLPKQ.js → media-O2GIGGFG.js} +2 -2
  65. package/dist/{metadata-7JKDCVYY.js → metadata-7RA6MXW7.js} +1 -2
  66. package/dist/{metadata-ZV5RYLKR.js → metadata-GSBDSRNM.js} +1 -2
  67. package/dist/{metadata-X4UIPNL6.js → metadata-JXRXW6UQ.js} +1 -2
  68. package/dist/{metadata-W5XIPFVU.js → metadata-QM4UGMX5.js} +1 -2
  69. package/dist/{metadata-UKBRUFH2.js → metadata-RODKLIDO.js} +1 -2
  70. package/dist/onboarding-7XHOLSKH.js +943 -0
  71. package/dist/{orders-IAL3JNPU.js → orders-HKUVFCTQ.js} +2 -3
  72. package/dist/pages/index.d.ts +140 -140
  73. package/dist/pages/index.js +16 -14
  74. package/dist/{payment-details-ATUYMVJX.js → payment-details-VWR2S32W.js} +1 -2
  75. package/dist/{pricing-RBESFX5P.js → pricing-6UZ6SXIE.js} +1 -2
  76. package/dist/{product-tags-W4BL6RWV.js → product-tags-YXVFIPGQ.js} +3 -4
  77. package/dist/{product-variant-detail-KU5OCL7E.js → product-variant-detail-O2NOUFFC.js} +1 -2
  78. package/dist/{products-3VVYJUH7.js → products-3NIIOQBB.js} +2 -3
  79. package/dist/{products-YYLVCOOY.js → products-T2EMLRXQ.js} +10 -9
  80. package/dist/{professional-details-6Y5K6GBL.js → professional-details-SJ4AF5TM.js} +1 -2
  81. package/dist/{promotions-NBJTFP6N.js → promotions-ZEH4RHL3.js} +4 -4
  82. package/dist/register-4SX23YPM.js +210 -0
  83. package/dist/{reset-password-PLCDLFL4.js → reset-password-4LWDUVMH.js} +1 -1
  84. package/dist/{sales-channels-UIDLFCX6.js → sales-channels-2OVI6RTV.js} +3 -2
  85. package/dist/{sales-channels-UWPEFKAO.js → sales-channels-BKOYQXVC.js} +3 -2
  86. package/dist/{settings-5MNWE5CR.js → settings-F6KJREHK.js} +3 -4
  87. package/dist/{shipping-profiles-O7XB2DTE.js → shipping-profiles-AQMJSXDB.js} +1 -2
  88. package/dist/{stock-VJAAYYW5.js → stock-4G4WQIR7.js} +1 -2
  89. package/dist/{stock-2CGEFBXO.js → stock-NJADHNRP.js} +1 -2
  90. package/dist/{store-ZBSMNWFT.js → store-E4JEK2CQ.js} +220 -118
  91. package/dist/{store-closure-43FK32AQ.js → store-closure-QPK4LBBZ.js} +35 -19
  92. package/dist/{store-select-Q2HE572R.js → store-select-XPC6NIV5.js} +31 -22
  93. package/dist/{team-ZLZJJWIY.js → team-DZ5CV3LG.js} +1 -2
  94. package/package.json +5 -5
  95. package/dist/chunk-STBCWNZQ.js +0 -57
  96. package/dist/invite-P6HTOEIV.js +0 -301
  97. package/dist/onboarding-DLIBZRKE.js +0 -873
  98. package/dist/register-ZLE6MNPF.js +0 -223
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  require_dist
3
3
  } from "./chunk-ZZO3INVE.js";
4
+ import {
5
+ AuthLayout
6
+ } from "./chunk-JWB2HSCJ.js";
4
7
  import {
5
8
  AvatarBox
6
9
  } from "./chunk-CP5IL4P6.js";
@@ -8,8 +11,7 @@ import "./chunk-U2EI2ZLM.js";
8
11
  import {
9
12
  useSelectSeller,
10
13
  useSellers
11
- } from "./chunk-NYRRRCJS.js";
12
- import "./chunk-STBCWNZQ.js";
14
+ } from "./chunk-ZCJ737TR.js";
13
15
  import "./chunk-F4OJN2F2.js";
14
16
  import "./chunk-LRARA622.js";
15
17
  import "./chunk-M6N4ISXL.js";
@@ -38,12 +40,13 @@ import {
38
40
  } from "./chunk-NBMM2TZK.js";
39
41
 
40
42
  // src/pages/store-select/store-select.tsx
43
+ import { Children } from "react";
41
44
  import { ChevronRight, Plus, Spinner } from "@medusajs/icons";
42
45
  import { Avatar, Heading, StatusBadge, Text } from "@medusajs/ui";
43
46
  import { useTranslation } from "react-i18next";
44
47
  import { useLocation, useNavigate } from "react-router-dom";
45
48
  var import_types = __toESM(require_dist(), 1);
46
- import { jsx, jsxs } from "react/jsx-runtime";
49
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
47
50
  var getSellerStatusBadge = (status, t) => {
48
51
  switch (status) {
49
52
  case import_types.SellerStatus.OPEN:
@@ -56,7 +59,7 @@ var getSellerStatusBadge = (status, t) => {
56
59
  case import_types.SellerStatus.SUSPENDED:
57
60
  return { color: "red", label: t("storeSelect.status.suspended") };
58
61
  case import_types.SellerStatus.TERMINATED:
59
- return { color: "grey", label: t("storeSelect.status.terminated") };
62
+ return null;
60
63
  default:
61
64
  return { color: "grey", label: status };
62
65
  }
@@ -66,9 +69,9 @@ var StoreSelectLogo = () => {
66
69
  };
67
70
  var StoreSelectHeader = () => {
68
71
  const { t } = useTranslation();
69
- return /* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-col items-center", children: [
72
+ return /* @__PURE__ */ jsxs("div", { className: "mb-6 flex flex-col", children: [
70
73
  /* @__PURE__ */ jsx(Heading, { children: t("storeSelect.title") }),
71
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle text-center", children: t("storeSelect.subtitle") })
74
+ /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: t("storeSelect.subtitle") })
72
75
  ] });
73
76
  };
74
77
  var StoreSelectList = ({
@@ -83,7 +86,7 @@ var StoreSelectList = ({
83
86
  navigate("/", { replace: true });
84
87
  };
85
88
  return /* @__PURE__ */ jsxs("div", { className: "shadow-elevation-card-rest bg-ui-bg-base flex w-full flex-col divide-y rounded-lg", children: [
86
- seller_members?.map((member) => {
89
+ seller_members?.filter((member) => member.seller.status !== import_types.SellerStatus.TERMINATED).map((member) => {
87
90
  const seller = member.seller;
88
91
  const badge = getSellerStatusBadge(seller.status, t);
89
92
  return /* @__PURE__ */ jsxs(
@@ -97,22 +100,26 @@ var StoreSelectList = ({
97
100
  {
98
101
  variant: "squared",
99
102
  size: "small",
103
+ src: seller.logo || void 0,
100
104
  fallback: seller.name.charAt(0).toUpperCase()
101
105
  }
102
106
  ),
103
107
  /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col items-start", children: [
104
108
  /* @__PURE__ */ jsx(Text, { size: "small", weight: "plus", leading: "compact", children: seller.name }),
105
- /* @__PURE__ */ jsx(
109
+ seller.handle ? /* @__PURE__ */ jsxs(
106
110
  Text,
107
111
  {
108
112
  size: "xsmall",
109
113
  className: "text-ui-fg-subtle",
110
114
  leading: "compact",
111
- children: seller.handle
115
+ children: [
116
+ "/",
117
+ seller.handle
118
+ ]
112
119
  }
113
- )
120
+ ) : null
114
121
  ] }),
115
- /* @__PURE__ */ jsx(StatusBadge, { color: badge.color, children: badge.label }),
122
+ badge ? /* @__PURE__ */ jsx(StatusBadge, { color: badge.color, children: badge.label }) : null,
116
123
  /* @__PURE__ */ jsx(ChevronRight, { className: "text-ui-fg-muted" })
117
124
  ]
118
125
  },
@@ -135,23 +142,25 @@ var StoreSelectList = ({
135
142
  var StoreSelectFooter = () => {
136
143
  return null;
137
144
  };
138
- var Root = () => {
145
+ var Root = ({ children }) => {
139
146
  const location = useLocation();
140
147
  const email = location.state?.email ?? "";
141
148
  const { seller_members, isLoading } = useSellers();
142
149
  if (isLoading) {
143
- return /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, { className: "text-ui-fg-muted animate-spin" }) });
150
+ return /* @__PURE__ */ jsx(AuthLayout, { children: /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ jsx(Spinner, { className: "text-ui-fg-muted animate-spin" }) }) });
144
151
  }
145
- return /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "flex w-[380px] flex-col items-center", children: [
152
+ return /* @__PURE__ */ jsx(AuthLayout, { children: Children.count(children) > 0 ? children : /* @__PURE__ */ jsxs(Fragment, { children: [
146
153
  /* @__PURE__ */ jsx(StoreSelectLogo, {}),
147
- /* @__PURE__ */ jsx(StoreSelectHeader, {}),
148
- /* @__PURE__ */ jsx(
149
- StoreSelectList,
150
- {
151
- seller_members: seller_members ?? [],
152
- email
153
- }
154
- ),
154
+ /* @__PURE__ */ jsxs("div", { className: "mt-8", children: [
155
+ /* @__PURE__ */ jsx(StoreSelectHeader, {}),
156
+ /* @__PURE__ */ jsx(
157
+ StoreSelectList,
158
+ {
159
+ seller_members: seller_members ?? [],
160
+ email
161
+ }
162
+ )
163
+ ] }),
155
164
  /* @__PURE__ */ jsx(StoreSelectFooter, {})
156
165
  ] }) });
157
166
  };
@@ -34,8 +34,7 @@ import {
34
34
  useMe,
35
35
  useRemoveSellerMember,
36
36
  useSellerMembers
37
- } from "./chunk-NYRRRCJS.js";
38
- import "./chunk-STBCWNZQ.js";
37
+ } from "./chunk-ZCJ737TR.js";
39
38
  import "./chunk-F4OJN2F2.js";
40
39
  import "./chunk-LRARA622.js";
41
40
  import "./chunk-M6N4ISXL.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercurjs/vendor",
3
- "version": "2.0.2",
3
+ "version": "2.1.0-canary.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mercurjs/mercur",
@@ -29,8 +29,8 @@
29
29
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
30
30
  },
31
31
  "dependencies": {
32
- "@mercurjs/dashboard-shared": "2.0.0-canary.97",
33
- "@mercurjs/client": "2.0.0-canary.97",
32
+ "@mercurjs/dashboard-shared": "2.1.0-canary.5",
33
+ "@mercurjs/client": "2.1.0-canary.5",
34
34
  "@ariakit/react": "^0.4.15",
35
35
  "@babel/runtime": "^7.26.10",
36
36
  "@dnd-kit/core": "^6.1.0",
@@ -83,8 +83,8 @@
83
83
  "tsup": "^8.0.2",
84
84
  "typescript": "5.9.3",
85
85
  "@medusajs/types": "2.13.4",
86
- "@mercurjs/core-plugin": "workspace:*",
86
+ "@mercurjs/core": "workspace:*",
87
87
  "@mercurjs/dashboard-sdk": "workspace:*",
88
88
  "@mercurjs/types": "workspace:*"
89
89
  }
90
- }
90
+ }
@@ -1,57 +0,0 @@
1
- import {
2
- queryClient
3
- } from "./chunk-RHKRREUU.js";
4
- import {
5
- queryKeysFactory
6
- } from "./chunk-ZA2KFUFR.js";
7
- import {
8
- sdk
9
- } from "./chunk-RIN4CBRB.js";
10
-
11
- // src/hooks/api/invites.tsx
12
- import {
13
- useMutation,
14
- useQuery
15
- } from "@tanstack/react-query";
16
- var INVITES_QUERY_KEY = "invites";
17
- var invitesQueryKeys = queryKeysFactory(INVITES_QUERY_KEY);
18
- var useInvites = (sellerId, query, options) => {
19
- const { data, ...rest } = useQuery({
20
- queryFn: () => sdk.vendor.sellers.$id.members.invites.query({
21
- $id: sellerId,
22
- ...query
23
- }),
24
- queryKey: invitesQueryKeys.list({ sellerId, ...query }),
25
- ...options
26
- });
27
- return { ...data, ...rest };
28
- };
29
- var useAcceptInvite = (options) => {
30
- return useMutation({
31
- mutationFn: (payload) => sdk.vendor.members.invites.accept.mutate({
32
- invite_token: payload.invite_token,
33
- fetchOptions: {
34
- headers: {
35
- Authorization: `Bearer ${payload.auth_token}`
36
- }
37
- }
38
- }),
39
- ...options
40
- });
41
- };
42
- var useCreateInvite = (sellerId, options) => {
43
- return useMutation({
44
- mutationFn: (payload) => sdk.vendor.sellers.$id.members.mutate({ $id: sellerId, ...payload }),
45
- onSuccess: (data, variables, context) => {
46
- queryClient.invalidateQueries({ queryKey: invitesQueryKeys.lists() });
47
- options?.onSuccess?.(data, variables, context);
48
- },
49
- ...options
50
- });
51
- };
52
-
53
- export {
54
- useInvites,
55
- useAcceptInvite,
56
- useCreateInvite
57
- };
@@ -1,301 +0,0 @@
1
- import {
2
- AvatarBox
3
- } from "./chunk-CP5IL4P6.js";
4
- import {
5
- isFetchError
6
- } from "./chunk-C6SUTRP2.js";
7
- import {
8
- Form
9
- } from "./chunk-3QSRE5LS.js";
10
- import "./chunk-U2EI2ZLM.js";
11
- import {
12
- useAcceptInvite
13
- } from "./chunk-STBCWNZQ.js";
14
- import {
15
- useSignInForInvite,
16
- useSignUpForInvite
17
- } from "./chunk-F4OJN2F2.js";
18
- import "./chunk-RHKRREUU.js";
19
- import "./chunk-ZA2KFUFR.js";
20
- import "./chunk-RIN4CBRB.js";
21
- import "./chunk-NBMM2TZK.js";
22
-
23
- // src/pages/invite/invite.tsx
24
- import { zodResolver } from "@hookform/resolvers/zod";
25
- import { Alert, Button, Heading, Hint, Input, Text, toast } from "@medusajs/ui";
26
- import i18n from "i18next";
27
- import { AnimatePresence, motion } from "motion/react";
28
- import { useState } from "react";
29
- import { useForm } from "react-hook-form";
30
- import { useTranslation } from "react-i18next";
31
- import { decodeToken } from "react-jwt";
32
- import { Link, useSearchParams } from "react-router-dom";
33
- import * as z from "zod";
34
- import { jsx, jsxs } from "react/jsx-runtime";
35
- var CreateAccountSchema = z.object({
36
- email: z.string().email(),
37
- password: z.string().min(1),
38
- repeat_password: z.string().optional(),
39
- existing_member: z.boolean()
40
- }).superRefine(({ password, repeat_password, existing_member }, ctx) => {
41
- if (!existing_member && (!repeat_password || password !== repeat_password)) {
42
- ctx.addIssue({
43
- code: z.ZodIssueCode.custom,
44
- message: i18n.t("invite.passwordMismatch"),
45
- path: ["repeat_password"]
46
- });
47
- }
48
- });
49
- var Invite = () => {
50
- const [searchParams] = useSearchParams();
51
- const [success, setSuccess] = useState(false);
52
- const token = searchParams.get("token");
53
- const invite = token ? decodeToken(token) : null;
54
- const isValidInvite = invite && validateDecodedInvite(invite);
55
- return /* @__PURE__ */ jsx("div", { className: "bg-ui-bg-subtle relative flex min-h-dvh w-dvw items-center justify-center p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full max-w-[360px] flex-col items-center", children: [
56
- /* @__PURE__ */ jsx(AvatarBox, { checked: success }),
57
- /* @__PURE__ */ jsx("div", { className: "w-full will-change-contents", children: isValidInvite ? /* @__PURE__ */ jsx(AnimatePresence, { children: !success ? /* @__PURE__ */ jsx(
58
- motion.div,
59
- {
60
- initial: false,
61
- animate: { y: 0 },
62
- exit: { height: 0, y: 40 },
63
- transition: {
64
- duration: 0.8,
65
- delay: 0.6,
66
- ease: [0, 0.71, 0.2, 1.01]
67
- },
68
- className: "w-full will-change-transform",
69
- children: /* @__PURE__ */ jsx(
70
- motion.div,
71
- {
72
- initial: false,
73
- animate: { opacity: 1, scale: 1 },
74
- exit: { opacity: 0, scale: 0.7 },
75
- transition: {
76
- duration: 0.6,
77
- delay: 0,
78
- ease: [0, 0.71, 0.2, 1.01]
79
- },
80
- children: /* @__PURE__ */ jsx(
81
- CreateView,
82
- {
83
- onSuccess: () => setSuccess(true),
84
- token,
85
- invite
86
- }
87
- )
88
- },
89
- "inner-create-account"
90
- )
91
- },
92
- "create-account"
93
- ) : /* @__PURE__ */ jsx(
94
- motion.div,
95
- {
96
- initial: { opacity: 0, scale: 0.4 },
97
- animate: { opacity: 1, scale: 1 },
98
- transition: {
99
- duration: 1,
100
- delay: 0.6,
101
- ease: [0, 0.71, 0.2, 1.01]
102
- },
103
- className: "w-full",
104
- children: /* @__PURE__ */ jsx(SuccessView, { sellerName: invite.seller_name })
105
- },
106
- "success-view"
107
- ) }) : /* @__PURE__ */ jsx(InvalidView, {}) })
108
- ] }) });
109
- };
110
- var LoginLink = () => {
111
- const { t } = useTranslation();
112
- return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center", children: [
113
- /* @__PURE__ */ jsx("div", { className: "my-6 h-px w-full border-b border-dotted" }),
114
- /* @__PURE__ */ jsx(
115
- Link,
116
- {
117
- to: "/login",
118
- className: "txt-small text-ui-fg-base transition-fg hover:text-ui-fg-base-hover focus-visible:text-ui-fg-base-hover font-medium outline-none",
119
- children: t("invite.backToLogin")
120
- }
121
- )
122
- ] });
123
- };
124
- var InvalidView = () => {
125
- const { t } = useTranslation();
126
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center", children: [
127
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-1", children: [
128
- /* @__PURE__ */ jsx(Heading, { children: t("invite.invalidTokenTitle") }),
129
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle text-center", children: t("invite.invalidTokenHint") })
130
- ] }),
131
- /* @__PURE__ */ jsx(LoginLink, {})
132
- ] });
133
- };
134
- var CreateView = ({
135
- onSuccess,
136
- token,
137
- invite
138
- }) => {
139
- const { t } = useTranslation();
140
- const [invalid, setInvalid] = useState(false);
141
- const isExistingMember = invite.existing_member;
142
- const form = useForm({
143
- resolver: zodResolver(CreateAccountSchema),
144
- defaultValues: {
145
- email: invite.email || "",
146
- password: "",
147
- repeat_password: "",
148
- existing_member: isExistingMember
149
- }
150
- });
151
- const { mutateAsync: signUp, isPending: isCreatingAuthUser } = useSignUpForInvite();
152
- const { mutateAsync: signIn, isPending: isSigningIn } = useSignInForInvite();
153
- const { mutateAsync: acceptInvite, isPending: isAcceptingInvite } = useAcceptInvite();
154
- const handleSubmit = form.handleSubmit(async (data) => {
155
- try {
156
- const { token: authToken } = isExistingMember ? await signIn({
157
- email: data.email,
158
- password: data.password
159
- }) : await signUp({
160
- email: data.email,
161
- password: data.password
162
- });
163
- await acceptInvite({
164
- invite_token: token,
165
- auth_token: authToken
166
- });
167
- toast.success(t("invite.toast.accepted"));
168
- onSuccess();
169
- } catch (error) {
170
- if (isFetchError(error)) {
171
- if (error.status === 401) {
172
- form.setError("root", {
173
- type: "manual",
174
- message: t("errors.invalidCredentials")
175
- });
176
- return;
177
- }
178
- if (error.status === 400) {
179
- form.setError("root", {
180
- type: "manual",
181
- message: t("invite.invalidInvite")
182
- });
183
- setInvalid(true);
184
- return;
185
- }
186
- }
187
- form.setError("root", {
188
- type: "manual",
189
- message: t("errors.serverError")
190
- });
191
- }
192
- });
193
- const serverError = form.formState.errors.root?.message;
194
- const validationError = form.formState.errors.email?.message || form.formState.errors.password?.message || form.formState.errors.repeat_password?.message;
195
- return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center", children: [
196
- /* @__PURE__ */ jsxs("div", { className: "mb-4 flex flex-col items-center", children: [
197
- /* @__PURE__ */ jsx(Heading, { children: t("invite.title", {
198
- name: invite.seller_name
199
- }) }),
200
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle text-center", children: isExistingMember ? t("invite.existingMemberHint") : t("invite.hint") })
201
- ] }),
202
- /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, className: "flex w-full flex-col gap-y-6", children: [
203
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
204
- /* @__PURE__ */ jsx(
205
- Form.Field,
206
- {
207
- control: form.control,
208
- name: "email",
209
- render: ({ field }) => /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
210
- Input,
211
- {
212
- autoComplete: "off",
213
- ...field,
214
- className: "bg-ui-bg-field-component",
215
- placeholder: t("fields.email"),
216
- disabled: true
217
- }
218
- ) }) })
219
- }
220
- ),
221
- /* @__PURE__ */ jsx(
222
- Form.Field,
223
- {
224
- control: form.control,
225
- name: "password",
226
- render: ({ field }) => /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
227
- Input,
228
- {
229
- autoComplete: "new-password",
230
- type: "password",
231
- ...field,
232
- className: "bg-ui-bg-field-component",
233
- placeholder: t("fields.password")
234
- }
235
- ) }) })
236
- }
237
- ),
238
- !isExistingMember && /* @__PURE__ */ jsx(
239
- Form.Field,
240
- {
241
- control: form.control,
242
- name: "repeat_password",
243
- render: ({ field }) => /* @__PURE__ */ jsx(Form.Item, { children: /* @__PURE__ */ jsx(Form.Control, { children: /* @__PURE__ */ jsx(
244
- Input,
245
- {
246
- autoComplete: "off",
247
- type: "password",
248
- ...field,
249
- className: "bg-ui-bg-field-component",
250
- placeholder: t("fields.repeatPassword")
251
- }
252
- ) }) })
253
- }
254
- ),
255
- validationError && /* @__PURE__ */ jsx("div", { className: "mt-6 text-center", children: /* @__PURE__ */ jsx(Hint, { className: "inline-flex", variant: "error", children: validationError }) }),
256
- serverError && /* @__PURE__ */ jsx(
257
- Alert,
258
- {
259
- className: "bg-ui-bg-base items-center p-2",
260
- dismissible: true,
261
- variant: "error",
262
- children: serverError
263
- }
264
- )
265
- ] }),
266
- /* @__PURE__ */ jsx(
267
- Button,
268
- {
269
- className: "w-full",
270
- type: "submit",
271
- isLoading: isCreatingAuthUser || isSigningIn || isAcceptingInvite,
272
- disabled: invalid,
273
- children: isExistingMember ? t("invite.signIn") : t("invite.createAccount")
274
- }
275
- )
276
- ] }) }),
277
- /* @__PURE__ */ jsx(LoginLink, {})
278
- ] });
279
- };
280
- var SuccessView = ({ sellerName }) => {
281
- const { t } = useTranslation();
282
- return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col items-center gap-y-6", children: [
283
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-y-1", children: [
284
- /* @__PURE__ */ jsx(Heading, { className: "text-center", children: t("invite.successTitle", { name: sellerName }) }),
285
- /* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle text-center", children: t("invite.successHint") })
286
- ] }),
287
- /* @__PURE__ */ jsx(Button, { variant: "secondary", asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(Link, { to: "/login", replace: true, children: t("invite.backToLogin") }) })
288
- ] });
289
- };
290
- var InviteSchema = z.object({
291
- id: z.string(),
292
- jti: z.string(),
293
- exp: z.number(),
294
- iat: z.number()
295
- });
296
- var validateDecodedInvite = (decoded) => {
297
- return InviteSchema.safeParse(decoded).success;
298
- };
299
- export {
300
- Invite as Component
301
- };