Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement check in out #32

Merged
merged 21 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a9a79d7
Update gitignore
sasithak Jul 19, 2023
07cb6b9
Merge branch 'main' into implement/check-in-out
sasithak Aug 7, 2023
1c48bf1
Merge branch 'main' into implement/check-in-out
sasithak Aug 7, 2023
2f3daab
Implement UI of 'resources/{id}/check-in-out' page
sasithak Aug 7, 2023
f574022
Update UI of /resources/{id}/check-in-out
sasithak Aug 9, 2023
a6f956c
Send requests to fingerprint device 10 times per second for '/request…
sasithak Aug 9, 2023
3191d68
Update backend API call for fingerprint authentication
sasithak Aug 9, 2023
0ceaec8
Add token to fingerprint authentication service request
sasithak Aug 10, 2023
f174c7c
Updates to '/resources/{id}/check-in-out' route
sasithak Aug 10, 2023
925f4a6
Request fingerprint through socket
NethumL Aug 10, 2023
5f1ae0e
Add environment variables to `vite-env.d.ts`
NethumL Aug 10, 2023
db03148
Fingerprint results dialog
Yasith-Heshan Aug 12, 2023
6268ea0
Fix issues mentioned in review
Yasith-Heshan Aug 12, 2023
e749d9e
Fix 400 issue
Yasith-Heshan Aug 12, 2023
cd10a79
Fix Mosip --> CSE
Yasith-Heshan Aug 12, 2023
210f79e
remove commented lines
Yasith-Heshan Aug 13, 2023
5642126
Merge pull request #33 from Yasith-Heshan/Checkin_checkout
Yasith-Heshan Aug 13, 2023
abcaf93
Merge branch 'main' into implement/check-in-out
NethumL Aug 13, 2023
baf6d48
Update .env file with defaults
NethumL Aug 13, 2023
efa387f
Remove unnecessary `FingerprintService`
NethumL Aug 13, 2023
04aad58
Use `Link` from React Router instead of anchor tag
NethumL Aug 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_BACKEND_URL='http://localhost:8080/'
REACT_APP_VITE_NAME = "Booking App"
REACT_APP_SOCKET_HOST='http://localhost:4000'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ yarn-debug.log*
yarn-error.log*

.env

/.idea
84 changes: 81 additions & 3 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"react-toastify": "^9.1.3",
"recharts": "^2.7.2",
"redux-persist": "^6.0.0",
"socket.io-client": "^4.7.2",
"vite-plugin-env-compatible": "^1.1.1",
"web-vitals": "^2.1.4",
"yup": "^1.2.0"
Expand Down
Binary file added public/assets/images/fingerprint_failed.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/fingerprint_success.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/fp_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions src/components/FingerPrintResults.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import * as React from 'react';
import {styled} from '@mui/material/styles';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';
import Typography from '@mui/material/Typography';
import Grid from "@mui/material/Grid";
import {FingerPrintDetails, SetDialogOpenFunction} from "../types";
import FingerPrintFailed from '../../public/assets/images/fingerprint_failed.jpg'
import FingerPrintSuccess from '../../public/assets/images/fingerprint_success.jpg'

const BootstrapDialog = styled(Dialog)(({theme}) => ({
'& .MuiDialogContent-root': {
padding: theme.spacing(2),
},
'& .MuiDialogActions-root': {
padding: theme.spacing(1),
},
}));

export interface DialogTitleProps {
id: string;
children?: React.ReactNode;
onClose: () => void;
}

function BootstrapDialogTitle(props: DialogTitleProps) {
const {children, onClose, ...other} = props;

return (
<DialogTitle sx={{m: 0, p: 2}} {...other}>
{children}
{onClose ? (
<IconButton
aria-label="close"
onClick={onClose}
sx={{
position: 'absolute',
right: 1,
top: 0,
color: (theme) => theme.palette.grey[500],
}}
>
<CloseIcon/>
</IconButton>
) : null}
</DialogTitle>
);
}


export const FingerPrintResults = ({
open,
setOpen,
access,
booking
}: { open: boolean, setOpen: SetDialogOpenFunction, access: boolean, booking: FingerPrintDetails }) => {


const handleClose = () => {
setOpen(false);
};

return (
<div>

<BootstrapDialog
onClose={handleClose}
aria-labelledby="customized-dialog-title"
open={open}
>
<BootstrapDialogTitle id="customized-dialog-title" onClose={handleClose}>
</BootstrapDialogTitle>
<DialogContent dividers>
{
access ? (
<>
<Grid container direction={'column'} alignItems={'center'} justifyContent={'center'}>
<img style={{borderRadius: '50%'}}
src={FingerPrintSuccess}
alt={'fingerprint success'}/>
</Grid>
<Grid mt={1} container direction={"column"} alignItems={'center'} justifyContent={'center'}>
<Typography variant={"h6"} color={'green'} fontWeight={'bold'}>
Successfully Recognized
</Typography>

<Typography variant={'h4'} fontWeight={"bold"}>
{booking.username}
</Typography>
</Grid>
<Grid mt={2} spacing={2} container direction={"row"} alignItems={'center'}
justifyContent={'space-between'}>
<Grid item>
<Typography variant={'body2'}>
{booking.timeslot}
</Typography>
</Grid>
<Grid item>
</Grid>
<Grid item>
<Typography variant={'body2'}>
Count: {booking.count}
</Typography>
</Grid>
</Grid>
</>
) : (
<>
<Grid container direction={'column'} alignItems={'center'} justifyContent={'center'}>
<img style={{borderRadius: '50%'}}
src={FingerPrintFailed}
alt={'fingerprint success'}/>
</Grid>
<Typography gutterBottom variant={"h6"} color={'red'} mt={1}>
No Booking for this Timeslot
</Typography>
</>
)
}


</DialogContent>
</BootstrapDialog>
</div>
);
}
5 changes: 5 additions & 0 deletions src/helpers/socket.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { io } from "socket.io-client";

const URL = import.meta.env.REACT_APP_SOCKET_HOST;

export const socket = io(URL);
22 changes: 17 additions & 5 deletions src/navigation/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Dashboard from "../pages/layout/Dashboard";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import AddNewResourceContainer from "src/pages/add-resource/AddNewResourceContainer";
import LoginContainer from "src/pages/auth/LoginContainer";
import CheckInOutContainer from "src/pages/check-in-out/CheckInOutContainer";
import BookingContainer from "src/pages/create-booking/BookingContainer";
import ViewBookingsContainer from "src/pages/view-bookings/ViewBookingsContainer";
import AddNewResourceContainer from "src/pages/add-resource/AddNewResourceContainer";
import ViewResourcesContainer from "src/pages/view-resources/ViewResourcesContainer";
import LoginContainer from "src/pages/auth/LoginContainer";
import Dashboard from "../pages/layout/Dashboard";
import ProtectedRoute from "./protectedRoute";

const AppRoutes = () => {
Expand Down Expand Up @@ -53,6 +53,18 @@ const AppRoutes = () => {
</ProtectedRoute>
}
/>
<Route path="resources">
<Route path=":resourceId">
<Route
path="check-in-out"
element={
<ProtectedRoute permissions={["RESOURCE_MANAGER", "ADMIN"]}>
<CheckInOutContainer />
</ProtectedRoute>
}
/>
</Route>
</Route>
</Routes>
</BrowserRouter>
);
Expand Down
Loading