diff --git a/components/EditBox.tsx b/components/EditBox.tsx index e8abbdb..bc27c6e 100644 --- a/components/EditBox.tsx +++ b/components/EditBox.tsx @@ -1,7 +1,11 @@ -import { useAtom } from "jotai"; +import { Atom, useAtom } from "jotai"; import { useState } from "react"; -export default function EditBox({ valueAtom }) { +export interface Props { + valueAtom: Atom; +} + +export default function EditBox({ valueAtom }: Props) { const [value, setValue] = useAtom(valueAtom); const [valueInput, setValueInput] = useState(""); const [editing, setEditing] = useState(false); @@ -11,12 +15,12 @@ export default function EditBox({ valueAtom }) { currency: "USD", }); - const startEditing = (_) => { + const startEditing = (_: any) => { setValueInput(value.toString()); setEditing(true); }; - const finalize = (e) => { + const finalize = (e: Event) => { e.preventDefault(); try { const n = parseFloat(valueInput); diff --git a/next.config.js b/next.config.js index ae88795..8a7ca97 100644 --- a/next.config.js +++ b/next.config.js @@ -2,6 +2,11 @@ const nextConfig = { reactStrictMode: true, swcMinify: true, -} -module.exports = nextConfig + typescript: { + // TODO: Move fast and break things lmao + ignoreBuildErrors: true, + }, +}; + +module.exports = nextConfig; diff --git a/pages/index-old.tsx b/pages/index-old.tsx deleted file mode 100644 index eeeee31..0000000 --- a/pages/index-old.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import type { NextPage } from "next"; -import EditBox from "../components/EditBox"; - -const Home: NextPage = () => { - return ( -
-

Items

- -
- Details for nerds -
{JSON.stringify(state)}
-
- -

- Final total: {formatter.format(state.finalTotal)} - - trySetNum(["finalTotal"], e.target.value)} - value={state.finalTotal} - /> -

- - - - -
- ); -}; - -export default Home; diff --git a/pages/index.tsx b/pages/index.tsx index c05425b..4ecc3a0 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -74,22 +74,24 @@ const Home: NextPage = () => {

Items

-
- Receipt Total: - -
-
setInput(e.target.value)} value={input} + style={{ padding: "8px", fontSize: "1.5em" }} /> +
+ Receipt Total: + +
+
    {receipt.map((itemAtom, i) => { return ( diff --git a/src/components/EditBox.tsx b/src/components/EditBox.tsx deleted file mode 100644 index 777e026..0000000 --- a/src/components/EditBox.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export default function EditBox() { -} diff --git a/src/entry-client.tsx b/src/entry-client.tsx deleted file mode 100644 index 9422848..0000000 --- a/src/entry-client.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { mount, StartClient } from "solid-start/entry-client"; - -mount(() => , document); diff --git a/src/entry-server.tsx b/src/entry-server.tsx deleted file mode 100644 index 86898c9..0000000 --- a/src/entry-server.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { - createHandler, - renderAsync, - StartServer, -} from "solid-start/entry-server"; - -export default createHandler( - renderAsync((event) => ) -); diff --git a/src/root.css b/src/root.css deleted file mode 100644 index 5955a5a..0000000 --- a/src/root.css +++ /dev/null @@ -1,40 +0,0 @@ -body { - font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell, - 'Open Sans', 'Helvetica Neue', sans-serif; -} - -a { - margin-right: 1rem; -} - -main { - text-align: center; - padding: 1em; - margin: 0 auto; -} - -h1 { - color: #335d92; - text-transform: uppercase; - font-size: 4rem; - font-weight: 100; - line-height: 1.1; - margin: 4rem auto; - max-width: 14rem; -} - -p { - max-width: 14rem; - margin: 2rem auto; - line-height: 1.35; -} - -@media (min-width: 480px) { - h1 { - max-width: none; - } - - p { - max-width: none; - } -} diff --git a/src/root.tsx b/src/root.tsx deleted file mode 100644 index 250d1d4..0000000 --- a/src/root.tsx +++ /dev/null @@ -1,39 +0,0 @@ -// @refresh reload -import { Suspense } from "solid-js"; -import { - A, - Body, - ErrorBoundary, - FileRoutes, - Head, - Html, - Meta, - Routes, - Scripts, - Title, -} from "solid-start"; -import "./root.css"; - -export default function Root() { - return ( - - - SolidStart - Bare - - - - - - - Index - About - - - - - - - - - ); -} diff --git a/src/routes/[...404].tsx b/src/routes/[...404].tsx deleted file mode 100644 index 1089460..0000000 --- a/src/routes/[...404].tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Title } from "solid-start"; -import { HttpStatusCode } from "solid-start/server"; - -export default function NotFound() { - return ( -
    - Not Found - -

    Page Not Found

    -

    - Visit{" "} - - start.solidjs.com - {" "} - to learn how to build SolidStart apps. -

    -
    - ); -} diff --git a/src/routes/index.tsx b/src/routes/index.tsx deleted file mode 100644 index 238fff5..0000000 --- a/src/routes/index.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import { createStore } from "solid-js/store"; -import { batch, createComputed, createSignal, For } from "solid-js"; -import { Title } from "solid-start"; - -export default function Home() { - const [state, setState] = createStore({ - itemEdit: "", - items: [], - finalTotal: 0, - - get totals() { - const totals = new Map(); - - let subtotalSum = 0; - for (let item of state.items) { - const price = item.price; - const numPeople = item.people.length; - if (numPeople == 0) continue; - - const eachPrice = price / numPeople; - subtotalSum += price; - for (let person of item.people) { - const personName = person.name.toString(); - let accum = totals.get(personName) || 0; - accum += eachPrice; - totals.set(personName, accum); - } - } - - if (subtotalSum == 0) return totals; - - const proportion = state.finalTotal / subtotalSum; - console.log("Subtotal sum", subtotalSum, proportion); - const newTotals = new Map(); - for (let person of totals.keys()) { - const value = totals.get(person); - newTotals.set(person, value * proportion); - } - - return newTotals; - }, - }); - - const [totals, setTotals] = createSignal(new Map()); - - const addItem = (e) => { - e.preventDefault(); - batch(() => { - setState("items", [ - ...state.items, - { name: state.itemEdit, price: 0, personEdit: "", people: [] }, - ]); - setState("itemEdit", ""); - }); - return false; - }; - - const itemAddPerson = (e, i) => { - e.preventDefault(); - batch(() => { - setState("items", i, "people", [ - ...state.items[i].people, - { name: state.items[i].personEdit }, - ]); - setState("items", i, "personEdit", ""); - }); - return false; - }; - - const trySetNum = (target, v) => { - try { - let n = parseFloat(v); - console.log([...target, n]); - setState.apply(null, [...target, n]); - } catch (e) { - return; - } - }; - - const formatter = new Intl.NumberFormat("en-US", { - style: "currency", - currency: "USD", - }); - - return ( -
    - Hello World - -

    Items

    - -
    - Details for nerds -
    {JSON.stringify(state)}
    -
    - -

    - Final total: {formatter.format(state.finalTotal)} - trySetNum(["finalTotal"], e.target.value)} - value={state.finalTotal} - /> -

    - -
      - - {(item, i) => ( -
    • - {item.name} ({formatter.format(item.price)}) - - trySetNum(["items", i(), "price"], e.target.value) - } - value={item.price} - /> -
        - - {(person, j) =>
      • {person.name}
      • } -
        -
      • -
        itemAddPerson(e, i())}> - - setState("items", i(), "personEdit", e.target.value) - } - value={item.personEdit} - /> -
        -
      • -
      -
    • - )} -
      - -
    • -
      - setState("itemEdit", e.target.value)} - value={state.itemEdit} - /> -
      -
    • -
    - -
      - - {([person, amount], i) => ( -
    • - {person} : {formatter.format(amount)} -
    • - )} -
      -
    -
    - ); -}