the type construct of components display. TODO: add area rug calculator.
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
import { length } from "enheter";
|
||||
import { Product } from "../product";
|
||||
|
||||
describe("Product tests", () => {
|
||||
@ -20,11 +19,4 @@ describe("Product tests", () => {
|
||||
const comparison = standard.priceFor({l : 24, u: "inch"});
|
||||
expect(comparison).toBeCloseTo(20, 4);
|
||||
});
|
||||
|
||||
it("Can convert to/from object", () => {
|
||||
const standard = new Product(10, {l: 1, u : "feet"});
|
||||
const obj = standard.asObject;
|
||||
const back = Product.fromObject(obj);
|
||||
expect(back).toEqual(standard);
|
||||
})
|
||||
});
|
@ -11,7 +11,6 @@ export type area_t = length_t & {
|
||||
|
||||
export type dimensions_t = area_t | length_t;
|
||||
|
||||
export type product_type_t = "area" | "length";
|
||||
|
||||
export const isArea = (d: dimensions_t) => ("width" in d);
|
||||
export const isLength = (d: dimensions_t) => (!("width" in d));
|
||||
|
@ -1,6 +1,7 @@
|
||||
import uuid from "react-native-uuid";
|
||||
import { dimensions_t, area_t } from "./dimensions";
|
||||
import { matchDimensions } from "./dimensions";
|
||||
import { Area, Length, Unit } from "convert";
|
||||
|
||||
export type Id = string;
|
||||
|
||||
@ -15,11 +16,18 @@ export type ProductAttributes = {
|
||||
currency?: Currency,
|
||||
[index:string]: any,
|
||||
}
|
||||
|
||||
export function dimensionArea(d: dimensions_t) {
|
||||
return "w" in d ? d.w * d.l : 0;
|
||||
}
|
||||
|
||||
export type product_type_t = "lumber" | "area_rug"
|
||||
export const PRODUCT_TYPES = [
|
||||
"lumber",
|
||||
"area_rug",
|
||||
] as const;
|
||||
|
||||
export type product_type_t = typeof PRODUCT_TYPES[number];
|
||||
|
||||
|
||||
export type Product = {
|
||||
id?: Id;
|
||||
|
Reference in New Issue
Block a user