-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
285 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
# don't ever lint node_modules | ||
node_modules | ||
# don't lint build output (make sure it's set to your correct build folder name) | ||
dist | ||
# don't lint nyc coverage output | ||
coverage | ||
public | ||
# .eslintignore | ||
*.json | ||
*.rc | ||
*.config.ts | ||
*.node.json | ||
.eslint* | ||
.prettier* | ||
.vscode/* | ||
.settings.json | ||
.gitignore | ||
.gitattributes | ||
/coverage | ||
/public | ||
/node_modules | ||
/build | ||
/dist | ||
/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,27 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": false, | ||
"endOfLine": "lf", | ||
"bracketSpacing": true, | ||
"printWidth": 80, | ||
"proseWrap": "preserve", | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"tabWidth": 4, | ||
"useTabs": true, | ||
"arrowParens": "always", | ||
"trailingComma": "none" | ||
} | ||
"endOfLine": "lf", | ||
"overrides": [ | ||
{ | ||
"files": "*.json", | ||
"options": { | ||
"singleQuote": false | ||
} | ||
}, | ||
{ | ||
"files": ".*rc", | ||
"options": { | ||
"singleQuote": false, | ||
"parser": "json" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export interface CheckIn { | ||
_id: string | ||
name: string | ||
points: string | ||
checkinCount: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { DispatchActionType } from "enums/DispatchActionType" | ||
import { RequestStatus } from "enums/RequestStatus" | ||
import { RemoteDispatchAction } from "types/DispatchAction" | ||
|
||
export const allCheckInItems = (): RemoteDispatchAction => ({ | ||
type: DispatchActionType.USER_GET_TEAM, | ||
useAPI: true, | ||
request: { | ||
path: "/check-in", | ||
method: "GET" | ||
}, | ||
status: RequestStatus.PENDING | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@import "~/styles/variables.scss"; | ||
@import "~/styles/mixins.scss"; | ||
|
||
.dialog { | ||
display: flex; | ||
align-items: center; | ||
width: 75%; | ||
border-radius: 25px; | ||
padding: 2rem; | ||
margin: 0 auto; | ||
flex-direction: column; | ||
background-image: $dialog-container-gradient; | ||
box-shadow: $dialog-container-box-shadow; | ||
backdrop-filter: blur(4px); | ||
|
||
max-height: 70%; | ||
overflow: scroll; | ||
|
||
@include down($breakpoint-md) { | ||
width: 80%; | ||
} | ||
|
||
@include down($breakpoint-sm) { | ||
width: 70%; | ||
} | ||
} | ||
|
||
.dialogContent { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
width: 100%; | ||
} | ||
|
||
.spinnerContainer { | ||
display: flex; | ||
justify-content: center; | ||
} | ||
|
||
.table { | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import { | ||
CircularProgress, | ||
Collapse, | ||
Table, | ||
TableBody, | ||
TableCell, | ||
TableContainer, | ||
TableHead, | ||
TableRow | ||
} from "@mui/material" | ||
import React, { ReactElement, useEffect, useMemo, useState } from "react" | ||
import { useDispatch } from "react-redux" | ||
import { Column, useTable } from "react-table" | ||
import actions from "src/actions" | ||
import styles from "./index.module.scss" | ||
import { CheckIn } from "types/CheckIn" | ||
|
||
const CheckInTable = (): ReactElement => { | ||
const dispatch = useDispatch() | ||
const [loading, setLoading] = useState(true) | ||
|
||
const [checkIns, setCheckIns] = useState([]) | ||
|
||
useEffect(() => { | ||
const getCheckIn = async () => { | ||
setLoading(true) | ||
try { | ||
const { data } = await dispatch(actions.checkin.allCheckInItems()) | ||
data.sort((a: { startTime: number }, b: { startTime: number }) => { | ||
return a.startTime > b.startTime | ||
}) | ||
setCheckIns(data) | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
setLoading(false) | ||
} | ||
getCheckIn() | ||
}, [dispatch]) | ||
|
||
const columns: Column<CheckIn>[] = useMemo( | ||
() => [ | ||
{ | ||
Header: "ID", | ||
accessor: "_id" | ||
}, | ||
{ | ||
Header: "Name", | ||
accessor: "name" | ||
}, | ||
{ | ||
Header: () => ( | ||
<div | ||
style={{ | ||
textAlign: "center" | ||
}} | ||
> | ||
Points | ||
</div> | ||
), | ||
accessor: "points", | ||
Cell: (row) => <div style={{ textAlign: "center" }}>{row.value}</div> | ||
}, | ||
{ | ||
Header: () => ( | ||
<div | ||
style={{ | ||
textAlign: "center" | ||
}} | ||
> | ||
Check-In Count | ||
</div> | ||
), | ||
accessor: "checkinCount", | ||
Cell: (row) => <div style={{ textAlign: "center" }}>{row.value}</div> | ||
} | ||
], | ||
[] | ||
) | ||
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = | ||
useTable<CheckIn>({ | ||
columns, | ||
data: checkIns, | ||
initialState: { | ||
hiddenColumns: ["_id"] | ||
} | ||
}) | ||
|
||
return ( | ||
<> | ||
<div className={styles.dialogContent}> | ||
<Collapse in={loading}> | ||
<div className={styles.spinnerContainer}> | ||
<CircularProgress /> | ||
</div> | ||
</Collapse> | ||
<TableContainer> | ||
<Table {...getTableProps()}> | ||
<TableHead> | ||
{ | ||
// Loop over the header rows | ||
headerGroups.map((headerGroup, headerIdx) => ( | ||
// Apply the header row props | ||
<TableRow | ||
{...headerGroup.getHeaderGroupProps()} | ||
key={headerIdx} | ||
> | ||
{ | ||
// Loop over the headers in each row | ||
headerGroup.headers.map((column, cellIdx) => ( | ||
// Apply the header cell props | ||
<TableCell {...column.getHeaderProps()} key={cellIdx}> | ||
{ | ||
// Render the header | ||
column.render("Header") | ||
} | ||
</TableCell> | ||
)) | ||
} | ||
</TableRow> | ||
)) | ||
} | ||
</TableHead> | ||
{/* Apply the table body props */} | ||
<TableBody {...getTableBodyProps()}> | ||
{rows.map((row, rowIdx) => { | ||
// Prepare the row for display | ||
prepareRow(row) | ||
return ( | ||
// Apply the row props | ||
<TableRow {...row.getRowProps()} key={rowIdx}> | ||
{ | ||
// Loop over the rows cells | ||
row.cells.map((cell, cellIdx) => { | ||
// Apply the cell props | ||
return ( | ||
<TableCell {...cell.getCellProps()} key={cellIdx}> | ||
{ | ||
// Render the cell contents | ||
cell.render("Cell") | ||
} | ||
</TableCell> | ||
) | ||
}) | ||
} | ||
</TableRow> | ||
) | ||
})} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default CheckInTable |
Oops, something went wrong.