From 3e3db7a92398e4ccf064be3b22ebaba6116ba2e3 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 1 Oct 2024 13:27:17 +0200 Subject: [PATCH 01/27] Work in progress login page --- .../appwrite-logo.svg | 13 ++ .../github-education-program/artwork-dark.svg | 88 ++++++++++ .../github-education-program/github-logo.svg | 4 + .../github-education-program/+page.svelte | 164 ++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 src/lib/images/github-education-program/appwrite-logo.svg create mode 100644 src/lib/images/github-education-program/artwork-dark.svg create mode 100644 src/lib/images/github-education-program/github-logo.svg create mode 100644 src/routes/(public)/(guest)/register/github-education-program/+page.svelte diff --git a/src/lib/images/github-education-program/appwrite-logo.svg b/src/lib/images/github-education-program/appwrite-logo.svg new file mode 100644 index 0000000000..1cb8a05349 --- /dev/null +++ b/src/lib/images/github-education-program/appwrite-logo.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/lib/images/github-education-program/artwork-dark.svg b/src/lib/images/github-education-program/artwork-dark.svg new file mode 100644 index 0000000000..2f142bbe4b --- /dev/null +++ b/src/lib/images/github-education-program/artwork-dark.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/images/github-education-program/github-logo.svg b/src/lib/images/github-education-program/github-logo.svg new file mode 100644 index 0000000000..232dafc9b5 --- /dev/null +++ b/src/lib/images/github-education-program/github-logo.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte new file mode 100644 index 0000000000..53af8e6f03 --- /dev/null +++ b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte @@ -0,0 +1,164 @@ + + + + Sign up - Appwrite Education Program + +
+
+ +
+
+
+
+ Appwrite logo +
+ Github logo +
+

Join the Appwrite Education Program

+

+ Enjoy Appwrite Cloud for free throughout your student journey as part of the GitHub + Student Developer Pack. +

+ +
+
+
+ + From 484daab32f7c150fb08e8d97bba4bb886e8463cb Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 1 Oct 2024 14:32:50 +0200 Subject: [PATCH 02/27] Fix styling login page --- .../appwrite-logo.svg | 13 --- .../artwork-dark-mobile.svg | 87 +++++++++++++++++++ .../artwork-light-mobile.svg | 78 +++++++++++++++++ .../artwork-light.svg | 86 ++++++++++++++++++ .../github-logo.svg => github-logo-dark.svg} | 0 src/lib/images/github-logo-light.svg | 4 + .../github-education-program/+page.svelte | 40 +++++++-- 7 files changed, 290 insertions(+), 18 deletions(-) delete mode 100644 src/lib/images/github-education-program/appwrite-logo.svg create mode 100644 src/lib/images/github-education-program/artwork-dark-mobile.svg create mode 100644 src/lib/images/github-education-program/artwork-light-mobile.svg create mode 100644 src/lib/images/github-education-program/artwork-light.svg rename src/lib/images/{github-education-program/github-logo.svg => github-logo-dark.svg} (100%) create mode 100644 src/lib/images/github-logo-light.svg diff --git a/src/lib/images/github-education-program/appwrite-logo.svg b/src/lib/images/github-education-program/appwrite-logo.svg deleted file mode 100644 index 1cb8a05349..0000000000 --- a/src/lib/images/github-education-program/appwrite-logo.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/lib/images/github-education-program/artwork-dark-mobile.svg b/src/lib/images/github-education-program/artwork-dark-mobile.svg new file mode 100644 index 0000000000..5376631423 --- /dev/null +++ b/src/lib/images/github-education-program/artwork-dark-mobile.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/images/github-education-program/artwork-light-mobile.svg b/src/lib/images/github-education-program/artwork-light-mobile.svg new file mode 100644 index 0000000000..089bbdf1f8 --- /dev/null +++ b/src/lib/images/github-education-program/artwork-light-mobile.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/images/github-education-program/artwork-light.svg b/src/lib/images/github-education-program/artwork-light.svg new file mode 100644 index 0000000000..0c3d901a9f --- /dev/null +++ b/src/lib/images/github-education-program/artwork-light.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/lib/images/github-education-program/github-logo.svg b/src/lib/images/github-logo-dark.svg similarity index 100% rename from src/lib/images/github-education-program/github-logo.svg rename to src/lib/images/github-logo-dark.svg diff --git a/src/lib/images/github-logo-light.svg b/src/lib/images/github-logo-light.svg new file mode 100644 index 0000000000..578dd34855 --- /dev/null +++ b/src/lib/images/github-logo-light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte index 53af8e6f03..59a2f6567e 100644 --- a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte +++ b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte @@ -3,6 +3,10 @@ import { sdk } from '$lib/stores/sdk'; import { OAuthProvider } from '@appwrite.io/console'; import { Button } from '$lib/elements/forms'; + import AppwriteLogoDark from '$lib/images/appwrite-logo-dark.svg'; + import AppwriteLogoLight from '$lib/images/appwrite-logo-light.svg'; + import GithubLogoDark from '$lib/images/github-logo-dark.svg'; + import GithubLogoLight from '$lib/images/github-logo-light.svg'; let artworkImageSrc; getArtworkImageSrc(); @@ -49,16 +53,17 @@
+
Appwrite logo
Github logo

