Skip to content

Commit

Permalink
Allow commas in numbers, and saving via Enter
Browse files Browse the repository at this point in the history
Also tweak PWA with eslint/git/prettier (ignore generated files).
  • Loading branch information
BrunoBernardino committed Sep 19, 2021
1 parent a31b840 commit 7a8d39a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
10 changes: 10 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/public/precache.*.*.js
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/fallback-*.js
**/public/precache.*.*.js.map
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
**/public/fallback-*.js
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ node_modules
.env.build
.serverless
.serverless_nextjs
**/public/precache.*.*.js
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/fallback-*.js
**/public/precache.*.*.js.map
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
**/public/fallback-*.js
10 changes: 10 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@ node_modules
package-lock.json
.serverless
.serverless_nextjs
**/public/precache.*.*.js
**/public/sw.js
**/public/workbox-*.js
**/public/worker-*.js
**/public/fallback-*.js
**/public/precache.*.*.js.map
**/public/sw.js.map
**/public/workbox-*.js.map
**/public/worker-*.js.map
**/public/fallback-*.js
11 changes: 9 additions & 2 deletions components/ExpenseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,21 @@ const ExpenseModal = (props: ExpenseModalProps) => {
};

const onKeyDown = useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
(event: React.KeyboardEvent<HTMLInputElement>) => {
// @ts-ignore: Convert comma to dot
if (event.key === ',' && event.target.type === 'number') {
event.preventDefault();
event.stopPropagation();
setCost(`${cost}.`);
}

if (event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
addExpense();
}
},
[],
[cost, description, budget, date],
);

return (
Expand Down
11 changes: 9 additions & 2 deletions components/Panels/AddExpense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,21 @@ const AddExpense = ({ budgets, reloadData, db }: AddExpenseProps) => {
};

const onKeyDown = useCallback(
(event: React.KeyboardEvent<HTMLDivElement>) => {
(event: React.KeyboardEvent<HTMLInputElement>) => {
// @ts-ignore: Convert comma to dot
if (event.key === ',' && event.target.type === 'number') {
event.preventDefault();
event.stopPropagation();
setCost(`${cost}.`);
}

if (event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
addExpense();
}
},
[],
[cost, description, budget, date],
);

const budgetsToShow = [...budgets];
Expand Down
1 change: 0 additions & 1 deletion public/sw.js

This file was deleted.

1 change: 0 additions & 1 deletion public/workbox-4a677df8.js

This file was deleted.

0 comments on commit 7a8d39a

Please sign in to comment.