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 ProductFormEntry { name: string, price: number, } export interface ProductFormState { form: ProductFormEntry, errors: string[], busy: boolean, } export function validateForm(form: ProductFormEntry) { let errors: {name: string[],price: string[]} = { name: [], price: [], }; if (!form.name) { errors.name.push("Name required"); } if (!form.price) { errors.price.push("Price required"); } if (form.price < 0) { errors.price.push("Price must be positive"); } return errors; }