Skip to content

Commit

Permalink
fix: cleaned up code (#3)
Browse files Browse the repository at this point in the history
* Updated checkin

* Before consolidating errs

* Test prettier

* Cleaned up points

* Abt to merge
  • Loading branch information
gracewzhang committed Jan 21, 2023
1 parent a801bf6 commit 14907b3
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 138 deletions.
7 changes: 5 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
},
"extends": [
"plugin:react/recommended",
"standard-with-typescript"
"standard-with-typescript",
"prettier"
],
"plugins": [
"react"
"react",
"prettier"
],
"rules": {
"semi": [
Expand All @@ -19,6 +21,7 @@
2,
"single"
],
"max-len": ["error", { "code": 80 }],
"no-unused-vars": 1,
"multiline-ternary": 0,
"@typescript-eslint/no-unused-vars": 1,
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": true,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 80
}
106 changes: 106 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"prepare": "husky install"
"prepare": "husky install",
"prettier-format": "prettier --config .prettierrc 'src/**/*.{tsx,ts}' --write"
},
"husky": {
"hooks": {
Expand All @@ -16,6 +17,7 @@
},
"lint-staged": {
"src/**/*.{tsx,ts}": [
"npm run prettier-format",
"eslint --fix --max-warnings=0"
]
},
Expand All @@ -36,13 +38,16 @@
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@vitejs/plugin-react": "^3.0.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-standard-with-typescript": "^31.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.32.1",
"husky": "^8.0.3",
"lint-staged": "^13.1.0",
"prettier": "2.8.3",
"typescript": "^4.9.4",
"vite": "^4.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import './App.css';
const App = (): React.ReactElement => {
return (
<BrowserRouter>
<ToastContainer/>
<ToastContainer />
<div className="home-container">
<Navbar />
<div className="content-container">
Expand Down
7 changes: 5 additions & 2 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
/* font-size: 16px; */
line-height: 24px;
font-weight: 400;

Expand All @@ -13,7 +13,6 @@

body {
margin: 0;

}

Button {
Expand All @@ -34,6 +33,10 @@ h6 {
margin: 0;
}

h1, h3 {
padding-bottom: 0.5em;
}

#root {
width: 100%;
height: 100%;
Expand Down
47 changes: 20 additions & 27 deletions src/pages/CheckIn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ import { Tab, Input, Button } from 'semantic-ui-react';

import axiosInstance from '../../api';
import { toastError, toastSuccess } from '../../utils/toast';

import './style.css';

const CheckIn = (): React.ReactElement => {
const [eventKey, setEventKey] = useState('');
const [eventKeyError, setEventKeyError] = useState(false);

useEffect(() => {
// Temporary patch to ensure users are authenticated before checking in
// TODO: Remove after implementing proper login flow
// eslint-disable-next-line @typescript-eslint/no-floating-promises
axiosInstance.get('/profile');
}, []);
const handleChangeKey = (event: BaseSyntheticEvent): void => {
setEventKey(event.target.value);
};

const handleEnter = async (tgt: React.KeyboardEvent): Promise<void> => {
if (tgt.key === 'enter') {
await handleSubmit();
}
};

const handleSubmit = async (): Promise<void> => {
const isEventKeyError = eventKey === '';
setEventKeyError(isEventKeyError);
if (isEventKeyError) {
return;
}
if (isEventKeyError) return;

axiosInstance
.patch('/profile', { eventKey })
Expand All @@ -34,24 +36,18 @@ const CheckIn = (): React.ReactElement => {
});
};

const handleEnter = async (tgt: React.KeyboardEvent): Promise<void> => {
if (tgt.charCode === 13) {
await handleSubmit();
}
};

const handleChangeKey = (event: BaseSyntheticEvent): void => {
setEventKey(event.target.value);
};
useEffect(() => {
// Temporary patch to ensure users are authenticated before checking in
// TODO: Remove after implementing proper login flow
// eslint-disable-next-line @typescript-eslint/no-floating-promises
axiosInstance.get('/profile');
}, []);

return (
<div className="check-in">
<h2>Check-in</h2>
<br />
{/* <Notifications /> */}
<h1>Check-in</h1>
<Tab.Pane>
<h4>Event Key</h4>

<h3>Event Key</h3>
<Input
fluid
error={eventKeyError}
Expand All @@ -60,11 +56,8 @@ const CheckIn = (): React.ReactElement => {
onChange={handleChangeKey}
onKeyPress={handleEnter}
/>

<br />

{/* eslint-disable-next-line @typescript-eslint/no-misused-promises */}
<Button fluid onClick={async () => { await handleSubmit(); }}>
<Button fluid onClick={handleSubmit}>
Check-in
</Button>
</Tab.Pane>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/CheckIn/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
.check-in .__createEvent {
float: right;
}
Loading

1 comment on commit 14907b3

@vercel
Copy link

@vercel vercel bot commented on 14907b3 Jan 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.