ASPNetCore/Next/lib/product.ts

34 lines
748 B
TypeScript

import { ProductListItem } from "../APIClient";
export interface ProductDataProps {
productID: string,
}
export interface DeleteProductProps extends ProductDataProps {
onDelete: (val) => void
}
export interface ProductListRowsProps {
products: ProductListItem[],
onDelete: (val) => void,
}
export interface ProductState {
product: ProductListItem[]
}
export interface ProductFormState {
form: {
name: string,
price: number,
},
errors: string[],
busy: boolean,
}
export function validateForm(form): string[] {
let errors: string[] = [];
if (!form.name) {
errors.push("Name required");
}
if (!form.price) {
errors.push("Price required");
}
return errors;
}