Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

feat: removed premium plan #10361

Merged
merged 2 commits into from
May 13, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions components/layouts/MultiLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export default function MultiLayout({ settings, children }) {
<>
<SkipLink />
<div className="flex flex-col min-h-screen">
{(!settings ||
settings.type === "free" ||
(settings.type === "premium" && !settings.hideNavbar)) && (
{(!settings || !settings.hideNavbar) && (
<>
<Alert />
<Navbar />
Expand All @@ -19,9 +17,7 @@ export default function MultiLayout({ settings, children }) {
<main id="main" className="flex-1 dark:bg-dark-2 dark:z-40">
{children}
</main>
{(!settings ||
settings.type === "free" ||
(settings.type === "premium" && !settings.hideFooter)) && <Footer />}
{(!settings || !settings.hideFooter) && <Footer />}
</div>
</>
);
Expand Down
1 change: 0 additions & 1 deletion middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export async function middleware(req) {

if (
profile?.username &&
profile.user.type === "premium" &&
profile.settings?.domain &&
profile.settings.domain === hostname
) {
Expand Down
2 changes: 1 addition & 1 deletion pages/account/manage/premium.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function ManageSettings({
const [domain, setDomain] = useState(
settings.domain?.replaceAll("|", ".") || "",
); // TODO: use getter/setter instead
const [enableForm] = useState(accountType === "premium" ? true : false);
const [enableForm] = useState(false);

const handleSubmit = async (e) => {
e.preventDefault();
Expand Down
13 changes: 4 additions & 9 deletions pages/account/statistics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function Statistics({ data, profile, BASE_URL }) {
</div>
)}

{session && session.accountType === "premium" && profile.stats && (
{session && profile.stats && (
<ul
role="list"
className="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-2 xl:gap-x-8 mb-8"
Expand Down Expand Up @@ -208,14 +208,9 @@ export default function Statistics({ data, profile, BASE_URL }) {
data.links.individual.map((link) => (
<tr key={link._id}>
<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">
{session && session.accountType === "premium" && (
<Link href={`/account/statistics/link/${link._id}`}>
{link.url}
</Link>
)}
{session && session.accountType === "free" && (
<>{link.url}</>
)}
<Link href={`/account/statistics/link/${link._id}`}>
{link.url}
</Link>
</td>
<td className="whitespace-nowrap px-3 py-4 text-sm text-primary-medium dark:text-primary-low">
{abbreviateNumber(link.clicks)}
Expand Down
8 changes: 0 additions & 8 deletions pages/account/statistics/link/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ const DynamicChart = dynamic(
export async function getServerSideProps(context) {
const { req, res } = context;
const session = await getServerSession(req, res, authOptions);
if (session.accountType !== "premium") {
return {
redirect: {
destination: "/account/onboarding",
permanent: false,
},
};
}

const username = session.username;
const { status, profile } = await getUserApi(req, res, username);
Expand Down
9 changes: 0 additions & 9 deletions pages/account/statistics/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ export async function getServerSideProps(context) {
const { req, res } = context;
const session = await getServerSession(req, res, authOptions);

if (session.accountType !== "premium") {
return {
redirect: {
destination: "/account/onboarding",
permanent: false,
},
};
}

const username = session.username;
const { status, profile } = await getUserApi(req, res, username);
if (status !== 200) {
Expand Down
9 changes: 0 additions & 9 deletions pages/account/statistics/referers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ export async function getServerSideProps(context) {
const { req, res } = context;
const session = await getServerSession(req, res, authOptions);

if (session.accountType !== "premium") {
return {
redirect: {
destination: "/account/onboarding",
permanent: false,
},
};
}

const username = session.username;
const { status, profile } = await getUserApi(req, res, username);
if (status !== 200) {
Expand Down
4 changes: 0 additions & 4 deletions pages/api/account/statistics/link/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export default async function handler(req, res) {
.json({ error: "Invalid request: GET request required" });
}

if (session.accountType !== "premium") {
res.status(401).json({ message: "You must have a Premium account." });
}

const data = await getStatsForLink(session.username, req.query.id);
if (data.error) {
res.status(400).json({ error: data.error });
Expand Down
27 changes: 3 additions & 24 deletions pages/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,9 @@ export default function Premium({ user }) {
return "Join Premium plan";
}
},
action: () => {
if (user.isLoggedIn && user.accountType === "premium") {
return "/api/stripe";
}
if (user.isLoggedIn && user.accountType === "free") {
return "/api/stripe";
}
if (!user.isLoggedIn) {
return "/auth/signin";
}
},
isDisabled: () => {
if (user.isLoggedIn && user.accountType === "premium") {
return true;
}
return false;
},
onClick: () => {
if (typeof window !== "undefined" && window.localStorage) {
if (user.accountType !== "premium") {
localStorage.setItem("premium-intent", true);
}
}
},
action: () => "/auth/signin",
isDisabled: () => true,
onClick: () => {},
},
},
];
Expand Down
19 changes: 10 additions & 9 deletions tests/account/stats/location.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ test("Guest user cannot access premium locations stats", async ({
await expect(page).toHaveURL("/auth/signin");
});

test("Logged in free user cannot access premium locations stats", async ({
browser,
}) => {
const context = await login(browser);
const page = await context.newPage();
await page.goto("/account/statistics/locations");
await page.waitForLoadState("domcontentloaded");
await expect(page).toHaveURL(/account\/onboarding/);
});
// THIS PREMIUM IS BEING GIVEN TO EVERYONE
// test("Logged in free user cannot access premium locations stats", async ({
// browser,
// }) => {
// const context = await login(browser);
// const page = await context.newPage();
// await page.goto("/account/statistics/locations");
// await page.waitForLoadState("domcontentloaded");
// await expect(page).toHaveURL(/account\/onboarding/);
// });

test("Logged in premium user can access premium locations stats", async ({
browser,
Expand Down
19 changes: 10 additions & 9 deletions tests/account/stats/referer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ test("Guest user cannot access premium referers stats", async ({ browser }) => {
await expect(page).toHaveURL("/auth/signin");
});

test("Logged in free user cannot access premium referers stats", async ({
browser,
}) => {
const context = await login(browser);
const page = await context.newPage();
await page.goto("/account/statistics/referers");
await page.waitForLoadState("domcontentloaded");
await expect(page).toHaveURL(/account\/onboarding/);
});
// THIS PREMIUM IS BEING GIVEN TO EVERYONE
// test("Logged in free user cannot access premium referers stats", async ({
// browser,
// }) => {
// const context = await login(browser);
// const page = await context.newPage();
// await page.goto("/account/statistics/referers");
// await page.waitForLoadState("domcontentloaded");
// await expect(page).toHaveURL(/account\/onboarding/);
// });

test("Logged in premium user can access premium referers stats", async ({
browser,
Expand Down