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

feat: migrate from swag up to shopify 🎁 #527

Merged
merged 11 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions apps/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ STUDENT_PROFILE_URL=http://localhost:3000
# R2_BUCKET_NAME=
# R2_SECRET_ACCESS_KEY=
# SENTRY_DSN=
# SHOPIFY_ACCESS_TOKEN=
# SHOPIFY_STORE_NAME=
# SLACK_ANNOUNCEMENTS_CHANNEL_ID=
# SLACK_ADMIN_TOKEN=
# SLACK_BIRTHDATE_FIELD_ID=
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/shared/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const BaseEnvironmentConfig = z.object({
R2_SECRET_ACCESS_KEY: EnvironmentVariable,
REDIS_URL: EnvironmentVariable,
SENTRY_DSN: EnvironmentVariable,
SHOPIFY_ACCESS_TOKEN: EnvironmentVariable,
SHOPIFY_STORE_NAME: EnvironmentVariable,
SLACK_ANNOUNCEMENTS_CHANNEL_ID: EnvironmentVariable,
SLACK_ADMIN_TOKEN: EnvironmentVariable,
SLACK_BIRTHDATE_FIELD_ID: EnvironmentVariable,
Expand Down Expand Up @@ -84,6 +86,8 @@ const EnvironmentConfig = z.discriminatedUnion('ENVIRONMENT', [
R2_BUCKET_NAME: true,
R2_SECRET_ACCESS_KEY: true,
SENTRY_DSN: true,
SHOPIFY_ACCESS_TOKEN: true,
SHOPIFY_STORE_NAME: true,
SLACK_ANNOUNCEMENTS_CHANNEL_ID: true,
SLACK_ADMIN_TOKEN: true,
SLACK_BIRTHDATE_FIELD_ID: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,32 @@ export default function ClaimSwagPack() {

return (
<>
<Modal.Header>
<Modal.Title>Claim Your Swag Pack 🎁</Modal.Title>
<Modal.CloseButton />
</Modal.Header>

<Suspense fallback={<LoadingState />}>
<Await resolve={inventoryPromise}>
{(inventory) => {
return inventory > 0 ? (
<ClaimSwagPackForm />
<>
<Modal.Header>
<Modal.Title>Claim Your Swag Pack 🎁</Modal.Title>
<Modal.CloseButton />
</Modal.Header>

<ClaimSwagPackForm />
</>
) : (
<Modal.Description>
Unfortunately, we ran out of swag pack inventory. However, we're
restocking ASAP and you should be able to claim a pack in the
next 2-4 weeks. Sorry about any inconvenience and thank you for
your patience!
</Modal.Description>
<>
<Modal.Header>
<Modal.Title>
Sit tight, we're sending you a gift card! πŸ€‘
</Modal.Title>
<Modal.CloseButton />
</Modal.Header>

<Modal.Description>
We're changing the way we send out swag. Give us 2 business
days and we'll send you a gift card to our Merch Store!
</Modal.Description>
</>
);
}}
</Await>
Expand Down
31 changes: 1 addition & 30 deletions apps/member-profile/app/routes/_profile.home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,14 @@ export default function HomeLayout() {
const showOnboardingCard =
!!student.joinedAfterActivation && !student.onboardedAt;

const showSwagCard =
!!student.joinedAfterActivation &&
!!student.activatedAt &&
!student.claimedSwagPackAt;

return (
<>
<Text variant="2xl">Hey, {student.firstName}! πŸ‘‹</Text>

{(showActivationCard || showOnboardingCard || showSwagCard) && (
{(showActivationCard || showOnboardingCard) && (
<>
<div className="grid grid-cols-1 items-start gap-4 @[1000px]:grid-cols-2 @[1500px]:grid-cols-3">
{showActivationCard && <ActivationCard />}
{showSwagCard && <ClaimSwagPackCard />}
{showOnboardingCard && <OnboardingSessionCard />}
</div>

Expand Down Expand Up @@ -348,29 +342,6 @@ function ActiveStatusCard() {
);
}

function ClaimSwagPackCard() {
return (
<Card>
<Card.Title>Claim Swag Pack 🎁</Card.Title>

<Card.Description>
Congratulations on becoming an activated ColorStack member! As a thank
you for engaging in the community, we would love to send you a
ColorStack swag pack.
</Card.Description>

<Button.Group>
<Link
className={getButtonCn({ variant: 'primary' })}
to={Route['/home/claim-swag-pack']}
>
Claim Swag Pack
</Link>
</Button.Group>
</Card>
);
}

function OnboardingSessionCard() {
return (
<Card>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"./gamification/types": "./src/modules/gamification/gamification.types.ts",
"./gamification/ui": "./src/modules/gamification/gamification.ui.tsx",
"./github": "./src/modules/github/github.ts",
"./goody": "./src/modules/goody/goody.ts",
"./goody": "./src/modules/goody.ts",
"./location": "./src/modules/location/location.core.ts",
"./location/types": "./src/modules/location/location.types.ts",
"./location/ui": "./src/modules/location/location.ui.tsx",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { db } from '@oyster/db';
import { ActivationRequirement, type Student } from '@oyster/types';

import { job } from '@/infrastructure/bull/use-cases/job';
import { activateMember } from '@/modules/member/use-cases/activate-member';
import { ENV } from '@/shared/env';
import { ErrorWithContext } from '@/shared/errors';

Expand Down Expand Up @@ -78,7 +79,7 @@ export async function onActivationStepCompleted(
});

if (activated) {
await activateStudent(studentId);
await activateMember(studentId);
}

const [newRequirementCompleted] = updatedCompletedRequirements.filter(
Expand Down Expand Up @@ -212,18 +213,6 @@ async function updateCompletedRequirements(studentId: string) {
return updatedRequirements;
}

async function activateStudent(id: string) {
await db
.updateTable('students')
.set({ activatedAt: new Date() })
.where('id', '=', id)
.execute();

job('student.activated', {
studentId: id,
});
}

async function sendProgressNotification({
activationRequirementsCompleted,
firstName,
Expand All @@ -241,7 +230,7 @@ async function sendProgressNotification({

You've completed all of your activation requirements, which means...you are now an *activated* ColorStack member.

You can now claim your free swag pack in your <https://app.colorstack.io/home|*Member Profile*>! 🎁
You can now claim your free ColorStack merch <https://app.colorstack.io/home/claim-swag-pack|*here*>! 🎁
`;
} else {
message = dedent`
Expand Down
10 changes: 0 additions & 10 deletions packages/core/src/modules/member/events/member-activated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { db } from '@oyster/db';

import { type GetBullJobData } from '@/infrastructure/bull/bull.types';
import { job } from '@/infrastructure/bull/use-cases/job';
import { ENV } from '@/shared/env';

export async function onMemberActivated({
studentId,
Expand All @@ -17,13 +16,4 @@ export async function onMemberActivated({
studentId: student.id,
type: 'get_activated',
});

job('notification.email.send', {
data: {
firstName: student.firstName,
studentProfileUrl: ENV.STUDENT_PROFILE_URL,
},
name: 'student-activated',
to: student.email,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ReferralAcceptedEmail,
ReferralSentEmail,
ResumeSubmittedEmail,
StudentActivatedEmail,
StudentAttendedOnboardingEmail,
StudentRemovedEmail,
} from '@oyster/email-templates';
Expand Down Expand Up @@ -73,7 +72,6 @@ async function sendEmailWithPostmark(input: EmailTemplate) {
.with('resume-submitted', () => FROM_NOTIFICATIONS)
.with('referral-accepted', () => FROM_NOTIFICATIONS)
.with('referral-sent', () => FROM_NOTIFICATIONS)
.with('student-activated', () => FROM_NOTIFICATIONS)
.with('student-attended-onboarding', () => FROM_NOTIFICATIONS)
.with('student-removed', () => FROM_NOTIFICATIONS)
.exhaustive();
Expand Down Expand Up @@ -149,9 +147,6 @@ function getHtml(input: EmailTemplate): string {
.with({ name: 'resume-submitted' }, ({ data }) => {
return ResumeSubmittedEmail(data);
})
.with({ name: 'student-activated' }, ({ data }) => {
return StudentActivatedEmail(data);
})
.with({ name: 'student-attended-onboarding' }, ({ data }) => {
return StudentAttendedOnboardingEmail(data);
})
Expand Down Expand Up @@ -191,9 +186,6 @@ function getSubject(input: EmailTemplate): string {
.with({ name: 'resume-submitted' }, ({ data }) => {
return `Confirmation: ${data.resumeBookName} Resume Book! βœ…`;
})
.with({ name: 'student-activated' }, () => {
return 'Swag Pack 😜';
})
.with({ name: 'student-attended-onboarding' }, () => {
return "Onboarding Session, βœ…! What's Next?";
})
Expand Down Expand Up @@ -229,7 +221,6 @@ async function getAttachments(
{ name: 'referral-accepted' },
{ name: 'referral-sent' },
{ name: 'resume-submitted' },
{ name: 'student-activated' },
{ name: 'student-removed' },
() => {
return undefined;
Expand Down
Loading
Loading