Skip to content

Commit

Permalink
don't send gift card automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiAbdou committed Sep 27, 2024
1 parent 33e8a6d commit 25ddce1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
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
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"./resumes/ui": "./src/modules/resume/resume.ui.tsx",
"./scholarships": "./src/modules/scholarship/scholarship.core.ts",
"./scholarships/ui": "./src/modules/scholarship/scholarship.ui.tsx",
"./shopify": "./src/modules/shopify.ts",
"./slack/server": "./src/modules/slack/index.server.ts"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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 { getSwagPackInventory } from '@/modules/swag-pack/swag-pack.service';
import { ENV } from '@/shared/env';
import { ErrorWithContext } from '@/shared/errors';

Expand Down Expand Up @@ -226,19 +225,12 @@ async function sendProgressNotification({
let message: string;

if (completedRequirements === totalRequirements) {
const inventory = await getSwagPackInventory();

const action =
inventory >= 1
? 'You can now claim a free swag pack in your <https://app.colorstack.io/home/claim-swag-pack|*Member Profile*>! 🎁'
: 'Look out for an email for a $50 gift card to the <ColorStack Merch Store|https://colorstackmerch.org>! 🤑';

message = dedent`
Congratulations, ${firstName}! 🎉
You've completed all of your activation requirements, which means...you are now an *activated* ColorStack member.
${action}
You can now claim your free ColorStack merch <https://app.colorstack.io/home/claim-swag-pack|*here*>! 🎁
`;
} else {
message = dedent`
Expand Down
18 changes: 0 additions & 18 deletions packages/core/src/modules/member/events/member-activated.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import dayjs from 'dayjs';

import { db } from '@oyster/db';

import { type GetBullJobData } from '@/infrastructure/bull/bull.types';
import { job } from '@/infrastructure/bull/use-cases/job';
import { createGiftCard } from '@/modules/shopify';

export async function onMemberActivated({
studentId,
Expand All @@ -15,21 +12,6 @@ export async function onMemberActivated({
.where('id', '=', studentId)
.executeTakeFirstOrThrow();

const giftCardResult = await createGiftCard({
expiresOn: dayjs().add(1, 'week').format('YYYY-MM-DD'),
initialValue: '50.00',
note: 'This is for member activation.',
recipient: {
email: member.email,
firstName: member.firstName,
lastName: member.lastName,
},
});

if (!giftCardResult.ok) {
throw new Error(giftCardResult.error);
}

job('gamification.activity.completed', {
studentId: member.id,
type: 'get_activated',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/shopify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SHOPIFY_HEADERS = {
};

/**
* @see https://docs.anthropic.com/en/api/rate-limits#rate-limits
* @see https://shopify.dev/docs/api/admin-rest#rate_limits
*/
const shopifyRateLimiter = new RateLimiter('shopify:requests', {
rateLimit: 2,
Expand Down

0 comments on commit 25ddce1

Please sign in to comment.