Join the Appwrite Education Program

@@ -75,6 +80,17 @@
From 718063129c8cbccab1184329dc974e91c520beb2 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Thu, 3 Oct 2024 16:04:57 +0200 Subject: [PATCH 09/27] Make gradient bit more visible --- .../(guest)/register/github-education-program/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte index 61852ac6eb..bc57aa1458 100644 --- a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte +++ b/src/routes/(public)/(guest)/register/github-education-program/+page.svelte @@ -118,7 +118,7 @@ min-height: 100vh; background: linear-gradient( 56deg, - rgba(253, 54, 110, 0.1) 0%, + rgba(253, 54, 110, 0.15) 0%, var(--gradient-start-color) 48.38% ); From eef885d5f5faa4b4117fbf995dc6146d05021b62 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Thu, 3 Oct 2024 16:14:55 +0200 Subject: [PATCH 10/27] Add to Organization screen --- src/routes/(console)/account/organizations/+page.svelte | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/(console)/account/organizations/+page.svelte b/src/routes/(console)/account/organizations/+page.svelte index 6c46e6718d..04404d65c0 100644 --- a/src/routes/(console)/account/organizations/+page.svelte +++ b/src/routes/(console)/account/organizations/+page.svelte @@ -17,7 +17,7 @@ import { Pill } from '$lib/elements'; import type { Models } from '@appwrite.io/console'; import type { Organization } from '$lib/stores/organization'; - import { daysLeftInTrial, plansInfo } from '$lib/stores/billing'; + import { daysLeftInTrial, plansInfo, tierToPlan } from '$lib/stores/billing'; import { tooltip } from '$lib/actions/tooltip'; import { toLocaleDate } from '$lib/helpers/date'; import { BillingPlan } from '$lib/constants'; @@ -71,14 +71,15 @@ {#if isCloudOrg(organization)} - {#if organization?.billingPlan === BillingPlan.FREE} + {#if organization?.billingPlan === BillingPlan.FREE || organization?.billingPlan === BillingPlan.GITHUB_EDUCATION}
- FREE + {tierToPlan(organization?.billingPlan)?.name}
{/if} {#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays} From 1c3747017c2b6492ee8a003b75a1ed481d2ec6e8 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 7 Oct 2024 14:04:38 +0200 Subject: [PATCH 11/27] Remove tier-3 override --- src/lib/stores/organization.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib/stores/organization.ts b/src/lib/stores/organization.ts index b27110cbb0..d400742e34 100644 --- a/src/lib/stores/organization.ts +++ b/src/lib/stores/organization.ts @@ -42,8 +42,5 @@ export const organizationList = derived( ($page) => $page.data.organizations as Models.TeamList> ); -// TODO: remove override to tier-3 when BE PR, https://github.com/appwrite-labs/cloud/pull/816, has been merged and deployed --> -export const organization = derived(page, ($page) => { - return { ...($page.data?.organization as Organization), billingPlan: 'tier-3' as Tier }; -}); +export const organization = derived(page, ($page) => $page.data?.organization as Organization); export const members = derived(page, ($page) => $page.data.members as Models.MembershipList); From ba11128cc859896588c305893cef8c1f3ab8da20 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 7 Oct 2024 14:20:07 +0200 Subject: [PATCH 12/27] Fix undefined for Education program billing --- .../organization-[organization]/billing/planSummary.svelte | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte index 53bf6ac509..474c15377b 100644 --- a/src/routes/(console)/organization-[organization]/billing/planSummary.svelte +++ b/src/routes/(console)/organization-[organization]/billing/planSummary.svelte @@ -55,7 +55,9 @@ {tierToPlan($organization?.billingPlan)?.name} plan
- {isTrial ? formatCurrency(0) : formatCurrency(currentPlan?.price)} + {isTrial || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION + ? formatCurrency(0) + : formatCurrency(currentPlan?.price)}
{#if $organization?.billingPlan !== BillingPlan.FREE && $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION && extraUsage > 0} From 9cdb37d90aa88691892990b6be1c859f29f5e1c6 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 8 Oct 2024 14:28:09 +0200 Subject: [PATCH 13/27] Add error page for membership call result, and add logic for extra use cases --- src/hooks.client.ts | 10 +++ src/lib/sdk/billing.ts | 14 +++- .../+page.svelte => education/+layout.svelte} | 67 +-------------- .../(public)/(guest)/education/+page.svelte | 83 +++++++++++++++++++ .../(guest)/education/error/+page.svelte | 54 ++++++++++++ src/routes/+page.ts | 29 +++++-- 6 files changed, 181 insertions(+), 76 deletions(-) rename src/routes/(public)/(guest)/{register/github-education-program/+page.svelte => education/+layout.svelte} (64%) create mode 100644 src/routes/(public)/(guest)/education/+page.svelte create mode 100644 src/routes/(public)/(guest)/education/error/+page.svelte diff --git a/src/hooks.client.ts b/src/hooks.client.ts index c6404ee813..628a86db08 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -25,3 +25,13 @@ export const handleError: HandleClientError = Sentry.handleErrorWithSentry( }; } ); + +const originalFetch = window.fetch; + +const customFetch = async (input, init = {}) => { + init.credentials = 'include'; + console.log('adjusted => ', input); + return originalFetch(input, init); +}; + +window.fetch = customFetch; diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index b3e6736c28..36efbd8f69 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -705,12 +705,18 @@ export class Billing { ); } - async setMembership(programId: string): Promise { + async setMembership( + programId: string + ): Promise { const path = `/console/programs/${programId}/memberships`; const uri = new URL(this.client.config.endpoint + path); - return await this.client.call('POST', uri, { - 'content-type': 'application/json' - }); + try { + return await this.client.call('POST', uri, { + 'content-type': 'application/json' + }); + } catch (e) { + return { error: { code: e.code, message: e.message } }; + } } async getCoupon(couponId: string): Promise { diff --git a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte b/src/routes/(public)/(guest)/education/+layout.svelte similarity index 64% rename from src/routes/(public)/(guest)/register/github-education-program/+page.svelte rename to src/routes/(public)/(guest)/education/+layout.svelte index bc57aa1458..9820ce2e77 100644 --- a/src/routes/(public)/(guest)/register/github-education-program/+page.svelte +++ b/src/routes/(public)/(guest)/education/+layout.svelte @@ -31,16 +31,6 @@ } } - function onGithubLogin() { - localStorage.setItem('githubEducationProgram', 'true'); - sdk.forConsole.account.createOAuth2Session( - OAuthProvider.Github, - window.location.origin + '/console/register/github-education-program?success', - window.location.origin + '/console/register/github-education-program?failure', - ['read:user', 'user:email'] - ); - } - function monitorResize() { window.addEventListener('resize', getArtworkImageSrc); @@ -61,26 +51,7 @@
-
-
- Appwrite logo -
- Github logo -
-

Join the Appwrite Education Program

-

- Enjoy Appwrite Cloud for free throughout your student journey as part of the GitHub - Student Developer Pack. -

- -
+
@@ -162,40 +133,4 @@ justify-content: center; } } - - .content { - @media (min-width: 768px) { - width: 460px; - } - } - - .content h1 { - font-family: var(--heading-font); - font-size: 2rem; - line-height: 2.125rem; - margin-top: 2.5rem; - color: var(--heading-color); - } - - .content p { - margin-top: 1.25rem; - color: var(--text-color); - font-size: 1.125rem; - font-weight: 500; - line-height: 1.625rem; - margin-bottom: 2rem; - } - - .content .logos { - display: flex; - flex-direction: row; - gap: 1.5rem; - height: 1.5rem; - } - - .content .logo-divider { - width: 2px; - height: 100%; - background-color: var(--divider-background-color); - } diff --git a/src/routes/(public)/(guest)/education/+page.svelte b/src/routes/(public)/(guest)/education/+page.svelte new file mode 100644 index 0000000000..8fb6b5d123 --- /dev/null +++ b/src/routes/(public)/(guest)/education/+page.svelte @@ -0,0 +1,83 @@ + + + + Sign up - Appwrite Education Program + + +
+
+ Appwrite logo +
+ Github logo +
+

Join the Appwrite Education Program

+

+ Enjoy Appwrite Cloud for free throughout your student journey as part of the GitHub Student + Developer Pack. +

+ +
+ + diff --git a/src/routes/(public)/(guest)/education/error/+page.svelte b/src/routes/(public)/(guest)/education/error/+page.svelte new file mode 100644 index 0000000000..64dbc8eb4b --- /dev/null +++ b/src/routes/(public)/(guest)/education/error/+page.svelte @@ -0,0 +1,54 @@ + + +
+

{message}

+

{getErrorExplanation()}

+ +
+ + diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 7720af4cc5..4f8c9d06ea 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -3,10 +3,33 @@ import { base } from '$app/paths'; import type { PageLoad } from './$types'; import { sdk } from '$lib/stores/sdk'; +const handleGithubEducationMembership = async () => { + const result = await sdk.forConsole.billing.setMembership('github-student-developer'); + if (result && 'error' in result) { + await sdk.forConsole.account.deleteSession('current'); + redirect( + 303, + `${base}/education/error?message=${result.error.message}&code=${result.error.code}` + ); + } +}; + +const userVisitedEducationPage = (): boolean => { + const didRegisterGithubEducationProgram = + localStorage.getItem('githubEducationProgram') === 'true'; + localStorage.removeItem('githubEducationProgram'); + return didRegisterGithubEducationProgram; +}; + export const load: PageLoad = async ({ parent, url }) => { const { organizations, account } = await parent(); + if (userVisitedEducationPage()) { + await handleGithubEducationMembership(); + } + if (organizations.total) { + console.log('getting into this funnel'); const teamId = account.prefs.organization ?? organizations.teams[0].$id; if (!teamId) { redirect(303, `${base}/account/organizations${url.search}`); @@ -14,12 +37,6 @@ export const load: PageLoad = async ({ parent, url }) => { redirect(303, `${base}/organization-${teamId}${url.search}`); } } else { - const didRegisterGithubEducationProgram = - localStorage.getItem('githubEducationProgram') === 'true'; - localStorage.removeItem('githubEducationProgram'); - if (didRegisterGithubEducationProgram) { - await sdk.forConsole.billing.setMembership('github-student-developer'); - } redirect(303, `${base}/onboarding${url.search}`); } }; From 66e40a7098af9020b016ffbdb0a430a5cdc08d8a Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 8 Oct 2024 14:29:00 +0200 Subject: [PATCH 14/27] Remove test code --- src/hooks.client.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 628a86db08..c6404ee813 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -25,13 +25,3 @@ export const handleError: HandleClientError = Sentry.handleErrorWithSentry( }; } ); - -const originalFetch = window.fetch; - -const customFetch = async (input, init = {}) => { - init.credentials = 'include'; - console.log('adjusted => ', input); - return originalFetch(input, init); -}; - -window.fetch = customFetch; From c82493bd2ac175e3e23879d43beac1ee12b9115b Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 8 Oct 2024 14:29:48 +0200 Subject: [PATCH 15/27] Remove console.log --- src/routes/+page.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 4f8c9d06ea..a5c37d54b8 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -29,7 +29,6 @@ export const load: PageLoad = async ({ parent, url }) => { } if (organizations.total) { - console.log('getting into this funnel'); const teamId = account.prefs.organization ?? organizations.teams[0].$id; if (!teamId) { redirect(303, `${base}/account/organizations${url.search}`); From 84d940bce6faa64f224c7ad3ea33da5d6c83386a Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 8 Oct 2024 14:31:15 +0200 Subject: [PATCH 16/27] Remove unused imports --- src/routes/(public)/(guest)/education/+layout.svelte | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/routes/(public)/(guest)/education/+layout.svelte b/src/routes/(public)/(guest)/education/+layout.svelte index 9820ce2e77..aad678455c 100644 --- a/src/routes/(public)/(guest)/education/+layout.svelte +++ b/src/routes/(public)/(guest)/education/+layout.svelte @@ -1,12 +1,5 @@
-

{message}

+

{getErrorTitle()}

{getErrorExplanation()}

From fc67419fe6d6c792a234b30283c4c7c3ce1f4166 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 07:39:33 +0100 Subject: [PATCH 20/27] Update for new plan id --- src/lib/constants.ts | 2 +- src/lib/stores/billing.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index caba065e05..2fc9104284 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -469,7 +469,7 @@ export enum BillingPlan { FREE = 'tier-0', PRO = 'tier-1', SCALE = 'tier-2', - GITHUB_EDUCATION = 'tier-3', + GITHUB_EDUCATION = 'auto-1', CUSTOM = 'cont-1' } diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 777460b7cb..e6688ea06a 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -34,7 +34,7 @@ import { user } from './user'; import { browser } from '$app/environment'; import { canSeeBilling } from './roles'; -export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'tier-3' | 'cont-1'; +export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1'; export const roles = [ { From 88e291e353df062f16430f517699717847606623 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 08:25:48 +0100 Subject: [PATCH 21/27] Update for mailinglist --- src/hooks.client.ts | 9 +++++++++ src/routes/+page.ts | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index c6404ee813..9d4ac94ba3 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -25,3 +25,12 @@ export const handleError: HandleClientError = Sentry.handleErrorWithSentry( }; } ); +const originalFetch = window.fetch; + +const customFetch = async (input, init = {}) => { + init.credentials = 'include'; + console.log('adjusted => ', input); + return originalFetch(input, init); +}; + +window.fetch = customFetch; diff --git a/src/routes/+page.ts b/src/routes/+page.ts index c2fd7a2a93..dbeb30a931 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -3,7 +3,7 @@ import { base } from '$app/paths'; import type { PageLoad } from './$types'; import { sdk } from '$lib/stores/sdk'; -const handleGithubEducationMembership = async () => { +const handleGithubEducationMembership = async (name: string, email: string) => { const result = await sdk.forConsole.billing.setMembership('github-student-developer'); if (result && 'error' in result) { await sdk.forConsole.account.deleteSession('current'); @@ -11,8 +11,8 @@ const handleGithubEducationMembership = async () => { 303, `${base}/education/error?message=${result.error.message}&code=${result.error.code}` ); - } else if (result && 'name' in result) { - await sdk.forConsole.billing.setMailinglist('gh-student', result.name, result.email); + } else if (result && '$createdAt' in result) { + await sdk.forConsole.billing.setMailinglist('gh-student', name, email); } }; @@ -27,8 +27,7 @@ export const load: PageLoad = async ({ parent, url }) => { const { organizations, account } = await parent(); if (userVisitedEducationPage()) { - console.log('account', account); - await handleGithubEducationMembership(); + await handleGithubEducationMembership(account.name, account.email); } if (organizations.total) { From 9f39892122db8d51e7f5088a099c645089ca0355 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 08:25:58 +0100 Subject: [PATCH 22/27] Update for mailinglist --- src/lib/sdk/billing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 15a3170b7d..66b2403cc7 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -710,7 +710,7 @@ export class Billing { async setMailinglist(listId: string, name: string, email: string): Promise { const path = `/mailinglists/${listId}`; - const uri = new URL(this.client.config.endpoint + path); + const uri = new URL('https://growth.appwrite.io/v1' + path); const params = { email, name @@ -728,7 +728,7 @@ export class Billing { async setMembership( programId: string - ): Promise<{ name: string; email: string } | { error: { code: number; message: string } }> { + ): Promise<{ $createdAt: string } | { error: { code: number; message: string } }> { const path = `/console/programs/${programId}/memberships`; const uri = new URL(this.client.config.endpoint + path); try { From fd45da45cd953800a65bb8b7add454b70013aa9e Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 08:26:12 +0100 Subject: [PATCH 23/27] Remove debug fetch --- src/hooks.client.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/hooks.client.ts b/src/hooks.client.ts index 9d4ac94ba3..c6404ee813 100644 --- a/src/hooks.client.ts +++ b/src/hooks.client.ts @@ -25,12 +25,3 @@ export const handleError: HandleClientError = Sentry.handleErrorWithSentry( }; } ); -const originalFetch = window.fetch; - -const customFetch = async (input, init = {}) => { - init.credentials = 'include'; - console.log('adjusted => ', input); - return originalFetch(input, init); -}; - -window.fetch = customFetch; From b003f6b1caa2b1811feacaeaa67700adb85e07b5 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 09:31:46 +0100 Subject: [PATCH 24/27] Fix empty name on github profile for mailinglist --- src/lib/sdk/billing.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index 66b2403cc7..ecc2e1a54a 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -711,10 +711,13 @@ export class Billing { async setMailinglist(listId: string, name: string, email: string): Promise { const path = `/mailinglists/${listId}`; const uri = new URL('https://growth.appwrite.io/v1' + path); - const params = { - email, - name - }; + const params = + name !== '' + ? { + email, + name + } + : { email }; return await this.client.call( 'POST', From 33f854b20303fe1b28dfd378430af6a593769246 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Mon, 28 Oct 2024 09:32:09 +0100 Subject: [PATCH 25/27] Don't await the mailing list result, and don't redirect to onboarding but straight to console --- src/routes/+page.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/+page.ts b/src/routes/+page.ts index dbeb30a931..0b6cd287ac 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -12,7 +12,7 @@ const handleGithubEducationMembership = async (name: string, email: string) => { `${base}/education/error?message=${result.error.message}&code=${result.error.code}` ); } else if (result && '$createdAt' in result) { - await sdk.forConsole.billing.setMailinglist('gh-student', name, email); + sdk.forConsole.billing.setMailinglist('gh-student', name, email); } }; @@ -28,9 +28,8 @@ export const load: PageLoad = async ({ parent, url }) => { if (userVisitedEducationPage()) { await handleGithubEducationMembership(account.name, account.email); - } - - if (organizations.total) { + redirect(303, base); + } else if (organizations.total) { const teamId = account.prefs.organization ?? organizations.teams[0].$id; if (!teamId) { redirect(303, `${base}/account/organizations${url.search}`); From eca8420c01e4ab9348b6fe7990f958ccf273e329 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 29 Oct 2024 08:25:53 +0100 Subject: [PATCH 26/27] Setting mailinglist from outside the sdk --- src/lib/sdk/billing.ts | 21 --------------------- src/routes/+page.ts | 14 +++++++++++++- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/lib/sdk/billing.ts b/src/lib/sdk/billing.ts index ecc2e1a54a..0908d7397d 100644 --- a/src/lib/sdk/billing.ts +++ b/src/lib/sdk/billing.ts @@ -708,27 +708,6 @@ export class Billing { ); } - async setMailinglist(listId: string, name: string, email: string): Promise { - const path = `/mailinglists/${listId}`; - const uri = new URL('https://growth.appwrite.io/v1' + path); - const params = - name !== '' - ? { - email, - name - } - : { email }; - - return await this.client.call( - 'POST', - uri, - { - 'content-type': 'application/json' - }, - params - ); - } - async setMembership( programId: string ): Promise<{ $createdAt: string } | { error: { code: number; message: string } }> { diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 0b6cd287ac..a62db4dd51 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -12,7 +12,7 @@ const handleGithubEducationMembership = async (name: string, email: string) => { `${base}/education/error?message=${result.error.message}&code=${result.error.code}` ); } else if (result && '$createdAt' in result) { - sdk.forConsole.billing.setMailinglist('gh-student', name, email); + setToGhStudentMailingList(name, email); } }; @@ -40,3 +40,15 @@ export const load: PageLoad = async ({ parent, url }) => { redirect(303, `${base}/onboarding${url.search}`); } }; + +const setToGhStudentMailingList = async (name: string, email: string) => { + const path = `/mailinglists/gh-student`; + const body = name !== '' ? { name, email } : { email }; + return fetch('https://growth.appwrite.io/v1' + path, { + method: 'POST', + body: JSON.stringify(body), + headers: { + 'Content-Type': 'application/json' + } + }); +}; From 1db31f18c0c4827d910a5701e040dba68e5d90e1 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Tue, 5 Nov 2024 10:29:38 +0100 Subject: [PATCH 27/27] Refactor images to css only solution --- .../(public)/(guest)/education/+layout.svelte | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/routes/(public)/(guest)/education/+layout.svelte b/src/routes/(public)/(guest)/education/+layout.svelte index aad678455c..abdb606e88 100644 --- a/src/routes/(public)/(guest)/education/+layout.svelte +++ b/src/routes/(public)/(guest)/education/+layout.svelte @@ -1,38 +1,10 @@ @@ -40,7 +12,14 @@
- +
+ + +
+
+ + +