From c57fe849b4f21af39c600fda166cb970b124a0e8 Mon Sep 17 00:00:00 2001 From: Clark Sell Date: Mon, 12 Sep 2022 14:02:58 -0500 Subject: [PATCH 1/3] feat: adds claim ticket --- package-lock.json | 83 +++---- package.json | 4 +- src/_components/activities/UpNext.svelte | 2 +- src/_components/nav/Cart.svelte | 20 +- src/_components/nav/ClaimCart.svelte | 20 ++ src/_components/nav/UserProfile.svelte | 2 +- src/_components/nav/interiorNav/Large.svelte | 44 ++-- src/_components/nav/interiorNav/Mobile.svelte | 10 + src/_components/nav/mainNav/Desktop.svelte | 34 ++- src/_components/nav/mainNav/Mobile.svelte | 11 +- .../api.that.tech/orders/mutations.js | 42 +++- src/_elements/buttons/Standard.svelte | 2 +- src/_elements/svgs/Ticket.svelte | 2 +- src/_utils/cart/cartConfig.js | 1 + src/_utils/cart/cartMachine.js | 22 +- src/_utils/cart/index.js | 5 +- src/_utils/claimTicket/config.js | 100 +++++++++ src/_utils/claimTicket/index.js | 10 + src/_utils/claimTicket/machine.js | 101 +++++++++ src/_utils/useMachine.js | 3 +- src/routes/__layout.svelte | 2 + .../activities/[state]/[year]/index.svelte | 2 +- src/routes/activities/index.svelte | 2 +- src/routes/communities/index.svelte | 2 +- .../events/[event]/[date]/tickets.svelte | 1 + src/routes/events/_components/_Hybrid.svelte | 2 + src/routes/events/_components/_Online.svelte | 22 +- .../_components/online/_EventTicket.svelte | 212 ++++++++++++------ .../_components/online/_OnlineHero.svelte | 2 +- .../events/_components/schedule/List.svelte | 2 +- src/routes/index.svelte | 2 +- src/routes/join/[activityId]/index.svelte | 4 +- src/routes/members/_components/upNext.svelte | 2 +- src/routes/members/index.svelte | 2 +- src/routes/membership/index.svelte | 2 +- src/routes/my/settings/order-history.svelte | 2 +- src/routes/orders/__layout-orders.svelte | 20 ++ src/routes/orders/_components/_Cart.svelte | 6 + .../orders/_components/_CartItem.svelte | 11 +- .../orders/_components/_ClaimCart.svelte | 75 +++++++ .../{_Steps.svelte => _Prerequisites.svelte} | 79 ++----- .../_machines/{steps.js => prerequisites.js} | 21 +- .../orders/_machines/prerequisitesConfig.js | 86 +++++++ src/routes/orders/_machines/stepsConfig.js | 78 ------- src/routes/orders/_machines/summary.js | 39 ---- src/routes/orders/_machines/summaryConfig.js | 45 ---- .../index.svelte} | 0 src/routes/orders/claim@orders.svelte | 26 +++ src/routes/orders/success/__layout.svelte | 7 - src/routes/orders/success/claim-ticket.svelte | 46 ++++ src/routes/orders/summary.svelte | 54 ----- src/routes/orders/summary@orders.svelte | 26 +++ src/routes/partners/[partner]/index.svelte | 2 +- .../partners/_components/_Followers.svelte | 2 +- src/routes/promo/index.svelte | 1 + src/routes/speakers/accept/index.svelte | 2 +- 56 files changed, 908 insertions(+), 499 deletions(-) create mode 100644 src/_components/nav/ClaimCart.svelte create mode 100644 src/_utils/claimTicket/config.js create mode 100644 src/_utils/claimTicket/index.js create mode 100644 src/_utils/claimTicket/machine.js create mode 100644 src/routes/orders/__layout-orders.svelte create mode 100644 src/routes/orders/_components/_ClaimCart.svelte rename src/routes/orders/_components/{_Steps.svelte => _Prerequisites.svelte} (70%) rename src/routes/orders/_machines/{steps.js => prerequisites.js} (59%) create mode 100644 src/routes/orders/_machines/prerequisitesConfig.js delete mode 100644 src/routes/orders/_machines/stepsConfig.js delete mode 100644 src/routes/orders/_machines/summary.js delete mode 100644 src/routes/orders/_machines/summaryConfig.js rename src/routes/orders/{canceled.svelte => canceled/index.svelte} (100%) create mode 100644 src/routes/orders/claim@orders.svelte create mode 100644 src/routes/orders/success/claim-ticket.svelte delete mode 100644 src/routes/orders/summary.svelte create mode 100644 src/routes/orders/summary@orders.svelte diff --git a/package-lock.json b/package-lock.json index 6e9af44ef..bae93e7c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,6 +27,7 @@ "@tailwindcss/line-clamp": "^0.4.0", "@tailwindcss/typography": "^0.5.2", "@xstate/inspect": "^0.7.0", + "@xstate/svelte": "^2.0.0", "all-contributors-cli": "^6.20.0", "archieml": "^0.5.0", "autoprefixer": "^10.4.7", @@ -80,8 +81,7 @@ "tailwindcss": "^3.0.24", "unist-util-visit": "^4.1.0", "uuid": "^8.3.2", - "xstate": "^4.32.1", - "xstate-svelte": "^1.0.1", + "xstate": "^4.33.5", "yup": "^0.32.11" }, "engines": { @@ -1545,13 +1545,6 @@ "url": "https://opencollective.com/typescript-eslint" } }, - "node_modules/@xstate/fsm": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@xstate/fsm/-/fsm-1.6.5.tgz", - "integrity": "sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==", - "dev": true, - "peer": true - }, "node_modules/@xstate/inspect": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@xstate/inspect/-/inspect-0.7.0.tgz", @@ -1571,6 +1564,25 @@ } } }, + "node_modules/@xstate/svelte": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@xstate/svelte/-/svelte-2.0.0.tgz", + "integrity": "sha512-051btq174/fc0lsFUsl5xLbpzEGF4lg6unV1uimjQwKxYTwF2GZXKlcQx2dW7WYpqeH0CWoKvKtb2qIBsnxq5A==", + "dev": true, + "peerDependencies": { + "@xstate/fsm": "^2.0.0", + "svelte": "^3.24.1", + "xstate": "^4.32.0" + }, + "peerDependenciesMeta": { + "@xstate/fsm": { + "optional": true + }, + "xstate": { + "optional": true + } + } + }, "node_modules/acorn": { "version": "8.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", @@ -8820,33 +8832,15 @@ } }, "node_modules/xstate": { - "version": "4.32.1", - "resolved": "https://registry.npmjs.org/xstate/-/xstate-4.32.1.tgz", - "integrity": "sha512-QYUd+3GkXZ8i6qdixnOn28bL3EvA++LONYL/EMWwKlFSh/hiLndJ8YTnz77FDs+JUXcwU7NZJg7qoezoRHc4GQ==", + "version": "4.33.5", + "resolved": "https://registry.npmjs.org/xstate/-/xstate-4.33.5.tgz", + "integrity": "sha512-C8WGBeQC+dNMp4MmQX359BUkJCv2VPAH/CGRnhtgri5JZ7wVEX7fsbfcqznAgnKyD0m9Hd3cGhg/wuzIjnfT4A==", "dev": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/xstate" } }, - "node_modules/xstate-svelte": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/xstate-svelte/-/xstate-svelte-1.0.1.tgz", - "integrity": "sha512-vp5NgOBDSa0XBP/EiIZsIlb/Ca5DxcVfUK8f49v+oWKvehOMmwDzvGVcJZBZgFC9F97Ji1eLCo8lvvj2pRqTvw==", - "deprecated": "This module is deprecated. Please use @xstate/svelte instead.", - "dev": true, - "dependencies": { - "tslib": "^2.0.3" - }, - "engines": { - "node": ">=10" - }, - "peerDependencies": { - "@xstate/fsm": "^1.3.0", - "svelte": "^3.20.0", - "xstate": "^4.8.0" - } - }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -10070,13 +10064,6 @@ "eslint-visitor-keys": "^3.3.0" } }, - "@xstate/fsm": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/@xstate/fsm/-/fsm-1.6.5.tgz", - "integrity": "sha512-b5o1I6aLNeYlU/3CPlj/Z91ybk1gUsKT+5NAJI+2W4UjvS5KLG28K9v5UvNoFVjHV8PajVZ00RH3vnjyQO7ZAw==", - "dev": true, - "peer": true - }, "@xstate/inspect": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/@xstate/inspect/-/inspect-0.7.0.tgz", @@ -10086,6 +10073,13 @@ "fast-safe-stringify": "^2.1.1" } }, + "@xstate/svelte": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@xstate/svelte/-/svelte-2.0.0.tgz", + "integrity": "sha512-051btq174/fc0lsFUsl5xLbpzEGF4lg6unV1uimjQwKxYTwF2GZXKlcQx2dW7WYpqeH0CWoKvKtb2qIBsnxq5A==", + "dev": true, + "requires": {} + }, "acorn": { "version": "8.7.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.7.1.tgz", @@ -15261,20 +15255,11 @@ "requires": {} }, "xstate": { - "version": "4.32.1", - "resolved": "https://registry.npmjs.org/xstate/-/xstate-4.32.1.tgz", - "integrity": "sha512-QYUd+3GkXZ8i6qdixnOn28bL3EvA++LONYL/EMWwKlFSh/hiLndJ8YTnz77FDs+JUXcwU7NZJg7qoezoRHc4GQ==", + "version": "4.33.5", + "resolved": "https://registry.npmjs.org/xstate/-/xstate-4.33.5.tgz", + "integrity": "sha512-C8WGBeQC+dNMp4MmQX359BUkJCv2VPAH/CGRnhtgri5JZ7wVEX7fsbfcqznAgnKyD0m9Hd3cGhg/wuzIjnfT4A==", "dev": true }, - "xstate-svelte": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/xstate-svelte/-/xstate-svelte-1.0.1.tgz", - "integrity": "sha512-vp5NgOBDSa0XBP/EiIZsIlb/Ca5DxcVfUK8f49v+oWKvehOMmwDzvGVcJZBZgFC9F97Ji1eLCo8lvvj2pRqTvw==", - "dev": true, - "requires": { - "tslib": "^2.0.3" - } - }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index e50a38a03..ef56aa6d1 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@tailwindcss/line-clamp": "^0.4.0", "@tailwindcss/typography": "^0.5.2", "@xstate/inspect": "^0.7.0", + "@xstate/svelte": "^2.0.0", "all-contributors-cli": "^6.20.0", "archieml": "^0.5.0", "autoprefixer": "^10.4.7", @@ -95,8 +96,7 @@ "tailwindcss": "^3.0.24", "unist-util-visit": "^4.1.0", "uuid": "^8.3.2", - "xstate": "^4.32.1", - "xstate-svelte": "^1.0.1", + "xstate": "^4.33.5", "yup": "^0.32.11" } } diff --git a/src/_components/activities/UpNext.svelte b/src/_components/activities/UpNext.svelte index 50ca0e63f..998a61691 100644 --- a/src/_components/activities/UpNext.svelte +++ b/src/_components/activities/UpNext.svelte @@ -2,7 +2,7 @@ export let stateMachineService; import { fade } from 'svelte/transition'; - import { useService } from 'xstate-svelte'; + import { useService } from '@xstate/svelte'; import { debug } from '$utils/config'; import lodash from 'lodash'; diff --git a/src/_components/nav/Cart.svelte b/src/_components/nav/Cart.svelte index b6ed715ba..2dcc9fb5b 100644 --- a/src/_components/nav/Cart.svelte +++ b/src/_components/nav/Cart.svelte @@ -6,17 +6,17 @@ $: cartItems = Object.keys($state.context.cart).length; -
- +{/if} diff --git a/src/_components/nav/ClaimCart.svelte b/src/_components/nav/ClaimCart.svelte new file mode 100644 index 000000000..969462d65 --- /dev/null +++ b/src/_components/nav/ClaimCart.svelte @@ -0,0 +1,20 @@ + + +{#if ['claim.pending'].some($state.matches)} +
+ +
+{/if} diff --git a/src/_components/nav/UserProfile.svelte b/src/_components/nav/UserProfile.svelte index b76fe62f1..87c436b6e 100644 --- a/src/_components/nav/UserProfile.svelte +++ b/src/_components/nav/UserProfile.svelte @@ -7,7 +7,7 @@ import { clickOutside } from '$elements/actions'; const { isEmpty } = lodash; - let visible; + let visible = false;
diff --git a/src/_components/nav/interiorNav/Large.svelte b/src/_components/nav/interiorNav/Large.svelte index a6f9cae17..6eeefa7e6 100644 --- a/src/_components/nav/interiorNav/Large.svelte +++ b/src/_components/nav/interiorNav/Large.svelte @@ -1,10 +1,9 @@
@@ -160,29 +158,19 @@ {/if} {/if} - {#if true} - - {/if} +
+ +
+
+ +
-
- - - +
+
+ + + +
diff --git a/src/_components/nav/interiorNav/Mobile.svelte b/src/_components/nav/interiorNav/Mobile.svelte index cbb664564..d6a5ae1f7 100644 --- a/src/_components/nav/interiorNav/Mobile.svelte +++ b/src/_components/nav/interiorNav/Mobile.svelte @@ -1,6 +1,10 @@ @@ -68,5 +72,11 @@
+
+ + + +
+
diff --git a/src/_components/nav/mainNav/Desktop.svelte b/src/_components/nav/mainNav/Desktop.svelte index ae644e3c3..c8dc89708 100644 --- a/src/_components/nav/mainNav/Desktop.svelte +++ b/src/_components/nav/mainNav/Desktop.svelte @@ -3,7 +3,9 @@ import Icon from 'svelte-awesome'; import { plus } from '$components/svelte-awesome-icons'; - import { Cart } from '$elements/svgs'; + import CartWarning from '../Cart.svelte'; + import ClaimCartWarning from '../ClaimCart.svelte'; + import UserProfile from '../UserProfile.svelte'; import links from './links'; @@ -33,26 +35,20 @@
-
- +
+
-
- - - +
+ +
+ +
+
+ + + +
{#each links as l} @@ -17,6 +20,12 @@ {/each} +
+ + + +
+
{#if $session.isAuthenticated} diff --git a/src/_dataSources/api.that.tech/orders/mutations.js b/src/_dataSources/api.that.tech/orders/mutations.js index 614bf1113..eb7efa139 100644 --- a/src/_dataSources/api.that.tech/orders/mutations.js +++ b/src/_dataSources/api.that.tech/orders/mutations.js @@ -54,6 +54,21 @@ export const MUTATION_ALLOCATE_TICKET = ` } `; +export const MUTATION_CLAIM_TICKET = ` + mutation ClaimMySpot ($claim: ClaimOrderInput!) { + orders { + me { + checkout { + claim(claim: $claim) { + result + message + } + } + } + } + } +`; + export default (fetch) => { const client = fetch ? gFetch(fetch) : gFetch(); @@ -126,9 +141,34 @@ export default (fetch) => { }); } + function claimTicket(eventId, productId) { + const variables = { + claim: { + eventId, + productId + } + }; + + return client + .mutation({ mutation: MUTATION_CLAIM_TICKET, variables }) + .then(({ data, errors }) => { + if (errors) log({ errors, tag: 'MUTATION_CLAIM_TICKET' }); + + let results; + + if (data) { + const { claim } = data.orders.me.checkout; + results = claim; + } + + return results; + }); + } + return { createCheckoutSession, markSurveyQuestionsCompleted, - allocateTicket + allocateTicket, + claimTicket }; }; diff --git a/src/_elements/buttons/Standard.svelte b/src/_elements/buttons/Standard.svelte index bd4aa6f55..4503bc628 100644 --- a/src/_elements/buttons/Standard.svelte +++ b/src/_elements/buttons/Standard.svelte @@ -1,7 +1,7 @@
-
-
+
+
+
+
+
+ + THAT Online - Event Ticket + +
+
+
+ {#if eventTickets['CLAIMABLE_TICKET'].price === 0} + Free + {:else} + ${eventTickets['CLAIMABLE_TICKET'].price} + USD + {/if} +
+

+ {event.name} +

+

+ {dayjs(event.startDate).format('dddd, MMMM D, YYYY - h:mm A z')} +

+

+ {eventTickets['VIRTUAL_CAMPER'].description} +

+
+
+
    +
  • +
    + +
    +

    Full Access All Day

    +
  • + +
  • +
    + +
    +

    Create and Facilitate Activities

    +
  • + +
  • +
    + +
    +

    Join Any Activity

    +
  • +
+ + + dispatch('claim-ticket', { product: { id: eventTickets['CLAIMABLE_TICKET'].id } })}> + Claim Your Ticket + +
+
+ +
+
+
+
+ + THAT Online - Event Ticket + +
+
+
+ ${eventTickets['VIRTUAL_CAMPER'].price} + USD +
+

+ {event.name} +

+

+ {dayjs(event.startDate).format('dddd, MMMM D, YYYY - h:mm A z')} +

+

+ {eventTickets['VIRTUAL_CAMPER'].description} +

+
+
+
    +
  • +
    + +
    +

    Full Access All Day

    +
  • + +
  • +
    + +
    +

    Create and Facilitate Activities

    +
  • + +
  • +
    + +
    +

    Join Any Activity

    +
  • + +
  • +
    + +
    +

    Helps Support Future Platform Growth

    +
  • +
+ dispatch('purchase-event-ticket')}> + Buy us a Coffee & Claim Ticket + +
+
+
+ +
+

Built to support the practitioners

@@ -52,8 +186,9 @@ experiences. Our problems are hard, they require context and that's ok. This is why we've created a platform to connect people more authentically, true to peer-to-peer learning.

- -
+
+
+
- -
diff --git a/src/routes/events/_components/online/_OnlineHero.svelte b/src/routes/events/_components/online/_OnlineHero.svelte index feb789d3a..409169bf0 100644 --- a/src/routes/events/_components/online/_OnlineHero.svelte +++ b/src/routes/events/_components/online/_OnlineHero.svelte @@ -44,7 +44,7 @@

- {dayjs(event.startDate).format("MMMM D, 'YY, h:mm A")} + {dayjs(event.startDate).format('MMMM D, YYYY')}

diff --git a/src/routes/events/_components/schedule/List.svelte b/src/routes/events/_components/schedule/List.svelte index 995900dea..8b0ad22da 100644 --- a/src/routes/events/_components/schedule/List.svelte +++ b/src/routes/events/_components/schedule/List.svelte @@ -1,7 +1,7 @@ + + +
+
+

+ Order Summary +

+ +
+ +
+
+
+ + +
diff --git a/src/routes/orders/_components/_Cart.svelte b/src/routes/orders/_components/_Cart.svelte index c43cbcdfc..15ba5f44a 100644 --- a/src/routes/orders/_components/_Cart.svelte +++ b/src/routes/orders/_components/_Cart.svelte @@ -150,6 +150,11 @@ + {#each Object.keys($state.context.cart) as productKey, i (productKey)} diff --git a/src/routes/orders/_components/_CartItem.svelte b/src/routes/orders/_components/_CartItem.svelte index bac2e93a6..e3aad9b83 100644 --- a/src/routes/orders/_components/_CartItem.svelte +++ b/src/routes/orders/_components/_CartItem.svelte @@ -1,6 +1,7 @@ + @@ -31,7 +40,7 @@ ...lineItem, quantity: currentQty })} - class="block rounded-md border border-gray-200 p-2 text-center shadow-sm focus:border-thatOrange-500 focus:ring-thatOrange-500" /> + class="block w-28 rounded-md border border-gray-200 p-2 text-center shadow-sm focus:border-thatOrange-500 focus:ring-thatOrange-500" />
+ Event + @@ -183,6 +188,7 @@
+
+ {#if eventDetails} +
{eventDetails.name}
+ event logo + {/if} +
+
{lineItem.name} + {/if} + + + {/if} + + {#if ['claim.claimingTicket'].some($state.matches)} +
+ +
processing ticket...
+
+ {/if} + + {#if ['claim.ticketClaimed'].some($state.matches)} +
ticket claimed
+ {/if} + + diff --git a/src/routes/orders/_components/_Steps.svelte b/src/routes/orders/_components/_Prerequisites.svelte similarity index 70% rename from src/routes/orders/_components/_Steps.svelte rename to src/routes/orders/_components/_Prerequisites.svelte index f45033db0..3d480bde1 100644 --- a/src/routes/orders/_components/_Steps.svelte +++ b/src/routes/orders/_components/_Prerequisites.svelte @@ -1,52 +1,38 @@
- {#if $state.matches('pendingLogin')} + {#if ['unAuthenticated', 'pendingLogin'].some($state.matches)}

Please Login

@@ -148,7 +111,7 @@

- {:else if $state.matches('authenticated.pendingProfile')} + {:else if $state.matches('pendingProfile')}

Full Profile Incomplete

@@ -164,7 +127,7 @@

- {:else if $state.matches('authenticated.profileCompleted')} + {:else if $state.matches('prerequisitesMet')}

Finalize and Complete

diff --git a/src/routes/orders/_machines/steps.js b/src/routes/orders/_machines/prerequisites.js similarity index 59% rename from src/routes/orders/_machines/steps.js rename to src/routes/orders/_machines/prerequisites.js index 2a1a458e9..036142052 100644 --- a/src/routes/orders/_machines/steps.js +++ b/src/routes/orders/_machines/prerequisites.js @@ -1,9 +1,13 @@ -import { createMachine, assign, sendParent } from 'xstate'; - +import { createMachine, assign } from 'xstate'; +import { getContext } from 'svelte'; import { log } from '$utils/error'; -import createConfig from './stepsConfig'; + +import createConfig from './prerequisitesConfig'; function createServices() { + const { send } = getContext('cart'); + const { send: claimTicketSend } = getContext('claimTicket'); + return { guards: { isAuthenticated: (context) => context.isAuthenticated, @@ -27,12 +31,19 @@ function createServices() { hasUserProfile: (_, event) => event.status }), - notifyPrerequisitesWereMet: sendParent('PREREQUISITES_MET') + setPrerequisitesMet: assign({ + prerequisitesMet: () => true + }), + + notifyPrerequisitesWereMet: () => { + send('VERIFICATION_SUCCESS'); + claimTicketSend('VERIFICATION_SUCCESS'); + } } }; } -function create(meta) { +function create(meta = undefined) { const services = createServices(); return createMachine({ ...createConfig(meta) }, { ...services }); } diff --git a/src/routes/orders/_machines/prerequisitesConfig.js b/src/routes/orders/_machines/prerequisitesConfig.js new file mode 100644 index 000000000..255d5e177 --- /dev/null +++ b/src/routes/orders/_machines/prerequisitesConfig.js @@ -0,0 +1,86 @@ +function createConfig(metaContext) { + return { + id: 'PrerequisitesMachine', + initial: 'pendingLogin', + context: { + meta: metaContext || undefined, + isAuthenticated: false, + hasUserProfile: false, + prerequisitesMet: false + }, + + on: { + /* + AUTHENTICATED Event + send('AUTHENTICATED', {status: true}) + */ + AUTHENTICATED: { + actions: ['setIsAuthenticated'], + target: 'pendingLogin' + }, + + /* + PROFILE_COMPLETED Event + send('PROFILE_COMPLETED', {status: true}) + */ + PROFILE_COMPLETED: { + actions: ['setHasUserProfile'] + } + }, + + states: { + pendingLogin: { + always: [ + { + cond: 'isAuthenticated', + target: 'authenticated' + }, + { + target: 'unAuthenticated' + } + ] + }, + + unAuthenticated: {}, + + authenticated: { + always: [ + { + cond: 'hasUserProfile', + target: 'profileCompleted' + }, + { + target: 'pendingProfile' + } + ] + }, + + pendingProfile: { + always: [ + { + cond: 'hasUserProfile', + target: 'profileCompleted' + } + ] + }, + + profileCompleted: { + entry: ['setPrerequisitesMet'], + always: { + target: 'prerequisitesMet' + } + }, + + prerequisitesMet: { + entry: ['notifyPrerequisitesWereMet'] + }, + + error: { + entry: 'logError', + type: 'final' + } + } + }; +} + +export default createConfig; diff --git a/src/routes/orders/_machines/stepsConfig.js b/src/routes/orders/_machines/stepsConfig.js deleted file mode 100644 index be3b30d9b..000000000 --- a/src/routes/orders/_machines/stepsConfig.js +++ /dev/null @@ -1,78 +0,0 @@ -/* - AUTHENTICATED Event - send('AUTHENTICATED', {status: true}) - - PROFILE_COMPLETED Event - send('PROFILE_COMPLETED', {status: true}) -*/ - -function createConfig(metaContext) { - return { - id: 'Order_Summary_Steps', - initial: 'pendingLogin', - context: { - meta: metaContext || undefined, - isAuthenticated: false, - hasUserProfile: false - }, - - on: { - AUTHENTICATED: { - actions: ['setIsAuthenticated'], - target: 'pendingLogin' - }, - - PROFILE_COMPLETED: { - actions: ['setHasUserProfile'] - } - }, - - states: { - pendingLogin: { - always: [ - { - cond: 'isAuthenticated', - target: 'authenticated' - } - ] - }, - - authenticated: { - initial: 'pendingProfile', - states: { - pendingProfile: { - always: { - cond: 'hasUserProfile', - target: 'profileCompleted' - } - }, - - profileCompleted: { - initial: 'pendingVerification', - states: { - pendingVerification: { - entry: ['notifyPrerequisitesWereMet'], - on: { - complete: { - target: 'completePurchase' - } - } - }, - - completePurchase: {} - } - } - } - }, - - unAuthenticated: {}, - - error: { - entry: 'logError', - type: 'final' - } - } - }; -} - -export default createConfig; diff --git a/src/routes/orders/_machines/summary.js b/src/routes/orders/_machines/summary.js deleted file mode 100644 index bd2e9073d..000000000 --- a/src/routes/orders/_machines/summary.js +++ /dev/null @@ -1,39 +0,0 @@ -import { getContext } from 'svelte'; -import { createMachine, assign, spawn } from 'xstate'; - -import { log } from '$utils/error'; -import createConfig from './summaryConfig'; - -function createServices(stepsMachine) { - const { send } = getContext('cart'); - - return { - guards: {}, - services: {}, - - actions: { - logError: (context, event) => - log({ - error: 'summary state machine has ended in the error state.', - extra: { context, event } - }), - - notifyPrerequisitesMet: () => send('VERIFICATION_SUCCESS'), - - setStepsMachine: assign({ - stepsMachine: (_context) => spawn(stepsMachine) - }), - - setPrerequisitesMet: assign({ - prerequisitesMet: () => true - }) - } - }; -} - -function create(stepsMachine) { - const services = createServices(stepsMachine); - return createMachine({ ...createConfig() }, { ...services }); -} - -export default create; diff --git a/src/routes/orders/_machines/summaryConfig.js b/src/routes/orders/_machines/summaryConfig.js deleted file mode 100644 index 921317c87..000000000 --- a/src/routes/orders/_machines/summaryConfig.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - AUTHENTICATED Event - send('AUTHENTICATED', {status: true}) - - PROFILE_COMPLETED Event - send('PROFILE_COMPLETED', {status: true}) -*/ - -function createConfig() { - return { - id: 'Order_Summary', - initial: 'init', - context: { - prerequisitesMet: false, - stepsMachine: null - }, - - on: { - PREREQUISITES_MET: { - actions: ['setPrerequisitesMet'], - target: 'ready' - } - }, - - states: { - init: { - always: { - actions: ['setStepsMachine'], - target: 'waiting' - } - }, - waiting: {}, - ready: { - entry: 'notifyPrerequisitesMet' - }, - - error: { - entry: 'logError', - type: 'final' - } - } - }; -} - -export default createConfig; diff --git a/src/routes/orders/canceled.svelte b/src/routes/orders/canceled/index.svelte similarity index 100% rename from src/routes/orders/canceled.svelte rename to src/routes/orders/canceled/index.svelte diff --git a/src/routes/orders/claim@orders.svelte b/src/routes/orders/claim@orders.svelte new file mode 100644 index 000000000..e93cf44f4 --- /dev/null +++ b/src/routes/orders/claim@orders.svelte @@ -0,0 +1,26 @@ + + + + +

+ +
diff --git a/src/routes/orders/success/__layout.svelte b/src/routes/orders/success/__layout.svelte index 712529dae..554b85356 100644 --- a/src/routes/orders/success/__layout.svelte +++ b/src/routes/orders/success/__layout.svelte @@ -1,13 +1,6 @@ diff --git a/src/routes/orders/success/claim-ticket.svelte b/src/routes/orders/success/claim-ticket.svelte new file mode 100644 index 000000000..02e4950e2 --- /dev/null +++ b/src/routes/orders/success/claim-ticket.svelte @@ -0,0 +1,46 @@ +
+

+ WELCOME TO THAT ONLINE +

+

+ Your ticket has been claimed! +

+
+ +
+

+ Thank you for securing a ticket to THAT Online! We are excited to have you join our community + and be part of our global family! Your support helps our mission of fostering a community of + geeks who want to help each other be awesome. Together we can accomplish amazing things! +

+ +

+ Make sure to mark your calendar and remember the event runs for 24 hours to best accommodate for + all time zones and schedules. So get ready and start thinking about the areas, topics, and/or + questions that would help you in your daily tech life. +

+ +

In the meantime, here are a few things you can do to prepare for the event:

+
    +
  • Create an Activity on something you want to discuss or share.
  • +
  • + Look through the list of Activities and favorite the ones you are interested in attending. +
  • +
  • + Join us in Slack. +
  • +
  • And lastly, tell your friends!
  • +
+ +

+ Have questions? Feel free to check out our FAQ, or email us at + hello@that.us. +

+ +

See you soon.

+
diff --git a/src/routes/orders/summary.svelte b/src/routes/orders/summary.svelte deleted file mode 100644 index 44eb9d2ac..000000000 --- a/src/routes/orders/summary.svelte +++ /dev/null @@ -1,54 +0,0 @@ - - - - -{#if ['waiting', 'ready'].some($state.matches)} - -
-
-

- Order Summary -

- -
- -
-
-
- -
- -
-
-{/if} diff --git a/src/routes/orders/summary@orders.svelte b/src/routes/orders/summary@orders.svelte new file mode 100644 index 000000000..be6e606f3 --- /dev/null +++ b/src/routes/orders/summary@orders.svelte @@ -0,0 +1,26 @@ + + + + +
+ +
diff --git a/src/routes/partners/[partner]/index.svelte b/src/routes/partners/[partner]/index.svelte index b3eb8e373..81c327d88 100644 --- a/src/routes/partners/[partner]/index.svelte +++ b/src/routes/partners/[partner]/index.svelte @@ -18,7 +18,7 @@ import { setContext } from 'svelte'; import { page, session } from '$app/stores'; import { fade } from 'svelte/transition'; - import { useMachine } from 'xstate-svelte'; + import { useMachine } from '@xstate/svelte'; import { debug } from '$utils/config'; import seoMetaTags from '$utils/seo/metaTags'; diff --git a/src/routes/partners/_components/_Followers.svelte b/src/routes/partners/_components/_Followers.svelte index 3c3915a8e..cb3a1ee6a 100644 --- a/src/routes/partners/_components/_Followers.svelte +++ b/src/routes/partners/_components/_Followers.svelte @@ -1,7 +1,7 @@ - -
-
-
-
-

- Upcoming - {#if $state.context.meta.name} - {$state.context.meta.name} - {/if} - Activities -

-

- Check out these activities currently on the schedule. - - - View all of the upcoming - {#if $state.context.meta.name} - {$state.context.meta.name} - {/if} - activities. - - -

-
- -
    - {#if $state.matches('loaded')} - {#if $state.context.items.length > 0} - {#each $state.context.items as s (s.id)} -
  • - -
  • - {/each} - {/if} - {/if} - - {#if $state.context.items.length < 6} -
  • - -
  • - {/if} -
- -
- {#if ['loaded'].some($state.matches)} - - {/if} - - {#if ['loadedAll'].some($state.matches)} - - {/if} -
-
-
-
diff --git a/src/routes/partners/[partner]/index.svelte b/src/routes/partners/[partner]/index.svelte index 81c327d88..47741b30c 100644 --- a/src/routes/partners/[partner]/index.svelte +++ b/src/routes/partners/[partner]/index.svelte @@ -133,7 +133,7 @@
- +
- export let stateMachineService; - - import { useService } from '@xstate/svelte'; - + export let followers = []; import { Avatars } from '$elements'; - import { debug } from '$utils/config'; - - const { state } = useService(stateMachineService, { devTools: debug.xstate }); -{#if $state.matches('loaded')} +{#if followers.length > 0}
@@ -23,16 +17,8 @@
- +
- -
diff --git a/src/routes/partners/_machines/followers.js b/src/routes/partners/_machines/followers.js deleted file mode 100644 index ca3b75195..000000000 --- a/src/routes/partners/_machines/followers.js +++ /dev/null @@ -1,47 +0,0 @@ -import { createMachine, assign } from 'xstate'; - -import { log } from '$utils/error'; -import createPagingConfig from '$machines/paging'; -import partnerQueryApi from '$dataSources/api.that.tech/partner/queries'; - -function createServices() { - const { queryFollowers, queryNextFollowers } = partnerQueryApi(); - - return { - guards: { - hasMore: (_, event) => event.data !== null - }, - - services: { - load: (context) => queryFollowers(context.meta.id), - loadNext: (context) => queryNextFollowers(context.meta.id, context.cursor) - }, - - actions: { - logError: (context, event) => - log({ - error: 'partners followers state machine ended in the error state.', - extra: { context, event } - }), - - loadSuccess: assign({ - items: (_, { data: { followers } }) => followers.members, - cursor: (_, { data: { followers } }) => followers.cursor - }), - - loadNextSuccess: assign({ items: (_, event) => event.data }), - - loadedAllSuccess: assign({ - items: () => [], - cursor: () => undefined - }) - } - }; -} - -function create(meta) { - const services = createServices(); - return createMachine({ ...createPagingConfig(meta) }, { ...services }); -} - -export default create; diff --git a/src/routes/partners/_machines/partner.js b/src/routes/partners/_machines/partner.js index e3025d755..e7208af5a 100644 --- a/src/routes/partners/_machines/partner.js +++ b/src/routes/partners/_machines/partner.js @@ -1,5 +1,5 @@ import { goto } from '$app/navigation'; -import { createMachine, assign, spawn, send } from 'xstate'; +import { createMachine, assign } from 'xstate'; import { isValidSlug } from '$machines/guards/slug'; import { log } from '$utils/error'; @@ -9,10 +9,9 @@ import partnerLeadsMutationsApi from '$dataSources/api.that.tech/partner/leads/m import meQueryApi from '$dataSources/api.that.tech/me/queries'; import createPartnerConfig from './partnerConfig'; -import createFollowMachine from './followers'; function createServices() { - const { getPartner } = partnerQueryApi(); + const { getPartner, queryFollowers } = partnerQueryApi(); const { toggleFollow } = partnerMutationsApi(); const { queryMeFollowingPartners } = meQueryApi(); const { addLead } = partnerLeadsMutationsApi(); @@ -22,7 +21,6 @@ function createServices() { isValidSlug, profileFound: (_, { data }) => data !== null, profileNotFound: (_, { data }) => data === null, - isAuthenticated: (context) => context.isAuthenticated, isUnAuthenticated: (context) => context.isAuthenticated }, @@ -30,6 +28,7 @@ function createServices() { services: { queryProfile: (context) => getPartner(context.slug), queryMyFollowing: () => queryMeFollowingPartners(), + queryFollowers: (context) => queryFollowers(context.profile.id), toggleFollow: (context) => toggleFollow(context.profile.id), addLeadMutate: (context) => addLead(context.profile.id) }, @@ -47,10 +46,6 @@ function createServices() { isAuthenticated: (_, event) => event.status }), - refreshFollowers: send('REFRESH', { - to: (context) => context.followMachineServices - }), - queryProfileSuccess: assign({ profile: (_, { data }) => data }), @@ -59,16 +54,16 @@ function createServices() { isFollowing: (context, { data }) => data.includes(context.profile.id) }), + queryFollowersSuccess: assign({ + followers: (_, { data: { followers } }) => followers.members + }), + toggleFollowSuccess: assign({ isFollowing: (_, event) => event.data }), addLeadSuccess: assign({ leadAdded: (_, event) => event.result - }), - - createFollowMachineServices: assign({ - followMachineServices: (context) => spawn(createFollowMachine(context.profile)) }) } }; diff --git a/src/routes/partners/_machines/partnerConfig.js b/src/routes/partners/_machines/partnerConfig.js index 7823cc7a1..c755f5752 100644 --- a/src/routes/partners/_machines/partnerConfig.js +++ b/src/routes/partners/_machines/partnerConfig.js @@ -18,7 +18,7 @@ function createConfig(slug) { slug: slug || undefined, profile: undefined, isAuthenticated: false, - followMachineServices: undefined + followers: [] }, on: { @@ -46,7 +46,7 @@ function createConfig(slug) { onDone: [ { cond: 'profileFound', - actions: ['queryProfileSuccess', 'createFollowMachineServices'], + actions: ['queryProfileSuccess'], target: 'profileLoaded' }, { @@ -92,20 +92,36 @@ function createConfig(slug) { states: { loadFollowing: { - invoke: { - id: 'queryMyFollowing', - src: 'queryMyFollowing', - onDone: [ - { - actions: ['queryMyFollowingSuccess'], - target: 'loaded' + invoke: [ + { + id: 'queryMyFollowing', + src: 'queryMyFollowing', + onDone: [ + { + actions: ['queryMyFollowingSuccess'], + target: 'loaded' + } + ], + + onError: { + target: 'error' + } + }, + { + id: 'queryFollowers', + src: 'queryFollowers', + onDone: [ + { + actions: ['queryFollowersSuccess'], + target: 'loaded' + } + ], + + onError: { + target: 'error' } - ], - - onError: { - target: 'error' } - } + ] }, toggleFollow: { @@ -114,7 +130,6 @@ function createConfig(slug) { src: 'toggleFollow', onDone: [ { - actions: ['refreshFollowers'], target: 'loadFollowing' } ],