@indietabletop/appkit 5.1.0 → 5.2.1
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.
- package/lib/account/JoinCard.tsx +8 -11
- package/lib/store/store.ts +27 -1
- package/package.json +1 -1
package/lib/account/JoinCard.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Form, useStoreState } from "@ariakit/react";
|
|
2
2
|
import { type Dispatch, type SetStateAction, useState } from "react";
|
|
3
|
-
import { Link
|
|
3
|
+
import { Link } from "wouter";
|
|
4
4
|
import { useAppConfig, useClient } from "../AppConfig/AppConfig.tsx";
|
|
5
5
|
import { cx } from "../class-names.ts";
|
|
6
6
|
import { interactiveText } from "../common.css.ts";
|
|
@@ -163,14 +163,7 @@ type SubmitCodeStepProps = {
|
|
|
163
163
|
|
|
164
164
|
function SubmitCodeStep(props: SubmitCodeStepProps) {
|
|
165
165
|
const { tokenId, email, setStep } = props;
|
|
166
|
-
const [_, navigate] = useLocation();
|
|
167
166
|
const client = useClient();
|
|
168
|
-
const redirectPath = useRedirectPath();
|
|
169
|
-
|
|
170
|
-
// Use redirect path if found in search params, otherwise go the success step.
|
|
171
|
-
const onSuccess = redirectPath
|
|
172
|
-
? () => navigate(redirectPath)
|
|
173
|
-
: () => setStep({ type: "SUCCESS" });
|
|
174
167
|
|
|
175
168
|
const { form, submitName } = useForm({
|
|
176
169
|
defaultValues: {
|
|
@@ -185,7 +178,9 @@ function SubmitCodeStep(props: SubmitCodeStepProps) {
|
|
|
185
178
|
});
|
|
186
179
|
});
|
|
187
180
|
},
|
|
188
|
-
onSuccess
|
|
181
|
+
onSuccess() {
|
|
182
|
+
setStep({ type: "SUCCESS" });
|
|
183
|
+
},
|
|
189
184
|
});
|
|
190
185
|
|
|
191
186
|
return (
|
|
@@ -218,6 +213,8 @@ function SubmitCodeStep(props: SubmitCodeStepProps) {
|
|
|
218
213
|
|
|
219
214
|
function SuccessStep() {
|
|
220
215
|
const { hrefs } = useAppConfig();
|
|
216
|
+
const redirectPath = useRedirectPath();
|
|
217
|
+
|
|
221
218
|
return (
|
|
222
219
|
<Letterhead>
|
|
223
220
|
<LetterheadHeader>
|
|
@@ -227,8 +224,8 @@ function SuccessStep() {
|
|
|
227
224
|
</LetterheadParagraph>
|
|
228
225
|
</LetterheadHeader>
|
|
229
226
|
|
|
230
|
-
<Link href={hrefs.dashboard()} {...cx(button())}>
|
|
231
|
-
Go to dashboard
|
|
227
|
+
<Link href={redirectPath ?? hrefs.dashboard()} {...cx(button())}>
|
|
228
|
+
{redirectPath ? "Continue" : "Go to dashboard"}
|
|
232
229
|
</Link>
|
|
233
230
|
</Letterhead>
|
|
234
231
|
);
|
package/lib/store/store.ts
CHANGED
|
@@ -206,11 +206,27 @@ const config = setup({
|
|
|
206
206
|
// Otherwise check that user IDs match.
|
|
207
207
|
return context.currentUser.id === event.currentUser.id;
|
|
208
208
|
},
|
|
209
|
+
|
|
210
|
+
hasBecomeEligibleForSync: and(["isNotMismatched", "hasBecomeVerified"]),
|
|
211
|
+
|
|
212
|
+
hasBecomeVerified: ({ event, context }) => {
|
|
213
|
+
assertEvent(event, "currentUser");
|
|
214
|
+
|
|
215
|
+
if (!context.currentUser) {
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// User was unverified previously, but now they are verified.
|
|
220
|
+
return (
|
|
221
|
+
context.currentUser.isVerified === false &&
|
|
222
|
+
event.currentUser.isVerified === true
|
|
223
|
+
);
|
|
224
|
+
},
|
|
209
225
|
},
|
|
210
226
|
});
|
|
211
227
|
|
|
212
228
|
export const machine = config.createMachine({
|
|
213
|
-
/** @xstate-layout N4IgpgJg5mDOIC5QEMAOqDEAnOYAuA2gAwC6ioqA9rAJZ42UB25IAHogLQBMRAbAHQBOQbwCMggOy8ALES7DRAGhABPTvIn8AzAA5B0rdN4BWCRKKDRvAL7XlaVPwCujZE7wALMI3oBjZHiQGL5OWDg+
|
|
229
|
+
/**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hTJjWDfuw2taNl3jalGkBFppA6e+c26tZpksiRFjzgCvpcFwP7QUU46CDoQH8sYR1yRxQ00BAfFgBg73-WiuX0usAh-sBghaOYZWFICUg-nR0HajDejAWjrmY9juPKQTapejkxRLbk7KDoawqAtmgi-tDxhLNBZljmzTUczjGA80m+EFGI2haDrZhyKKxZGr6SNaNrOvjkU2aiqIivPY+ADuyCzEeeMXWren0lIWRkwBFhIzyFQslkdE8DLXBTtmkqgpFT0nS9jvO8erCwJegRVtGgRYAAFKIO1EAAlBgj3HfJQ0J-QL5ZZ2hNzUUWTcrwMMSNBZEmYCpaaI3lN8PqPDAbaIKMJQEBwCwDjujXXrcDLQgiOIdNyAoOKrLUBjjloPDHFOlbggNpIT7zPa4sBEH6gObImBy+qQxUHBGDUueitmMhmufqMrjeUXBgf6vpAbTI6CIKYAC9RLK+jvlIFYa9zakUcu-KU-Uv4bkPGAQSUAaAACMcY-w9kCQy4ckZ4gUGRcQgIKbgRRpsM0RYmhR2LujGK+4cFEw1KOABQDyYRwppOZYMgtC6m1DIUUSNlwIKQnHR8Z0oDMPVOmIg7DgEU1ATicUi0+FwxkLBeCdDP6x1Li9KRnlvJHhkV6EQi0CEcJAbwbh+YCrbW1MtWQiMWIfxjiXDGBjFLnTGtI7KAMvT8jyPwIw1ReBskKFYaCFUjI6z4Pwng1DCq2wkXFbxrVYqQFMT2cQeJT4imECRIoAd6Sm34SYfUiMzDh3HDoFJ+jJHpP4NGJ2OMIDZPwokzQ9l5xHHgrnBaoEpy1DMCRGGMMRBmFEdHRBejPGPixtg-xk8ew5AKNoJmHIdDdw5LTRu2hdTimbsAsU9T5m7nLmhDp+kIbaE5Drfko4ii5D2VkcpRzhTAW5FoWwtggA */
|
|
214
230
|
id: "app",
|
|
215
231
|
context: () => createInitialContext(),
|
|
216
232
|
|
|
@@ -274,6 +290,16 @@ export const machine = config.createMachine({
|
|
|
274
290
|
|
|
275
291
|
on: {
|
|
276
292
|
currentUser: [
|
|
293
|
+
{
|
|
294
|
+
guard: "hasBecomeEligibleForSync",
|
|
295
|
+
target: "authenticated",
|
|
296
|
+
reenter: true,
|
|
297
|
+
|
|
298
|
+
actions: {
|
|
299
|
+
type: "setCurrentUser",
|
|
300
|
+
params: ({ event }) => event.currentUser,
|
|
301
|
+
},
|
|
302
|
+
},
|
|
277
303
|
{
|
|
278
304
|
guard: "isNotMismatched",
|
|
279
305
|
actions: {
|