Skip to content

Commit

Permalink
Fix app
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Hernandez committed Nov 21, 2023
1 parent 0f572b2 commit 06fa714
Show file tree
Hide file tree
Showing 21 changed files with 2,777 additions and 2,006 deletions.
31 changes: 31 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
es2023: true,
},
rules: {
"import/extensions": [2, { js: "always" }],
"react/display-name": "off",
"react/prop-types": "off",
"no-unused-vars": ["error", { ignoreRestSiblings: true }],
},
settings: {
react: {
version: "detect",
},
},
}
27 changes: 0 additions & 27 deletions .eslintrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
51 changes: 23 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
{
"name": "macro-planning",
"license": "MIT",
"version": "0.0.0",
"private": true,
"version": "0.1.0",
"type": "module",
"packageManager": "[email protected]",
"scripts": {
"dev": "vite --open",
"build": "vite build",
"preview": "vite preview",
"predeploy": "vite build",
"test": "vitest run",
"lint": "eslint ./src",
"lint": "eslint --ext js,jsx .",
"deploy": "gh-pages -d build"
},
"dependencies": {
"@chakra-ui/react": "^2.3.7",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@tanstack/react-table": "^8.3.3",
"ajv": "^8.11.0",
"framer-motion": "^7.5.3",
"futil": "^1.71.5",
"@chakra-ui/react": "^2.8.2",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@tanstack/react-table": "^8.10.7",
"ajv": "^8.12.0",
"framer-motion": "^10.16.5",
"futil": "^1.76.0",
"lodash": "^4.17.21",
"mobx": "^6.7.0",
"mobx-react-lite": "^3.4.0",
"mobx-state-tree": "^5.1.6",
"mobx": "^6.11.0",
"mobx-react-lite": "^3.4.3",
"mobx-state-tree": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.6.0",
"safe-stable-stringify": "^2.4.0"
"react-icons": "^4.12.0",
"safe-stable-stringify": "^2.4.3"
},
"devDependencies": {
"@vitejs/plugin-react": "^3.0.1",
"eslint": "^8.32.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.31.10",
"gh-pages": "^4.0.0",
"prettier": "^2.7.1",
"vite": "^4.0.4",
"vitest": "^0.27.2"
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.54.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.33.2",
"gh-pages": "^6.1.0",
"prettier": "^3.1.0",
"vite": "^5.0.0",
"vitest": "^0.34.6"
}
}
3 changes: 3 additions & 0 deletions prettier.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
semi: false,
}
84 changes: 0 additions & 84 deletions script.js

This file was deleted.

54 changes: 27 additions & 27 deletions src/Foods.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash/fp"
import _ from "lodash/fp.js"
import { action } from "mobx"
import { useRef, useState } from "react"
import {
Expand All @@ -19,12 +19,13 @@ import {
UnorderedList,
ListItem,
} from "@chakra-ui/react"
// eslint-disable-next-line import/extensions
import { MdEdit, MdAddCircle, MdRemoveCircle } from "react-icons/md"
import { formatGrams } from "./util/format.js"
import { useReaction } from "./util/mobx.js"
import { useTable, Table } from "./components/Table.jsx"
import { ModalButton } from "./components/ModalButton.jsx"
import { AlertDialogButton } from "./components/AlertDialogButton"
import { AlertDialogButton } from "./components/AlertDialogButton.jsx"
import { filteringColumn, sortingColumn } from "./columns.jsx"

/*
Expand Down Expand Up @@ -156,29 +157,6 @@ const RemoveFood = ({ store, row }) => (
)

const makeColumns = (store) => [
_.merge(sortingColumn(), {
accessorKey: "brand",
props: { td: { whiteSpace: "nowrap" } },
}),
_.merge(filteringColumn(), {
accessorKey: "name",
props: { td: { w: "100%", whiteSpace: "nowrap" } },
}),
_.merge(sortingColumn(), {
accessorKey: "carbs",
display: formatGrams,
isNumeric: true,
}),
_.merge(sortingColumn(), {
accessorKey: "proteins",
display: formatGrams,
isNumeric: true,
}),
_.merge(sortingColumn(), {
accessorKey: "fats",
display: formatGrams,
isNumeric: true,
}),
{
id: "control",
header: (
Expand All @@ -203,13 +181,35 @@ const makeColumns = (store) => [
variant="ghost"
icon={<Icon as={MdEdit} boxSize="1.2em" />}
form={{ defaultValues: store.foods[props.row.index] }}
{...props}
/>
<RemoveFood store={store} {...props} />
<RemoveFood store={store} row={props.row} />
</Flex>
),
props: { th: { py: 0 }, td: { py: 0 } },
},
_.merge(sortingColumn(), {
accessorKey: "brand",
props: { td: { whiteSpace: "nowrap" } },
}),
_.merge(filteringColumn(), {
accessorKey: "name",
props: { td: { w: "100%", whiteSpace: "nowrap" } },
}),
_.merge(sortingColumn(), {
accessorKey: "carbs",
display: formatGrams,
isNumeric: true,
}),
_.merge(sortingColumn(), {
accessorKey: "proteins",
display: formatGrams,
isNumeric: true,
}),
_.merge(sortingColumn(), {
accessorKey: "fats",
display: formatGrams,
isNumeric: true,
}),
]

export const Foods = ({ store, ...props }) => {
Expand Down
8 changes: 4 additions & 4 deletions src/Meals.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash/fp"
import _ from "lodash/fp.js"
import { useState } from "react"
import { useReaction } from "./util/mobx.js"
import { formatGrams, formatNumber } from "./util/format.js"
Expand Down Expand Up @@ -56,17 +56,17 @@ export const Meals = ({ store, ...props }) => {
name: food.id.name,
..._.pick(["carbs", "proteins", "fats", "calories", "amount"], food),
}),
row.foods
row.foods,
),
..._.map(
(recipe) => ({
name: recipe.id.name,
..._.pick(
["carbs", "proteins", "fats", "calories", "amount", "foods"],
recipe
recipe,
),
}),
row.recipes
row.recipes,
),
],
})
Expand Down
Loading

0 comments on commit 06fa714

Please sign in to comment.