Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub education program into console #1389

Merged
merged 31 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3e3db7a
Work in progress login page
ernstmul Oct 1, 2024
484daab
Fix styling login page
ernstmul Oct 1, 2024
a8a9e4c
WIP on membership call
ernstmul Oct 3, 2024
848c1df
Quick UI change to show education badge
ernstmul Oct 3, 2024
bad5650
Set correct constant for new tier-3
ernstmul Oct 3, 2024
0be3489
Final plan changes
ernstmul Oct 3, 2024
205f97c
Change import of image
ernstmul Oct 3, 2024
86f56da
Update width and background color of divider
ernstmul Oct 3, 2024
7180631
Make gradient bit more visible
ernstmul Oct 3, 2024
eef885d
Add to Organization screen
ernstmul Oct 3, 2024
1c37470
Remove tier-3 override
ernstmul Oct 7, 2024
ba11128
Fix undefined for Education program billing
ernstmul Oct 7, 2024
9cdb37d
Add error page for membership call result, and add logic for extra us…
ernstmul Oct 8, 2024
66e40a7
Remove test code
ernstmul Oct 8, 2024
c82493b
Remove console.log
ernstmul Oct 8, 2024
84d940b
Remove unused imports
ernstmul Oct 8, 2024
00800c5
Add to mailinglist
ernstmul Oct 10, 2024
e37064f
Merge branch 'main' into feat-prop-1297-login-for-github-education-pr…
ernstmul Oct 16, 2024
784a789
Add mailinglist call
ernstmul Oct 18, 2024
f3438d5
text updates
ernstmul Oct 18, 2024
3acc644
Merge branch 'main' into feat-prop-1297-login-for-github-education-pr…
ernstmul Oct 21, 2024
e2e248a
Merge branch 'main' into feat-prop-1297-login-for-github-education-pr…
ernstmul Oct 28, 2024
fc67419
Update for new plan id
ernstmul Oct 28, 2024
88e291e
Update for mailinglist
ernstmul Oct 28, 2024
9f39892
Update for mailinglist
ernstmul Oct 28, 2024
fd45da4
Remove debug fetch
ernstmul Oct 28, 2024
b003f6b
Fix empty name on github profile for mailinglist
ernstmul Oct 28, 2024
33f854b
Don't await the mailing list result, and don't redirect to onboarding…
ernstmul Oct 28, 2024
eca8420
Setting mailinglist from outside the sdk
ernstmul Oct 29, 2024
e14a0a3
Merge branch 'main' into feat-prop-1297-login-for-github-education-pr…
ernstmul Nov 4, 2024
1db31f1
Refactor images to css only solution
ernstmul Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export enum BillingPlan {
FREE = 'tier-0',
PRO = 'tier-1',
SCALE = 'tier-2',
GITHUB_EDUCATION = 'auto-1',
CUSTOM = 'cont-1'
}

Expand Down
87 changes: 87 additions & 0 deletions src/lib/images/github-education-program/artwork-dark-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions src/lib/images/github-education-program/artwork-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions src/lib/images/github-education-program/artwork-light-mobile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions src/lib/images/github-education-program/artwork-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/lib/images/github-education-program/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ArtworkDark from './artwork-dark.svg';
import ArtworkDarkMobile from './artwork-dark-mobile.svg';
import ArtworkLight from './artwork-light.svg';
import ArtworkLightMobile from './artwork-light-mobile.svg';

export { ArtworkDark, ArtworkDarkMobile, ArtworkLight, ArtworkLightMobile };
4 changes: 4 additions & 0 deletions src/lib/images/github-logo-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/lib/images/github-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions src/lib/sdk/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,20 @@ export class Billing {
);
}

