-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clients/label: fix onetime status label
- Loading branch information
1 parent
83f9912
commit af282dc
Showing
1 changed file
with
80 additions
and
80 deletions.
There are no files selected for viewing
160 changes: 80 additions & 80 deletions
160
clients/apps/web/src/components/Products/ProductPage/ProductPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,89 @@ | ||
import { Organization, Product } from "@polar-sh/api"; | ||
import { DashboardBody } from "../../Layout/DashboardLayout"; | ||
import { ProductPageContextView } from "./ProductPageContextView"; | ||
import { useMetrics } from '@/hooks/queries' | ||
import { dateToInterval } from '@/utils/metrics' | ||
import { Organization, Product } from '@polar-sh/api' | ||
import { Status } from '@polar-sh/ui/components/atoms/Status' | ||
import { | ||
Tabs, | ||
TabsContent, | ||
TabsList, | ||
TabsTrigger, | ||
} from "@polar-sh/ui/components/atoms/Tabs"; | ||
import { ProductOverview } from "./ProductOverview"; | ||
import { ProductMetricsView } from "./ProductMetricsView"; | ||
import { Status } from "@polar-sh/ui/components/atoms/Status"; | ||
import { ProductThumbnail } from "../ProductThumbnail"; | ||
import { useMetrics } from "@/hooks/queries"; | ||
import { dateToInterval } from "@/utils/metrics"; | ||
Tabs, | ||
TabsContent, | ||
TabsList, | ||
TabsTrigger, | ||
} from '@polar-sh/ui/components/atoms/Tabs' | ||
import { DashboardBody } from '../../Layout/DashboardLayout' | ||
import { ProductThumbnail } from '../ProductThumbnail' | ||
import { ProductMetricsView } from './ProductMetricsView' | ||
import { ProductOverview } from './ProductOverview' | ||
import { ProductPageContextView } from './ProductPageContextView' | ||
|
||
const ProductTypeDisplayColor: Record<string, string> = { | ||
subscription: "bg-emerald-100 text-emerald-500 dark:bg-emerald-950", | ||
one_time: "bg-blue-100 text-blue-400 dark:bg-blue-950", | ||
}; | ||
subscription: 'bg-emerald-100 text-emerald-500 dark:bg-emerald-950', | ||
one_time: 'bg-blue-100 text-blue-400 dark:bg-blue-950', | ||
} | ||
|
||
export interface ProductPageProps { | ||
organization: Organization; | ||
product: Product; | ||
organization: Organization | ||
product: Product | ||
} | ||
|
||
export const ProductPage = ({ organization, product }: ProductPageProps) => { | ||
const { data: metrics, isLoading: metricsLoading } = useMetrics({ | ||
organizationId: organization.id, | ||
productId: [product.id], | ||
interval: dateToInterval(new Date(product.created_at)), | ||
startDate: new Date(product.created_at), | ||
endDate: new Date(), | ||
}); | ||
const { data: metrics, isLoading: metricsLoading } = useMetrics({ | ||
organizationId: organization.id, | ||
productId: [product.id], | ||
interval: dateToInterval(new Date(product.created_at)), | ||
startDate: new Date(product.created_at), | ||
endDate: new Date(), | ||
}) | ||
|
||
return ( | ||
<Tabs defaultValue="overview" className="h-full"> | ||
<DashboardBody | ||
title={ | ||
<div className="flex flex-row items-center gap-6"> | ||
<div className="flex flex-row items-center gap-4"> | ||
<ProductThumbnail product={product} /> | ||
<h1 className="text-2xl">{product.name}</h1> | ||
</div> | ||
<Status | ||
status={ | ||
product.is_recurring ? "Subscription" : "One-time Product" | ||
} | ||
className={ | ||
ProductTypeDisplayColor[ | ||
product.is_recurring ? "subscription" : "one-time" | ||
] | ||
} | ||
/> | ||
</div> | ||
} | ||
header={ | ||
<TabsList> | ||
<TabsTrigger value="overview">Overview</TabsTrigger> | ||
<TabsTrigger value="metrics">Metrics</TabsTrigger> | ||
</TabsList> | ||
} | ||
contextViewClassName="hidden md:block" | ||
contextView={ | ||
<ProductPageContextView | ||
organization={organization} | ||
product={product} | ||
/> | ||
} | ||
> | ||
<TabsContent value="overview"> | ||
<ProductOverview | ||
metrics={metrics?.metrics} | ||
periods={metrics?.periods} | ||
organization={organization} | ||
product={product} | ||
/> | ||
</TabsContent> | ||
<TabsContent value="metrics"> | ||
<ProductMetricsView | ||
metrics={metrics?.metrics} | ||
periods={metrics?.periods} | ||
loading={metricsLoading} | ||
/> | ||
</TabsContent> | ||
</DashboardBody> | ||
</Tabs> | ||
); | ||
}; | ||
return ( | ||
<Tabs defaultValue="overview" className="h-full"> | ||
<DashboardBody | ||
title={ | ||
<div className="flex flex-row items-center gap-6"> | ||
<div className="flex flex-row items-center gap-4"> | ||
<ProductThumbnail product={product} /> | ||
<h1 className="text-2xl">{product.name}</h1> | ||
</div> | ||
<Status | ||
status={ | ||
product.is_recurring ? 'Subscription' : 'One-time Product' | ||
} | ||
className={ | ||
ProductTypeDisplayColor[ | ||
product.is_recurring ? 'subscription' : 'one_time' | ||
] | ||
} | ||
/> | ||
</div> | ||
} | ||
header={ | ||
<TabsList> | ||
<TabsTrigger value="overview">Overview</TabsTrigger> | ||
<TabsTrigger value="metrics">Metrics</TabsTrigger> | ||
</TabsList> | ||
} | ||
contextViewClassName="hidden md:block" | ||
contextView={ | ||
<ProductPageContextView | ||
organization={organization} | ||
product={product} | ||
/> | ||
} | ||
> | ||
<TabsContent value="overview"> | ||
<ProductOverview | ||
metrics={metrics?.metrics} | ||
periods={metrics?.periods} | ||
organization={organization} | ||
product={product} | ||
/> | ||
</TabsContent> | ||
<TabsContent value="metrics"> | ||
<ProductMetricsView | ||
metrics={metrics?.metrics} | ||
periods={metrics?.periods} | ||
loading={metricsLoading} | ||
/> | ||
</TabsContent> | ||
</DashboardBody> | ||
</Tabs> | ||
) | ||
} |