Skip to content

Commit

Permalink
remove pro
Browse files Browse the repository at this point in the history
  • Loading branch information
srikavin committed May 6, 2024
1 parent 1ac591e commit bcff076
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 114 deletions.
34 changes: 2 additions & 32 deletions frontend/src/screens/LandingPageScreen/LandingPageScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function LandingPageScreen() {
className="absolute inset-0 bg-gradient-to-b from-red-50 to-blue-50 pointer-events-none border-t-2 border-b-2 border-amber-500"
aria-hidden="true"></div>
<div className="text-center relative max-w-6xl mx-auto px-4 sm:px-6 pb-12 gap-12">
<h2 className="h2 mb-4">Pay what you want.</h2>
<h2 className="h2 mb-4">Plans</h2>

<div className="flex justify-center gap-12">
<div className="w-64 p-4 bg-white shadow-lg rounded-2xl">
Expand All @@ -167,7 +167,7 @@ export function LandingPageScreen() {
Core features will always be free.
</p>
<ul className="w-full mt-6 mb-6 text-sm text-gray-600">
{["No Watch Limit", "Real-time Notifications", "Push Notifications", "Discord Notifications", "Web Hook Notifications"].map(x => (
{["No Watch Limit", "Real-time Notifications", "Push Notifications", "Discord Notifications", "Web Hook Notifications", "Email Notifications"].map(x => (
<li className="mb-3 flex gap-2 items-center" key={x}>
<Icon color="#10b981" size={24} icon={<TickCircleIcon/>}></Icon>
{x}
Expand All @@ -181,36 +181,6 @@ export function LandingPageScreen() {
</button>
</NavLink>
</div>
<div className="w-64 p-4 bg-white shadow-lg rounded-2xl">
<p className="mb-4 text-xl font-medium text-gray-800">
Pro
</p>
<p className="text-3xl font-bold text-gray-900">
$2.99
<span className="text-sm text-gray-300">/ semester</span>
</p>
<p className="mt-4 text-xs text-gray-600">
Support hosting costs and get access to expensive notification channels.
</p>
<ul className="w-full mt-6 mb-6 text-sm text-gray-600">
{["All Always Free Features", "Email Notifications", "Text Notifications"].map(x => (
<li className="mb-3 flex gap-2 items-center" key={x}>
<Icon color="#10b981" size={24} icon={<TickCircleIcon/>}></Icon>
{x}
</li>
))}
<li>&nbsp;</li>
<li>&nbsp;</li>
</ul>
<div>
<NavLink to={"/login"}>
<button type="button"
className="py-2 px-4 bg-indigo-600 hover:bg-indigo-700 focus:ring-indigo-500 focus:ring-offset-indigo-200 text-white w-full transition ease-in duration-200 text-center text-base font-semibold shadow-md focus:outline-none focus:ring-2 focus:ring-offset-2 rounded-lg ">
Register
</button>
</NavLink>
</div>
</div>
</div>
</div>
</section>
Expand Down
68 changes: 3 additions & 65 deletions frontend/src/screens/ProfileScreen/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function CurrentSubscriptions() {
}

export function NotificationSettingsBody() {
const {isAuthed, isPro, getUser} = useContext(AuthContext);
const {isAuthed, getUser} = useContext(AuthContext);

const [discordUrl, setDiscordUrl] = useState('');
const [email, setEmail] = useState('');
Expand Down Expand Up @@ -275,9 +275,8 @@ export function NotificationSettingsBody() {
onChange={(e: any) => setWebhookUrl(e.target.value)}
/>
<TextInputField
label="Email Notifications (Pro Only)"
description={`Receive email notifications ${!isPro ? "(Pro Plan only)" : ""}`}
disabled={!isPro}
label="Email Notifications"
description={`Receive email notifications`}
placeholder={getUser()?.email ?? "Email"}
value={email}
isInvalid={!isEmailValid}
Expand Down Expand Up @@ -348,58 +347,6 @@ function DeleteAccount() {
);
}

export function PaidPlan() {
const {isAuthed, getUser, isPro} = useContext(AuthContext);
const {semester, semesters} = useSemesterContext();

const [paidPlans, setPaidPlans] = useState<any>({});

useEffect(() => {
return onValue(ref(realtime_db, `user_settings/${getUser()?.uid}/paid_plan`), e => {
setPaidPlans(e.val() ?? {});
});
}, [semesters, isAuthed]);

const plan = isPro ? "Pro Tier" : "Always Free";

const buyButtonId = import.meta.env.DEV ? "buy_btn_1N4THPFyZ0MspKh2OH5rczga" : "buy_btn_1N4T5KFyZ0MspKh2ZZmuwlSd";
const publishableKey = import.meta.env.DEV ?
"pk_test_51N2zqNFyZ0MspKh2ziT2o0XlXZ9Ab9tczmlyeqX3iTrBygPsi6mUFOG0qCrdGR0bsHuVZBsJF2VZEDbu4GMDxH05007U7bSWDa" :
"pk_live_51N2zqNFyZ0MspKh2k6z4TTBrmqza1YpomBOa5MJemzMYLz9oVyZiD7hwMx9lIjnu53y7GbFzSFpN8zC2oi4LLIat00DYmRZjeW";

return (
<>
<Heading size={800}>Your Plan</Heading>
<Text>Your current Waitlist Watcher plan is <b>{plan}</b> for {semester.name}.</Text>
{plan !== "Pro Tier" && semester.id === "202401" &&
<div className="mt-4 mb-2">
<Text>
Upgrade to Pro for $2.99 / semester (charged once).
</Text>
<br/>
<stripe-buy-button
buy-button-id={buyButtonId}
publishable-key={publishableKey}
client-reference-id={getUser()?.uid}
customer-email={getUser()?.email}
></stripe-buy-button>
</div>
}
<div className="mt-2">
<Text>Your plan for other semesters: </Text>
{Object.keys(semesters).map(x => {
if (x === semester.name) return null;
return (
<div>
<Text>{semesters[x].name} - <b>{paidPlans[x] === "pro" ? "Pro Tier" : "Always Free"}</b></Text>
</div>
)
})}
</div>
</>
)
}

export function ProfileScreen() {
const {isAuthed, getUser} = useContext(AuthContext);
useTitle("User Settings");
Expand All @@ -422,20 +369,11 @@ export function ProfileScreen() {
description="Used only for login purposes"
value={getUser()?.email ?? ""}
/>
{/*<TextInputField*/}
{/* label="Password"*/}
{/* description="Change your password"*/}
{/* placeholder="*********"*/}
{/*/>*/}
</Pane>

<Button>Save</Button>
</Card>

<Card border="1px solid #c1c4d6" paddingY={20} paddingX={15}>
<PaidPlan/>
</Card>

<Card border="1px solid #c1c4d6" paddingY={20} paddingX={15}>
<NotificationSettings/>
</Card>
Expand Down
9 changes: 1 addition & 8 deletions functions/src/notifier/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,8 @@ export const sendNotifications = async (event: CloudEvent<MessagePublishedData>)
const subscription_methods = await rtdb.ref("user_settings/" + key).once('value');
if (!subscription_methods.exists()) continue;

const paid_plan = await rtdb.ref(`user_settings/${key}/paid_plan/${semester}`).once('value');
let pro = false;
if (paid_plan.exists() && paid_plan.val() === "pro") {
pro = true;
}

const sub_methods = subscription_methods.val();

promises.push(publishNotifications(sub_methods, key, event, pro));
promises.push(publishNotifications(sub_methods, key, event));
}
}

Expand Down
10 changes: 4 additions & 6 deletions functions/src/notifier/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const sendEmailNotification = async (email: string, event: CourseEvent |
}), event);
}

export const publishNotifications = async (sub_methods: any, key: string, event: CourseEvent | TestNotificationEvent, is_pro: boolean) => {
export const publishNotifications = async (sub_methods: any, key: string, event: CourseEvent | TestNotificationEvent) => {
const promises = [];
if (sub_methods.web_hook) {
console.log("Notifying", key, "through a web hook");
Expand All @@ -92,11 +92,9 @@ export const publishNotifications = async (sub_methods: any, key: string, event:
console.log("Notifying", key, "through a discord web hook")
promises.push(sendDiscordNotification(sub_methods.discord, event));
}
if (is_pro) {
if (sub_methods.email) {
console.log("Notifying", key, "through an email")
promises.push(sendEmailNotification(sub_methods.email, event, key));
}
if (sub_methods.email) {
console.log("Notifying", key, "through an email")
promises.push(sendEmailNotification(sub_methods.email, event, key));
}

return Promise.all(promises);
Expand Down
4 changes: 1 addition & 3 deletions functions/src/notifier/test_notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export async function testNotify(data: any, context: CallableContext) {
const subscription_methods = await rtdb.ref("user_settings/" + userid).once('value');
if (!subscription_methods.exists()) return;

const pro = (await rtdb.ref(`user_settings/${userid}/paid_plan/`).once('value')).exists();

const sub_methods = subscription_methods.val();

await publishNotifications(sub_methods, userid, {
Expand All @@ -26,7 +24,7 @@ export async function testNotify(data: any, context: CallableContext) {
section: "101",
new: "New Value",
old: "Old Value",
}, pro);
});

return {success: true};
}

0 comments on commit bcff076

Please sign in to comment.