async setMembership(
programId: 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 {
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<Coupon> {
const path = `/console/coupons/${couponId}`;
const params = {
Expand Down
9 changes: 8 additions & 1 deletion src/lib/stores/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' | 'cont-1';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2' | 'auto-1' | 'cont-1';

export const roles = [
{
Expand Down Expand Up @@ -77,6 +77,8 @@ export function tierToPlan(tier: Tier) {
return tierPro;
case BillingPlan.SCALE:
return tierScale;
case BillingPlan.GITHUB_EDUCATION:
return tierGitHubEducation;
case BillingPlan.CUSTOM:
return tierCustom;
default:
Expand Down Expand Up @@ -175,6 +177,11 @@ export const tierFree: TierData = {
description: 'For personal hobby projects of small scale and students.'
};

export const tierGitHubEducation: TierData = {
name: 'GitHub Education',
description: 'For members of GitHub student developers program.'
};

export const tierPro: TierData = {
name: 'Pro',
description: 'For pro developers and production projects that need the ability to scale.'
Expand Down
1 change: 1 addition & 0 deletions src/lib/stores/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const organizationList = derived(
page,
($page) => $page.data.organizations as Models.TeamList<Record<string, unknown>>
);

export const organization = derived(page, ($page) => $page.data?.organization as Organization);
export const members = derived(page, ($page) => $page.data.members as Models.MembershipList);
7 changes: 4 additions & 3 deletions src/routes/(console)/account/organizations/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -71,14 +71,15 @@
</svelte:fragment>
<svelte:fragment slot="status">
{#if isCloudOrg(organization)}
{#if organization?.billingPlan === BillingPlan.FREE}
{#if organization?.billingPlan === BillingPlan.FREE || organization?.billingPlan === BillingPlan.GITHUB_EDUCATION}
<div
class="u-flex u-cross-center"
use:tooltip={{
content:
'You are limited to 1 free organization per account'
}}>
<Pill class="eyebrow-heading-3">FREE</Pill>
<Pill class="eyebrow-heading-3"
>{tierToPlan(organization?.billingPlan)?.name}</Pill>
</div>
{/if}
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlan !== BillingPlan.FREE && $plansInfo.get(organization.billingPlan)?.trialDays}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@
<span class="body-text-2">
{tierToPlan($organization?.billingPlan)?.name} plan</span>
<div class="body-text-2 u-margin-inline-start-auto">
{isTrial
{isTrial || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION
? formatCurrency(0)
: currentPlan
? formatCurrency(currentPlan?.price)
: ''}
</div>
</CollapsibleItem>
{#if $organization?.billingPlan !== BillingPlan.FREE && extraUsage > 0}
{#if $organization?.billingPlan !== BillingPlan.FREE && $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION && extraUsage > 0}
<CollapsibleItem isInfo gap={8}>
<svelte:fragment slot="beforetitle">
<span class="body-text-2"><b>Add-ons</b></span><span class="inline-tag"
Expand Down Expand Up @@ -188,7 +188,8 @@
}}></span>
</span>
<div class="body-text-2 u-margin-inline-start-auto">
{$organization?.billingPlan === BillingPlan.FREE
{$organization?.billingPlan === BillingPlan.FREE ||
$organization?.billingPlan === BillingPlan.GITHUB_EDUCATION
? formatCurrency(0)
: formatCurrency(
Math.max(
Expand Down Expand Up @@ -218,7 +219,7 @@
Upgrade
</Button>
</div>
{:else}
{:else if $organization?.billingPlan !== BillingPlan.GITHUB_EDUCATION}
<div class="u-flex u-gap-16 u-flex-wrap">
<Button
text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@
<span class="u-trim">
{$organization.name}
</span>
{#if isCloud && $organization?.billingPlan === BillingPlan.FREE}
{#if isCloud && $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION}
<Pill class="eyebrow-heading-3"
><span class="icon-github" aria-hidden="true" /> EDUCATION</Pill>
{:else if isCloud && $organization?.billingPlan === BillingPlan.FREE}
<Pill class="eyebrow-heading-3">FREE</Pill>
{/if}
{#if isCloud && $organization?.billingTrialStartDate && $daysLeftInTrial > 0 && $organization.billingPlan !== BillingPlan.FREE && $plansInfo.get($organization.billingPlan)?.trialDays}
Expand Down
108 changes: 108 additions & 0 deletions src/routes/(public)/(guest)/education/+layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<script lang="ts">
import {
ArtworkDark,
ArtworkDarkMobile,
ArtworkLightMobile,
ArtworkLight
} from '$lib/images/github-education-program';
</script>

<svelte:head>
<title>Sign up - Appwrite Education Program</title>
</svelte:head>
<section class="github-education-container">
<div class="artwork">
<div class="is-only-mobile">
<img src={ArtworkDarkMobile} alt="" class=" u-only-dark" />
<img src={ArtworkLightMobile} alt="" class="u-only-light" />
</div>
<div class="is-not-mobile">
<img src={ArtworkDark} alt="" class="u-only-dark" />
<img src={ArtworkLight} alt="" class="u-only-light" />
</div>
<div class="mobile-gradient" />
</div>
<div class="content-container">
<slot />
</div>
</section>

<style>
:global(.theme-dark) {
--gradient-start-color: #0c0c0d;
--heading-color: inherit;
--text-color: #e4e4e7a3;
--divider-background-color: rgba(255, 255, 255, 0.06);
}
:global(.theme-light) {
--gradient-start-color: #ededf0;
--heading-color: #19191c;
--text-color: #19191ca3;
--divider-background-color: rgba(25, 25, 28, 0.04);
}

.github-education-container {
display: flex;
flex-direction: column;

@media (min-width: 768px) {
flex-direction: row;
}
}

.artwork {
height: 16.5rem;
width: 100%;
display: flex;
justify-content: center;

@media (min-width: 768px) {
width: 50%;
min-height: 100vh;
background: linear-gradient(
56deg,
rgba(253, 54, 110, 0.15) 0%,
var(--gradient-start-color) 48.38%
);

display: flex;
justify-content: center;
align-items: center;
}
}

.artwork .mobile-gradient {
@media (max-width: 768px) {
background: linear-gradient(
180deg,
rgba(25, 25, 28, 0) -4.43%,
hsl(var(--p-body-bg-color)) 100%
);
position: absolute;
width: 100%;
height: 16.5rem;
}
}

.artwork img {
width: 100%;

@media (min-width: 768px) {
max-width: 500px;
height: 100%;
}
}

.content-container {
background-color: hsl(var(--p-body-bg-color));
width: 100%;
padding: 1rem;

@media (min-width: 768px) {
width: 50%;
display: flex;
align-items: center;
justify-content: center;
}
}
</style>
Loading
Loading