Skip to content

Commit

Permalink
Remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 13, 2023
1 parent 6284f1e commit 0268207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 38 deletions.
21 changes: 2 additions & 19 deletions src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@ import React from "react";

import { StripeMananageButton } from "../components/StripeManageButton";
import { SubGetStarted } from "../components/SubGetStarted/";
import {
COMMERCIAL_LICENSE_PRODUCT_ID,
productName,
SAAS_10K_PRODUCT_ID,
} from "@/util/subs";
import { COMMERCIAL_LICENSE_PRODUCT_ID, productName } from "@/util/subs";
import { useUser } from "@/util/useUser";
import { ApiUsage } from "./ApiUsage";
import styles from "./Dashboard.module.css";
import { ProductWithPrice } from "@/supabase/domain.types";
import { formatDate } from "@/util/helpers";

interface DashboardProps {
products: ProductWithPrice[];
}

export function Dashboard({ products }: DashboardProps): React.ReactElement {
export function Dashboard(): React.ReactElement {
const { userDetails, subscription, userFinishedLoading } = useUser();

const saasProduct = products.find(({ id }) => id === SAAS_10K_PRODUCT_ID);
const licenseProduct = products.find(
({ id }) => id === COMMERCIAL_LICENSE_PRODUCT_ID
);
if (!saasProduct || !licenseProduct) {
throw new Error("Dashboard: saasProduct or licenseProduct not found.");
}

if (!userFinishedLoading) {
return (
<Page>
Expand Down
21 changes: 2 additions & 19 deletions src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import { Loading, Page } from "@geist-ui/react";
import { GetStaticProps } from "next";
import { useRouter } from "next/router";
import React, { useEffect } from "react";

import { Dashboard, Nav } from "../components";
import { sentryException } from "@/util/sentry";
import { getActiveProductWithPrices } from "@/util/supabaseClient";
import { useUser } from "@/util/useUser";
import { ProductWithPrice } from "@/supabase/domain.types";

export const getStaticProps: GetStaticProps = async () => {
const products = await getActiveProductWithPrices();

return {
props: {
products,
},
};
};

interface IndexProps {
products: ProductWithPrice[];
}

export default function Index({ products }: IndexProps): React.ReactElement {
export default function Index(): React.ReactElement {
const router = useRouter();
const { user, userFinishedLoading } = useUser();

Expand All @@ -37,7 +20,7 @@ export default function Index({ products }: IndexProps): React.ReactElement {
<>
<Nav />
{user ? (
<Dashboard products={products} />
<Dashboard />
) : (
<Page>
<Loading />
Expand Down

0 comments on commit 0268207

Please sign in to comment.