ASPNetCore/Next/lib/product.ts

34 lines
748 B
TypeScript
Raw Normal View History

2021-03-29 07:08:26 +00:00
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,
2021-03-29 07:40:58 +00:00
}
export function validateForm(form): string[] {
let errors: string[] = [];
if (!form.name) {
errors.push("Name required");
}
if (!form.price) {
errors.push("Price required");
}
return errors;
2021-03-29 07:08:26 +00:00
}