added new invoice item schema
This commit is contained in:
@@ -24,7 +24,6 @@ export * from "./models/cusModels/cusProductModels.js";
|
||||
export * from "./models/cusModels/cusPriceModels/pricesInputModel.js";
|
||||
export * from "./models/cusModels/cusPriceModels/cusPriceModels.js";
|
||||
export * from "./models/cusModels/invoiceModels/invoiceModels.js";
|
||||
export * from "./models/cusModels/invoiceModels/invoiceItemModels.js";
|
||||
export * from "./models/cusModels/cusResponseModels.js";
|
||||
|
||||
// Org Models
|
||||
|
||||
@@ -15,6 +15,15 @@ export const InvoiceDiscountSchema = z.object({
|
||||
amount_used: z.number(),
|
||||
});
|
||||
|
||||
export const InvoiceItemSchema = z.object({
|
||||
price_id: z.string().nullish(),
|
||||
stripe_id: z.string(),
|
||||
internal_feature_id: z.string().nullable(),
|
||||
description: z.string(),
|
||||
period_start: z.number(),
|
||||
period_end: z.number(),
|
||||
});
|
||||
|
||||
export const InvoiceSchema = z.object({
|
||||
id: z.string(),
|
||||
created_at: z.number(),
|
||||
@@ -33,7 +42,9 @@ export const InvoiceSchema = z.object({
|
||||
currency: z.string(),
|
||||
receipt_url: z.string().nullish(),
|
||||
discounts: z.array(InvoiceDiscountSchema),
|
||||
items: z.array(InvoiceItemSchema),
|
||||
});
|
||||
|
||||
export type Invoice = z.infer<typeof InvoiceSchema>;
|
||||
export type InvoiceDiscount = z.infer<typeof InvoiceDiscountSchema>;
|
||||
export type InvoiceItem = z.infer<typeof InvoiceItemSchema>;
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const InvoiceItemResponseSchema = z.object({
|
||||
description: z.string(),
|
||||
period_start: z.number(),
|
||||
period_end: z.number(),
|
||||
|
||||
feature_id: z.string().optional(),
|
||||
feature_name: z.string().optional(),
|
||||
});
|
||||
|
||||
export const InvoiceResponseSchema = z.object({
|
||||
product_ids: z.array(z.string()),
|
||||
stripe_id: z.string(),
|
||||
|
||||
@@ -45,6 +45,7 @@ export const ProductItemSchema = z.object({
|
||||
// Feature stuff
|
||||
feature_id: z.string().nullish(),
|
||||
feature_type: z.nativeEnum(ProductItemFeatureType).nullish(),
|
||||
|
||||
included_usage: z.union([z.number(), z.literal(Infinite)]).nullish(),
|
||||
|
||||
interval: z.nativeEnum(ProductItemInterval).nullish(),
|
||||
|
||||
@@ -10,6 +10,10 @@ export const SubscriptionSchema = z.object({
|
||||
// metadata: z.record(z.string(), z.any()),
|
||||
usage_features: z.array(z.string()),
|
||||
org_id: z.string(),
|
||||
|
||||
current_period_start: z.number().nullable(),
|
||||
current_period_end: z.number().nullable(),
|
||||
|
||||
env: z.nativeEnum(AppEnv),
|
||||
});
|
||||
|
||||
|
||||
@@ -178,20 +178,13 @@ export const CustomersTable = ({
|
||||
className="grid grid-cols-16 gap-2 items-center px-10 w-full text-sm h-8 cursor-default hover:bg-primary/5 text-t2 whitespace-nowrap"
|
||||
>
|
||||
<CustomTableCell colSpan={3}>{customer.name}</CustomTableCell>
|
||||
<CustomTableCell
|
||||
className="font-mono text-t3 -translate-x-1"
|
||||
colSpan={3}
|
||||
>
|
||||
<span className="truncate">
|
||||
<CopyButton
|
||||
text={customer.id || ""}
|
||||
className="bg-transparent border-none text-t3 px-1 shadow-none"
|
||||
>
|
||||
{customer.id}
|
||||
</CopyButton>
|
||||
</span>
|
||||
|
||||
{/* {customer.id} */}
|
||||
<CustomTableCell className="font-mono -translate-x-1" colSpan={3}>
|
||||
<CopyButton
|
||||
text={customer.id || ""}
|
||||
className="bg-transparent text-t3 border-none px-1 shadow-none max-w-full"
|
||||
>
|
||||
<span className="truncate">{customer.id}</span>
|
||||
</CopyButton>
|
||||
</CustomTableCell>
|
||||
<CustomTableCell colSpan={3}>{customer.email}</CustomTableCell>
|
||||
<CustomTableCell colSpan={5}>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Invoice, Product } from "@autumn/shared";
|
||||
import { toast } from "sonner";
|
||||
import { getStripeInvoiceLink } from "@/utils/linkUtils";
|
||||
import { Row, Item } from "@/components/general/TableGrid";
|
||||
import { AdminHover } from "@/components/general/AdminHover";
|
||||
|
||||
export const InvoicesTable = () => {
|
||||
const { env, invoices, products, entityId, entities } = useCustomerContext();
|
||||
@@ -79,12 +80,19 @@ export const InvoicesTable = () => {
|
||||
}}
|
||||
>
|
||||
<Item className="col-span-3">
|
||||
{invoice.product_ids
|
||||
.map((p: string) => {
|
||||
return products.find((product: Product) => product.id === p)
|
||||
?.name;
|
||||
})
|
||||
.join(", ")}
|
||||
<AdminHover
|
||||
texts={[
|
||||
{ key: "ID", value: invoice.id },
|
||||
{ key: "Stripe ID", value: invoice.stripe_id },
|
||||
]}
|
||||
>
|
||||
{invoice.product_ids
|
||||
.map((p: string) => {
|
||||
return products.find((product: Product) => product.id === p)
|
||||
?.name;
|
||||
})
|
||||
.join(", ")}
|
||||
</AdminHover>
|
||||
</Item>
|
||||
<Item className="col-span-3">
|
||||
{invoice.total.toFixed(2)} {invoice.currency.toUpperCase()}
|
||||
|
||||
@@ -76,7 +76,6 @@ export const ProductRowToolbar = ({
|
||||
setSelectedProduct(product);
|
||||
setDialogType("copy");
|
||||
setModalOpen(true);
|
||||
// await handleCopy();
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between w-full gap-2">
|
||||
|
||||
@@ -57,16 +57,13 @@ export const ProductsTable = ({ products }: { products: Product[] }) => {
|
||||
<span className="truncate">{product.name}</span>
|
||||
</AdminHover>
|
||||
</Item>
|
||||
<Item className="col-span-3 font-mono -translate-x-1">
|
||||
<span className="truncate ">
|
||||
<CopyButton
|
||||
text={product.id || ""}
|
||||
className="bg-transparent border-none text-t3 px-1 shadow-none"
|
||||
>
|
||||
{product.id}
|
||||
</CopyButton>
|
||||
</span>
|
||||
{/* <span className="truncate">{product.id}</span> */}
|
||||
<Item className="col-span-3 font-mono -translate-x-1">
|
||||
<CopyButton
|
||||
text={product.id || ""}
|
||||
className="bg-transparent text-t3 border-none px-1 shadow-none max-w-full"
|
||||
>
|
||||
<span className="truncate">{product.id}</span>
|
||||
</CopyButton>
|
||||
</Item>
|
||||
<Item className="col-span-3">
|
||||
<TooltipProvider>
|
||||
|
||||
Reference in New Issue
Block a user