Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit bb4383d

Browse files
authored
feat: premium plan for all (#10361)
* feat: removed premium plan * fix: failing test
1 parent 8da58a5 commit bb4383d

File tree

11 files changed

+30
-89
lines changed

11 files changed

+30
-89
lines changed

components/layouts/MultiLayout.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export default function MultiLayout({ settings, children }) {
88
<>
99
<SkipLink />
1010
<div className="flex flex-col min-h-screen">
11-
{(!settings ||
12-
settings.type === "free" ||
13-
(settings.type === "premium" && !settings.hideNavbar)) && (
11+
{(!settings || !settings.hideNavbar) && (
1412
<>
1513
<Alert />
1614
<Navbar />
@@ -19,9 +17,7 @@ export default function MultiLayout({ settings, children }) {
1917
<main id="main" className="flex-1 dark:bg-dark-2 dark:z-40">
2018
{children}
2119
</main>
22-
{(!settings ||
23-
settings.type === "free" ||
24-
(settings.type === "premium" && !settings.hideFooter)) && <Footer />}
20+
{(!settings || !settings.hideFooter) && <Footer />}
2521
</div>
2622
</>
2723
);

middleware.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export async function middleware(req) {
5454

5555
if (
5656
profile?.username &&
57-
profile.user.type === "premium" &&
5857
profile.settings?.domain &&
5958
profile.settings.domain === hostname
6059
) {

pages/account/manage/premium.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function ManageSettings({
5959
const [domain, setDomain] = useState(
6060
settings.domain?.replaceAll("|", ".") || "",
6161
); // TODO: use getter/setter instead
62-
const [enableForm] = useState(accountType === "premium" ? true : false);
62+
const [enableForm] = useState(false);
6363

6464
const handleSubmit = async (e) => {
6565
e.preventDefault();

pages/account/statistics/index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default function Statistics({ data, profile, BASE_URL }) {
116116
</div>
117117
)}
118118

119-
{session && session.accountType === "premium" && profile.stats && (
119+
{session && profile.stats && (
120120
<ul
121121
role="list"
122122
className="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-2 xl:gap-x-8 mb-8"
@@ -208,14 +208,9 @@ export default function Statistics({ data, profile, BASE_URL }) {
208208
data.links.individual.map((link) => (
209209
<tr key={link._id}>
210210
<td className="md:whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-primary-high dark:text-primary-low sm:pl-6 text-ellipsis overflow-hidden">
211-
{session && session.accountType === "premium" && (
212-
<Link href={`/account/statistics/link/${link._id}`}>
213-
{link.url}
214-
</Link>
215-
)}
216-
{session && session.accountType === "free" && (
217-
<>{link.url}</>
218-
)}
211+
<Link href={`/account/statistics/link/${link._id}`}>
212+
{link.url}
213+
</Link>
219214
</td>
220215
<td className="whitespace-nowrap px-3 py-4 text-sm text-primary-medium dark:text-primary-low">
221216
{abbreviateNumber(link.clicks)}

pages/account/statistics/link/[id].js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ const DynamicChart = dynamic(
1919
export async function getServerSideProps(context) {
2020
const { req, res } = context;
2121
const session = await getServerSession(req, res, authOptions);
22-
if (session.accountType !== "premium") {
23-
return {
24-
redirect: {
25-
destination: "/account/onboarding",
26-
permanent: false,
27-
},
28-
};
29-
}
3022

3123
const username = session.username;
3224
const { status, profile } = await getUserApi(req, res, username);

pages/account/statistics/locations.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ export async function getServerSideProps(context) {
2020
const { req, res } = context;
2121
const session = await getServerSession(req, res, authOptions);
2222

23-
if (session.accountType !== "premium") {
24-
return {
25-
redirect: {
26-
destination: "/account/onboarding",
27-
permanent: false,
28-
},
29-
};
30-
}
31-
3223
const username = session.username;
3324
const { status, profile } = await getUserApi(req, res, username);
3425
if (status !== 200) {

pages/account/statistics/referers.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ export async function getServerSideProps(context) {
2020
const { req, res } = context;
2121
const session = await getServerSession(req, res, authOptions);
2222

23-
if (session.accountType !== "premium") {
24-
return {
25-
redirect: {
26-
destination: "/account/onboarding",
27-
permanent: false,
28-
},
29-
};
30-
}
31-
3223
const username = session.username;
3324
const { status, profile } = await getUserApi(req, res, username);
3425
if (status !== 200) {

pages/api/account/statistics/link/[id].js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ export default async function handler(req, res) {
1515
.json({ error: "Invalid request: GET request required" });
1616
}
1717

18-
if (session.accountType !== "premium") {
19-
res.status(401).json({ message: "You must have a Premium account." });
20-
}
21-
2218
const data = await getStatsForLink(session.username, req.query.id);
2319
if (data.error) {
2420
res.status(400).json({ error: data.error });

pages/pricing.js

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -87,30 +87,9 @@ export default function Premium({ user }) {
8787
return "Join Premium plan";
8888
}
8989
},
90-
action: () => {
91-
if (user.isLoggedIn && user.accountType === "premium") {
92-
return "/api/stripe";
93-
}
94-
if (user.isLoggedIn && user.accountType === "free") {
95-
return "/api/stripe";
96-
}
97-
if (!user.isLoggedIn) {
98-
return "/auth/signin";
99-
}
100-
},
101-
isDisabled: () => {
102-
if (user.isLoggedIn && user.accountType === "premium") {
103-
return true;
104-
}
105-
return false;
106-
},
107-
onClick: () => {
108-
if (typeof window !== "undefined" && window.localStorage) {
109-
if (user.accountType !== "premium") {
110-
localStorage.setItem("premium-intent", true);
111-
}
112-
}
113-
},
90+
action: () => "/auth/signin",
91+
isDisabled: () => true,
92+
onClick: () => {},
11493
},
11594
},
11695
];

tests/account/stats/location.spec.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ test("Guest user cannot access premium locations stats", async ({
1818
await expect(page).toHaveURL("/auth/signin");
1919
});
2020

21-
test("Logged in free user cannot access premium locations stats", async ({
22-
browser,
23-
}) => {
24-
const context = await login(browser);
25-
const page = await context.newPage();
26-
await page.goto("/account/statistics/locations");
27-
await page.waitForLoadState("domcontentloaded");
28-
await expect(page).toHaveURL(/account\/onboarding/);
29-
});
21+
// THIS PREMIUM IS BEING GIVEN TO EVERYONE
22+
// test("Logged in free user cannot access premium locations stats", async ({
23+
// browser,
24+
// }) => {
25+
// const context = await login(browser);
26+
// const page = await context.newPage();
27+
// await page.goto("/account/statistics/locations");
28+
// await page.waitForLoadState("domcontentloaded");
29+
// await expect(page).toHaveURL(/account\/onboarding/);
30+
// });
3031

3132
test("Logged in premium user can access premium locations stats", async ({
3233
browser,

0 commit comments

Comments
 (0)