import React from 'react'; import * as gf from '../src/genfuns'; import * as m from './Model'; class Summary { constructor(wrapper = 'span') { this.wrapper = wrapper; } } class Detail { } const total_receipt = items => items.reduce((acc, item) => acc + item.subtotal, 0); const subtotal = items => items.reduce((acc, item) => acc + item.price, 0); const total_tax = items => items.reduce((acc, item) => acc + item.tax, 0); const display_money = amount => amount.toFixed(2); const ItemLabel = ({ desc, amount, wrapper, ...restProps }) => React.createElement(wrapper, restProps, [ {desc}: , {display_money(amount)} ] ); export const Items = gf.defgeneric("Items", "animaltorender") .primary([gf.Shape("items", "view")], ({ items, view }) => Items(items, view)) .primary([Array, Summary], (items, view) => ( <> )) .primary([Array, Detail], items => (
    {items.map((a, idx) => , items)}
)) .fn; export const Item = gf.defgeneric("Item", "itemtorender") .primary([gf.Shape("item")], ({ item }) => Item(item)) .around([m.Item], function (_) { const [desc, price] = this.call_next_method(); return ; }) .primary([m.NonFood], item => ["Non-food Item", item.price]) .primary([m.NormalFood], item => ["Food", item.price]) .primary([m.AlcoholicBeverage], item => ["Alcohol", item.price]) .fn; export const Receipt = ({items}) => (

);