*/}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default EmployeeForm
\ No newline at end of file
diff --git a/src/features/Employees/EmployeesView.tsx b/src/features/Employees/EmployeesView.tsx
index 48a8bb0..0e2fce3 100644
--- a/src/features/Employees/EmployeesView.tsx
+++ b/src/features/Employees/EmployeesView.tsx
@@ -1,12 +1,14 @@
-import React, {FunctionComponent, useEffect} from 'react';
+import React, { FunctionComponent, useEffect, useState } from 'react';
import TableWrapper from "../../components/TableWrapper";
-import {createStyles, fade, Grid, Paper, Theme} from "@material-ui/core";
-import {makeStyles} from "@material-ui/core/styles";
+import { Avatar, Box, createStyles, fade, Grid, Paper, Theme } from "@material-ui/core";
+import { makeStyles } from "@material-ui/core/styles";
import SearchInput from "../../components/SearchInput";
import { RootState } from 'app/rootReducer'
import { useSelector, useDispatch } from 'react-redux';
import { fetchEmployees } from 'features/Employees/employeeSlice'
import { CustomMenuItem } from 'components/CustomMenuItem';
+import { serverUrl } from 'api/Apis';
+import CustomButton from 'components/Button';
interface OwnProps {
}
@@ -24,34 +26,57 @@ const useStyles = makeStyles((theme: Theme) =>
)
-const data = {
- name: 'Vijaya Tondon',
- mobileNo: 9754821630,
- email: 'Vijaytandon@gmail.com',
- organization: 'Company Name'
-}
+
//const columns = ['Visitor name', 'Mobile No.', 'Email', 'Organization']
+// designation: any,//developer,
+// email: any,//arjunp@gmail.com,
+// empid: any,//002,
+// fname: any,//arjun,
+// lname: any,//pan,
+// mname: any,//test,
+// mobile: any,//1any,//2345678,
+// profilepicpath:
const columns = [
{
- id: "name",
- label: 'Visitor name'
+ id: "profilepicpath",
+ label: ''
+ },
+ {
+ id: "fname",
+ label: 'First name'
+ },
+ {
+ id: "mname",
+ label: 'Middle name'
+ },
+ {
+ id: "lname",
+ label: 'Last name'
},
{
id: "mobile",
- label: 'Mobile No.'
+ label: 'Mobile no.'
+ },
+ {
+ id: "email",
+ label: 'Email id'
},
{
- id: "tomeet",
- label: 'Email'
+ id: "designation",
+ label: 'Designation'
},
{
- id: "purpose",
- label: 'Organization'
- }]
+ id: "empid",
+ label: 'Employee id'
+ }
+]
const EmployeesView: FunctionComponent
= (props) => {
const classes = useStyles()
+ const [filter, setfilter] = useState("")
+ const [rowPerPage, setRowPerPage] = useState(10);
+
const dispatch = useDispatch()
const {
@@ -68,6 +93,10 @@ const EmployeesView: FunctionComponent = (props) => {
}, [dispatch])
+ useEffect(() => {
+ debugger
+ dispatch(fetchEmployees(0, rowPerPage,filter))
+ }, [filter])
if (error) {
return (
@@ -78,36 +107,42 @@ const EmployeesView: FunctionComponent = (props) => {
)
}
- let tableRows: any = []
-
- for (let i = 0; i < 10; i++) {
- let copy: any = tableRows
-
- tableRows = [data, ...copy]
- }
-
-
const TableConfig = {
columns: columns,
- data: employees,
+ data: employees.map(el => ({
+ ...el,
+ profilepicpath:
+ })),
isLoading: isLoadingEmployee,
- pagination:true,
- pageChange:(page:number,count:number)=>{
- dispatch(fetchEmployees(page,count))
+ pagination: true,
+ pageChange: (page: number, count: number) => {
+ dispatch(fetchEmployees(page, count,filter))
},
- totalCount:pageCount,
- menuOptions: [{
- item: (id: any) => console.log('check out ' + id)}>
- Check Out
-
- }]
+ totalCount: pageCount,
+ //@ts-ignore
+ // menuOptions: [
+ // {
+ // item: (id: any) => console.log('check out ' + id)}>
+ // Check Out
+ //
+ // }
+ // ]
}
return (
-
+
-
-
+
+
+ { setfilter(e.target.value ) }} value={filter}/*style={{ margin: '0 23px 30px', paddingTop: '37px' }}*/ placeholder="Search Employees by name" width={500} />
+ {/* */}
+
+
+ Add
+
+
+
+
);
diff --git a/src/features/Employees/employeeSlice.ts b/src/features/Employees/employeeSlice.ts
index f218761..8103bf2 100644
--- a/src/features/Employees/employeeSlice.ts
+++ b/src/features/Employees/employeeSlice.ts
@@ -1,93 +1,150 @@
-import { createSlice, PayloadAction } from '@reduxjs/toolkit'
-import { Links } from 'parse-link-header'
-
-import { getEmployeesData } from 'api/Apis'
-import { AppThunk } from 'app/store'
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import { Links } from "parse-link-header";
+import { createEmployee, getEmployeesData } from "api/Apis";
+import { AppThunk } from "app/store";
+import { getBackdropStart, getBackdropStop } from "app/BackdropSlice";
+import { startSnackbar } from "app/SnackbarSlice";
export interface Employee {
- email: any //"admin@gmail.com",
- intime: any //"2020-09-14 20:28:34",
- employee_id: any //"arj1600095514",
- mobileno: any //"123456789",
- name: any //"arjunp",
- purpose: any //"tomeet",
- scheduletime: any //"2020-09-12 15:00"
- tomeet: any //"arjun2"
+ createdOn: any; //2020-09-30 13: 14: 38,
+ designation: any; //developer,
+ email: any; //arjunp@gmail.com,
+ empid: any; //002,
+ fname: any; //arjun,
+ lname: any; //pan,
+ mname: any; //test,
+ mobile: any; //1any,//2345678,
+ profilepicpath: any; //uploads/images/arj_pic_1601471678_arjun_pass.JPG,
+ updatedOn: any; //2020-09-30 13: 14: 38
+ name: any;
}
export interface EmployeesResult {
- //pageLinks: Links | null
- pageCount: number
- employees: Employee[]
+ //pageLinks: Links | null
+ pageCount: number;
+ employees: Employee[];
+}
+
+export interface EmployeeInputState {
+ fname: string;
+ mname: string;
+ lname: string;
+ mobile: string;
+ email: string;
+ empid: string;
+ designation: string;
}
+export const defaultInputState: EmployeeInputState = {
+ fname: "",
+ mname: "",
+ lname: "",
+ mobile: "",
+ email: "",
+ empid: "",
+ designation: "",
+};
interface EmployeeState {
- employees: Employee[]
- employeesById: Record
- currentPageEmployees: number[]
- pageCount: number
- pageLinks: Links | null
- isLoading: boolean
- error: string | null
+ employees: Employee[];
+ employeesById: Record;
+ currentPageEmployees: number[];
+ pageCount: number;
+ pageLinks: Links | null;
+ isLoading: boolean;
+ error: string | null;
+ currentEmployee: EmployeeInputState;
}
const employeesInitialState: EmployeeState = {
- employees: [],
- employeesById: {},
- currentPageEmployees: [],
- pageCount: 0,
- pageLinks: {},
- isLoading: false,
- error: null
-}
+ employees: [],
+ employeesById: {},
+ currentPageEmployees: [],
+ pageCount: 0,
+ pageLinks: {},
+ isLoading: false,
+ error: null,
+ currentEmployee: defaultInputState,
+};
function startLoading(state: EmployeeState) {
- state.isLoading = true
+ state.isLoading = true;
}
function loadingFailed(state: EmployeeState, action: PayloadAction) {
- state.isLoading = false
- state.error = action.payload
+ state.isLoading = false;
+ state.error = action.payload;
}
const employees = createSlice({
- name: 'employees',
- initialState: employeesInitialState,
- reducers: {
-
- getEmployeesStart: startLoading,
- getEmployeesSuccess(state, { payload }: PayloadAction) {
- const { pageCount, employees } = payload
- state.pageCount = pageCount
- state.isLoading = false
- state.error = null
- state.employees = employees
- // @ts-ignore
- state.employees.map(employee => (state.employeesById[employee.employee_id]=employee))
- },
- getEmployeesFailure: loadingFailed,
- }
-})
+ name: "employees",
+ initialState: employeesInitialState,
+ reducers: {
+ getEmployeesStart: startLoading,
+ getEmployeesSuccess(state, { payload }: PayloadAction) {
+ const { pageCount, employees } = payload;
+ state.pageCount = pageCount;
+ state.isLoading = false;
+ state.error = null;
+ state.employees = employees.map((e) => ({
+ ...e,
+ name: e.fname + " " + e.mname + " " + e.lname,
+ }));
+ // @ts-ignore
+ state.employees.map(
+ (employee) => (state.employeesById[employee.empid] = employee)
+ );
+ },
+ getEmployeesFailure: loadingFailed,
+ setCurrentEmployee(state, { payload }: PayloadAction) {
+ state.currentEmployee = payload;
+ },
+ },
+});
export const {
- getEmployeesStart,
- getEmployeesSuccess,
- getEmployeesFailure
-} = employees.actions
+ getEmployeesStart,
+ getEmployeesSuccess,
+ getEmployeesFailure,
+ setCurrentEmployee,
+} = employees.actions;
-export default employees.reducer
+export default employees.reducer;
export const fetchEmployees = (
- page?: number
- , count?: number
-): AppThunk => async dispatch => {
- try {
- dispatch(getEmployeesStart())
- const employees = await getEmployeesData(page,count)
+ page?: number,
+ count?: number,
+ filter?: string
+): AppThunk => async (dispatch) => {
+ try {
+ dispatch(getEmployeesStart());
+ const employees = await getEmployeesData(page, count, filter);
- dispatch(getEmployeesSuccess(employees))
- } catch (err) {
- dispatch(getEmployeesFailure(err.toString()))
- }
-}
+ dispatch(getEmployeesSuccess(employees));
+ } catch (err) {
+ dispatch(getEmployeesFailure(err.toString()));
+ }
+};
+export const saveEmployee = (
+ employeeFormData: any,
+ callback?: () => void
+): AppThunk => async (dispatch) => {
+ try {
+ dispatch(getBackdropStart());
+ await createEmployee(employeeFormData)
+ .then(() => {
+ dispatch(getBackdropStop());
+ dispatch(startSnackbar({ message: "Employee created" }));
+ })
+ .catch(() => {
+ dispatch(getBackdropStop());
+ dispatch(startSnackbar({ message: "Something went wrong" }));
+ });
+ //return setInputState(defaultInputState)
+ callback && callback();
+ //dispatch(saveInvitesSuccess(invites))
+ } catch (err) {
+ dispatch(getBackdropStop());
+ dispatch(startSnackbar({ message: "Something went wrong" }));
+ }
+};
diff --git a/src/features/Home/HomeDateDropdown.tsx b/src/features/Home/HomeDateDropdown.tsx
index 748005e..9d1d491 100644
--- a/src/features/Home/HomeDateDropdown.tsx
+++ b/src/features/Home/HomeDateDropdown.tsx
@@ -23,7 +23,7 @@ const useStyles = makeStyles((theme: Theme) =>
'& .MuiInput-underline:before, & .MuiInput-underline:after': {
borderBottom: 'none !important'
},
- '& #date-picker-inline': {
+ '& #date-picker-inline2': {
fontWeight: 600,
color: theme.palette.text.primary,
fontSize: '20px',
@@ -85,7 +85,7 @@ const HomeDateDropdown: FunctionComponent = (props) => {
variant="inline"
format="MMM dd, yyyy"
margin="normal"
- id="date-picker-inline"
+ id="date-picker-inline2"
autoOk
value={selectedDate}
onChange={handleDateChange}
diff --git a/src/features/Home/HomeView.tsx b/src/features/Home/HomeView.tsx
index 02654ca..10ce0db 100644
--- a/src/features/Home/HomeView.tsx
+++ b/src/features/Home/HomeView.tsx
@@ -26,14 +26,15 @@ import TableWrapper from "components/TableWrapper";
import SearchInput from "components/SearchInput";
import SelectInput from "components/SelectInput";
import { useSelector, useDispatch } from 'react-redux';
-import { fetchVisitors } from 'features/Home/visitorSlice'
+import { fetchInOfficeVisitors, fetchVisitors, setFilter } from 'features/Home/visitorSlice'
import { fetchHomeStats } from 'features/Home/homeSlice'
import { RootState } from 'app/rootReducer'
import { MyChart2 } from 'components/Chart'
import { CustomMenuItem } from 'components/CustomMenuItem';
import Axios from 'axios';
-import { apis, checkout } from 'api/Apis';
+import { apis, checkout, serverUrl } from 'api/Apis';
import { getBackdropStart, getBackdropStop } from 'app/BackdropSlice';
+import CustomizedSwitch from 'components/Switch';
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -98,6 +99,14 @@ const useStyles = makeStyles((theme: Theme) =>
transition: theme.transitions.create('width'),
},
+ label: {
+ textTransform: 'capitalize'
+ },
+ buttonRoot: {
+ backgroundColor: 'white',
+ boxShadow: 'none',
+ borderRadius: theme.shape.borderRadius - 5
+ }
})
)
@@ -109,12 +118,34 @@ type Props = OwnProps;
const HomeView: FunctionComponent = (props) => {
const classes = useStyles()
+ const [rowPerPage, setRowPerPage] = useState(10);
const [anchorEl, setAnchorEl] = useState(null);
-
+ const [filter, setFilter] = useState({ visitor: "", purpose: "", site: "" })
const handleClick = (event: React.MouseEvent) => {
setAnchorEl(event.currentTarget);
};
+ const [inOffice, setInOffice] = useState(false);
+ const setInOffice1 = (flag:boolean)=>{
+ setInOffice(flag)
+ //flag ? dispatch(fetchInOfficeVisitors()) : dispatch(fetchVisitors());
+ }
+
+ const doFetch=(page=0, count=10, visitor="", purpose="", site="")=>{
+ inOffice? dispatch(fetchInOfficeVisitors(page, count, visitor, purpose, site)): dispatch(fetchVisitors(page, count, visitor, purpose, site))
+ }
+ const handleFilterChange = (f: any) => {
+ debugger;
+ const newFilter = { ...filter, ...f }
+ setFilter(newFilter)
+ const {
+ purpose: purpose1,
+ site: site1,
+ visitor: visitor1
+ } = newFilter
+ //dispatch(fetchVisitors(0, rowPerPage, visitor1, purpose1, site1))
+ //doFetch(0, rowPerPage, visitor1, purpose1, site1)
+ }
const handleClose = () => {
setAnchorEl(null);
};
@@ -151,17 +182,21 @@ const HomeView: FunctionComponent = (props) => {
isSort: true
}]
- let tableRows: any = []
+
const dispatch = useDispatch()
+ const {
+ sites
+ } = useSelector((state: RootState) => state.sites)
const {
visitors,
currentPageVisitors,
pageCount,
pageLinks,
isLoading: isLoadingVisitor,
- error
+ error,
+ purpose
} = useSelector((state: RootState) => state.visitors)
const {
@@ -175,16 +210,28 @@ const HomeView: FunctionComponent = (props) => {
} = useSelector((state: RootState) => state.home)
useEffect(() => {
- dispatch(fetchVisitors(0,10))
+ //dispatch(fetchVisitors(0, 10))
+ doFetch(0, 10)
dispatch(fetchHomeStats())
}, [dispatch])
+ useEffect(() => {
+
+ const {
+ purpose: purpose1,
+ site: site1,
+ visitor: visitor1
+ } = filter
+ doFetch(0, rowPerPage, visitor1, purpose1, site1)
+ }, [inOffice,filter])
+
const handleCheckOut = async (id: any) => {
dispatch(getBackdropStart())
await checkout(id)
.then(() => {
dispatch(fetchHomeStats())
- dispatch(fetchVisitors(0,10))
+ //dispatch(fetchVisitors(0, 10))
+ doFetch(0, 10)
dispatch(getBackdropStop())
})
.catch(() => dispatch(getBackdropStop()))
@@ -202,25 +249,29 @@ const HomeView: FunctionComponent = (props) => {
const TableConfig = {
columns: columns,
- isLoading: isLoadingHomeStats,
+ isLoading: isLoadingVisitor,
data: visitors.map(el => ({
...el,
- profilePicPath:
+ profilePicPath:
})),
- pagination:true,
- pageChange:(page:number,count:number)=>{
- dispatch(fetchVisitors(page,count))
+ pagination: true,
+ pageChange: (page: number, count: number) => {
+ const {
+ purpose: purpose1,
+ site: site1,
+ visitor: visitor1
+ } = filter
+ setRowPerPage(count)
+ //dispatch(fetchVisitors(page, count, visitor1, purpose1, site1))
+ doFetch(page, count, visitor1, purpose1, site1)
},
- totalCount:pageCount,
+ totalCount: pageCount,
menuOptions: [{
key: 'checkin_id',
callback: handleCheckOut,
item: (id: any) => {
- return ( {
-
- }
- }>
+ return (
{'Check Out'}
)
}
@@ -264,15 +315,34 @@ const HomeView: FunctionComponent = (props) => {
-
+ {/* Old gap 30px */}
+
-
-
-
-
+ { debugger; handleFilterChange({ visitor: e.target.value }) }} value={filter.visitor} placeholder="Search visitor" />
+ {/* */}
+ { setInOffice(!inOffice) }} />
+ {/* */}
+ { debugger; handleFilterChange({ purpose: e.target.value }) }} menuOptions={purpose.map(item => ({ title: item }))} defaultValue="All Purpose" value={filter.purpose} />
+ { debugger; handleFilterChange({ site: e.target.value }) }} menuOptions={sites.map(item => ({ title: item.sitename }))} defaultValue="All Sites" value={filter.site} />
+
+
-
+
diff --git a/src/features/Home/VisitorDetailsView1.tsx b/src/features/Home/VisitorDetailsView1.tsx
new file mode 100644
index 0000000..5069b16
--- /dev/null
+++ b/src/features/Home/VisitorDetailsView1.tsx
@@ -0,0 +1,521 @@
+import { Box, createStyles, Grid, Paper } from "@material-ui/core";
+import { makeStyles } from "@material-ui/core/styles";
+import { Theme } from "@material-ui/core/styles/createMuiTheme";
+import { ArrowBackIos, CameraAlt } from "@material-ui/icons";
+import { getBackdropStart, getBackdropStop } from "app/BackdropSlice";
+import {
+ setCurrentVisitor,
+ defaultVisitor,
+ fetchVisitors,
+} from "features/Home/visitorSlice";
+import React, { FunctionComponent, useEffect } from "react";
+import { useDispatch, useSelector } from "react-redux";
+import { RouteComponentProps } from "react-router-dom";
+import { apis, serverUrl } from "../../api/Apis";
+import { RootState } from "../../app/rootReducer";
+import CustomButton from "../../components/Button";
+import SelectInput from "../../components/SelectInput";
+import TextInput from "../../components/TextInput";
+import { config as VisitorFormConfig } from "features/Settings/VisitorFormConfig";
+import { fetchVisitorConfigs } from "features/Settings/visitorConfigSlice";
+import img from "assets/logo/logo.png";
+import { fetchSites } from "features/SalesAndOrganisation/siteSlice";
+import { fetchEmployees } from "features/Employees/employeeSlice";
+import { startSnackbar } from "app/SnackbarSlice";
+
+const useStyles = makeStyles((theme: Theme) =>
+ createStyles({
+ paper: {
+ backgroundColor: "#E7ECF6",
+ borderRadius: theme.shape.borderRadius - 5,
+ marginRight: 20,
+ height: "100%",
+ },
+ header: {
+ fontSize: "20px",
+ fontWeight: "bold",
+ padding: theme.spacing(2, 0, 0, 4),
+ color: theme.palette.text.primary,
+ },
+ headerSecondary: {
+ fontSize: "18.75px",
+ fontWeight: "bold",
+ padding: theme.spacing(0, 0, 2, 0),
+ color: theme.palette.text.primary,
+ },
+ arrowBack: {
+ height: "16px",
+ // verticalAlign: 'bottom',
+ cursor: "pointer",
+ },
+ imageContainer: {
+ padding: theme.spacing(3, 0, 0, 8),
+ },
+ imageUpload: {
+ position: "relative",
+ backgroundColor: "#fff",
+ height: 86,
+ width: 86,
+ textAlign: "center",
+ borderRadius: theme.shape.borderRadius,
+ "& > svg": {
+ height: "100%",
+ opacity: 0.7,
+ fontSize: "44px",
+ },
+ },
+ visitorInfo: {
+ padding: theme.spacing(2, 0, 1, 8),
+ },
+ appointment: {
+ padding: theme.spacing(1, 0, 2, 8),
+ },
+ rightInputs: {
+ marginTop: 117,
+ },
+ button: {
+ // marginRight: 20
+ },
+ selectInput: {
+ "& > .makeStyles-inputContainer-32": {
+ // padding: 0
+ },
+ },
+ })
+);
+
+const selectInputMenu = [
+ {
+ title: "Check Out",
+ },
+ {
+ title: "Alert",
+ },
+];
+
+interface OwnProps extends RouteComponentProps { }
+
+type Props = OwnProps;
+
+const VisitorDetailsView: FunctionComponent = (props) => {
+ const classes = useStyles();
+
+ const dispatch = useDispatch();
+ const { visitorConfigsById, isLoading, error: configError } = useSelector(
+ (state: RootState) => state.visitorConfig
+ );
+ const defaultInputState = {
+ id: 0,
+ avatar: "",
+ name: "",
+ mobileNo: "",
+ personToMeet: "",
+ purpose: "",
+ inTime: "",
+ outTime: "",
+ type: "",
+ noOfVisitors: "",
+ city: "",
+ email: "",
+ visitorCompany: "",
+ country: "",
+ site: "",
+ host: "",
+ gender: "",
+ };
+
+ //const [inputState, setInputState] = useState(defaultInputState)
+ const handleChange = (e: any) => {
+ dispatch(
+ setCurrentVisitor({
+ ...currentVisitor,
+ [e.target.name]: e.target.value,
+ })
+ );
+ };
+
+ const {
+ visitors,
+ visitorsById,
+ currentVisitor,
+ purpose: purposeOptions,
+ isLoading: isLoadingVisitor,
+ error,
+ } = useSelector((state: RootState) => state.visitors);
+ const { sites } = useSelector((state: RootState) => state.sites);
+ const { employees } = useSelector((state: RootState) => state.employees);
+ //const inputState = currentVisitor
+ const { mask } = useSelector((state: RootState) => state.backdrop);
+
+ const {
+ answer1,
+ answer3,
+ answer4,
+ answer5,
+ belongings,
+ checkin_id,
+ city,
+ company,
+ country,
+ email,
+ gender,
+ idCardImagePath,
+ idtype,
+ intime,
+ mobile,
+ name,
+ ndastatus,
+ noofvisitor,
+ organisation,
+ outime,
+ policycheckstatus,
+ profilePicPath,
+ purpose,
+ signaturePath,
+ site,
+ tomeet,
+ usertype,
+ answer2,
+ vehicleno,
+ } = currentVisitor;
+ const id = props.match.params.visitorId;
+ useEffect(() => {
+ id != -1 && dispatch(setCurrentVisitor(visitorsById[id] || defaultVisitor));
+ }, [id]);
+
+ useEffect(() => {
+ dispatch(fetchVisitors());
+ dispatch(fetchSites());
+ dispatch(fetchEmployees());
+ }, [dispatch]);
+
+ const handleSubmit = async (e: any) => {
+ dispatch(getBackdropStart());
+ let bodyFormData = new FormData();
+ bodyFormData.append("profilepic", "arjun_pass.jpg");
+ bodyFormData.append("idcard", "arjun_pass.jpg");
+ bodyFormData.append("signature", "arjun_pass.jpg");
+ bodyFormData.append("name", name);
+ bodyFormData.append("mobile", mobile);
+ bodyFormData.append("tomeet", tomeet);
+ bodyFormData.append("email", email);
+ bodyFormData.append("purpose", purpose);
+ bodyFormData.append("gender", gender);
+ bodyFormData.append("visitorcount", noofvisitor);
+ bodyFormData.append("company", company);
+ bodyFormData.append("country", country);
+ bodyFormData.append("organisation", organisation);
+ bodyFormData.append("site", site);
+ bodyFormData.append("vehicleno", vehicleno);
+ bodyFormData.append("belongings", belongings);
+ bodyFormData.append("idtype", idtype);
+ bodyFormData.append("city", city);
+ bodyFormData.append("answer1", answer1);
+ bodyFormData.append("answer2", answer2);
+ bodyFormData.append("answer3", answer3);
+ bodyFormData.append("answer4", answer4);
+ bodyFormData.append("answer5", answer5);
+ bodyFormData.append("ndacheck", ndastatus);
+ bodyFormData.append("policycheck", policycheckstatus);
+ bodyFormData.append("usertype", usertype);
+ await apis
+ .post("/product/reception/user/checkin", bodyFormData, {
+ headers: {
+ Accept: "*/*",
+ "Cache-Control": "no-cache",
+ "Accept-Encoding": "gzip, deflate, br",
+ Connection: "keep-alive",
+ "Content-Type": "multipart/form-data",
+ "Content-Length": 2617,
+ },
+ })
+ .then(() => {
+ dispatch(getBackdropStop());
+ dispatch(startSnackbar({ message: "Visitor checked in" }));
+ })
+ .catch(() => {
+ dispatch(getBackdropStop());
+ dispatch(startSnackbar({ message: "Something went wrong" }));
+ });
+ };
+
+ const handlePurpose = (value: any) => {
+ dispatch(
+ setCurrentVisitor({
+ ...currentVisitor,
+ purpose: value,
+ })
+ );
+ };
+
+ const handleAutoComplete = (obj: any) => {
+ dispatch(
+ setCurrentVisitor({
+ ...currentVisitor,
+ ...obj,
+ })
+ );
+ };
+
+ const visitorSectionFields = VisitorFormConfig.filter(
+ (i) =>
+ i.section === "VI" &&
+ visitorConfigsById[i.id] &&
+ visitorConfigsById[i.id].value
+ )
+ .sort((a, b) => a.seq - b.seq)
+ .map((o, i) => (
+
+ {/* {(o.render && o.render(notificationById[i], handleChange, i + "-" + o.key)) || obj[o.key]} */}
+ {/* */}
+ {o.component ? (
+ o.component({
+ purpose: {
+ options: purposeOptions,
+ onChange: handleAutoComplete,
+ value: purpose,
+ },
+ visitors: {
+ options: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"],
+ onChange: handleAutoComplete,
+ value: noofvisitor,
+ },
+ style: {
+ width: 446,
+ marginLeft: i % 2 === 0 ? "64px" : "28px",
+ },
+ })
+ ) : (
+
+ )}
+
+ ));
+ const appointmentSectionFields = VisitorFormConfig.filter(
+ (i) =>
+ i.section === "AR" &&
+ visitorConfigsById[i.id] &&
+ visitorConfigsById[i.id].value
+ )
+ .sort((a, b) => a.seq - b.seq)
+ .map((o, i) => (
+
+ {/* {(o.render && o.render(notificationById[i], handleChange, i + "-" + o.key)) || obj[o.key]} */}
+ {o.component ? (
+ o.component({
+ site: {
+ options: sites.map((o) => o.sitename), //siteOptions ||
+ onChange: handleAutoComplete,
+ value: site,
+ },
+ person: {
+ options: employees.map((o) => o.fname + " " + o.lname), //siteOptions ||
+ onChange: handleAutoComplete,
+ value: tomeet,
+ },
+ style: {
+ width: 446,
+ marginLeft: i % 2 === 0 ? "64px" : "28px",
+ },
+ })
+ ) : (
+
+ )}
+
+ ));
+
+ useEffect(() => {
+ //dispatch(fetchVisitorConfigs())
+ }, [dispatch]);
+ return (
+
+
+
+
+
+ );
+};
+
+export default VisitorDetailsView;
diff --git a/src/features/Home/homeSlice.ts b/src/features/Home/homeSlice.ts
index cb10206..ad06d9b 100644
--- a/src/features/Home/homeSlice.ts
+++ b/src/features/Home/homeSlice.ts
@@ -1,16 +1,15 @@
-import { createSlice, PayloadAction } from '@reduxjs/toolkit';
-import { getHomeStats } from 'api/Apis';
-import { AppThunk } from 'app/store';
-
+import { createSlice, PayloadAction } from "@reduxjs/toolkit";
+import { getHomeStats } from "api/Apis";
+import { AppThunk } from "app/store";
interface homeStatsState {
- checked_out: number
- in_office: number
- invite_sent: number
- total_visitor: number
- visitors: number[]
- isLoading: boolean
- error: string | null
+ checked_out: number;
+ in_office: number;
+ invite_sent: number;
+ total_visitor: number;
+ visitors: number[];
+ isLoading: boolean;
+ error: string | null;
}
const homeStatsInitialState: homeStatsState = {
@@ -20,61 +19,58 @@ const homeStatsInitialState: homeStatsState = {
total_visitor: 0,
visitors: [],
isLoading: false,
- error: null
-}
+ error: null,
+};
function startLoading(state: homeStatsState) {
- state.isLoading = true
+ state.isLoading = true;
}
function loadingFailed(state: homeStatsState, action: PayloadAction) {
- state.isLoading = false
- state.error = action.payload
+ state.isLoading = false;
+ state.error = action.payload;
}
-
const homeStats = createSlice({
- name: 'homeStats',
+ name: "homeStats",
initialState: homeStatsInitialState,
reducers: {
-
getHomeStatsStart: startLoading,
getHomeStatsSuccess(state, { payload }: PayloadAction) {
- const { checked_out,
+ const {
+ checked_out,
in_office,
invite_sent,
total_visitor,
visitors,
- isLoading } = payload
- state.checked_out = checked_out
- state.in_office = in_office
- state.invite_sent = invite_sent
- state.total_visitor = total_visitor
- state.isLoading = false
- state.error = null
- state.visitors = visitors
+ isLoading,
+ } = payload;
+ state.checked_out = checked_out;
+ state.in_office = in_office;
+ state.invite_sent = invite_sent;
+ state.total_visitor = total_visitor;
+ state.isLoading = false;
+ state.error = null;
+ state.visitors = visitors;
},
getHomeStatsFailure: loadingFailed,
- }
-})
+ },
+});
export const {
getHomeStatsStart,
getHomeStatsSuccess,
getHomeStatsFailure,
-} = homeStats.actions
+} = homeStats.actions;
-export default homeStats.reducer
+export default homeStats.reducer;
-export const fetchHomeStats = (
- page?: number
-): AppThunk => async dispatch => {
+export const fetchHomeStats = (page?: number): AppThunk => async (dispatch) => {
try {
- dispatch(getHomeStatsStart())
- const stats = await getHomeStats()
- dispatch(getHomeStatsSuccess(stats.data))
+ dispatch(getHomeStatsStart());
+ const stats = await getHomeStats();
+ dispatch(getHomeStatsSuccess(stats.data));
} catch (err) {
- dispatch(getHomeStatsFailure(err.toString()))
+ dispatch(getHomeStatsFailure(err.toString()));
}
-}
-
+};
diff --git a/src/features/Home/visitorSlice.ts b/src/features/Home/visitorSlice.ts
index 42dffed..580cfe4 100644
--- a/src/features/Home/visitorSlice.ts
+++ b/src/features/Home/visitorSlice.ts
@@ -1,8 +1,9 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { Links } from 'parse-link-header'
-import { VisitorsResult, getVisitorInfo, getVisitorData } from 'api/Apis'
+import { VisitorsResult, getVisitorData, getPurpose, getInOfficeVisitorData } from 'api/Apis'
import { AppThunk } from 'app/store'
+import { fetchSites } from 'features/SalesAndOrganisation/siteSlice'
export interface VisitorInfo {
answer1: any,
@@ -69,14 +70,16 @@ export const defaultVisitor: VisitorInfo = {
}
interface VisitorState {
- visitors: VisitorInfo[]
+ visitors: VisitorInfo[],
visitorsById: any,
- currentVisitor: VisitorInfo
- currentPageVisitors: number[]
- pageCount: number
- pageLinks: Links | null
- isLoading: boolean
- error: string | null
+ currentVisitor: VisitorInfo,
+ currentPageVisitors: number[],
+ pageCount: number,
+ pageLinks: Links | null,
+ isLoading: boolean,
+ error: string | null,
+ purpose: any[],
+ filter: any,
}
const visitorsInitialState: VisitorState = {
@@ -87,7 +90,9 @@ const visitorsInitialState: VisitorState = {
pageCount: 0,
pageLinks: {},
isLoading: false,
- error: null
+ error: null,
+ purpose: [],
+ filter: { visitor: "", purpose: "All Purpose", site: "All Sites" }
}
function startLoading(state: VisitorState) {
@@ -115,9 +120,16 @@ const visitors = createSlice({
state.visitors.map(visitor => (state.visitorsById[visitor.checkin_id] = visitor))
//state.visitorsById = state.visitors.map(visitor => ({ ...visitor, id: visitor.id }))
},
+ getPurposeSuccess(state, { payload }: PayloadAction) {
+ const { purpose } = payload
+ state.purpose = purpose
+ },
getVisitorsFailure: loadingFailed,
setCurrentVisitor(state, { payload }: PayloadAction) {
state.currentVisitor = payload
+ },
+ setFilter(state, { payload }: PayloadAction) {
+ state.filter = { ...state.filter, ...payload }
}
}
})
@@ -126,23 +138,50 @@ export const {
getVisitorsStart,
getVisitorsSuccess,
getVisitorsFailure,
- setCurrentVisitor
+ setCurrentVisitor,
+ getPurposeSuccess,
+ setFilter
} = visitors.actions
export default visitors.reducer
export const fetchVisitors = (
- page?: number
- , count?: number
+ page?: number,
+ count?: number,
+ visitor?: string,
+ purpose?: string,
+ site?: string
): AppThunk => async dispatch => {
try {
+ dispatch(fetchSites())
dispatch(getVisitorsStart())
- const visitors = await getVisitorData(page,count)
-
+ const visitors = await getVisitorData(page, count, visitor, purpose, site)
dispatch(getVisitorsSuccess(visitors))
+
+ const pur = await getPurpose()
+ dispatch(getPurposeSuccess(pur))
} catch (err) {
dispatch(getVisitorsFailure(err.toString()))
}
}
+export const fetchInOfficeVisitors = (
+ page?: number,
+ count?: number,
+ visitor?: string,
+ purpose?: string,
+ site?: string
+): AppThunk => async dispatch => {
+ try {
+ dispatch(fetchSites())
+ dispatch(getVisitorsStart())
+ const visitors = await getInOfficeVisitorData(page, count, visitor, purpose, site)
+ dispatch(getVisitorsSuccess(visitors))
+
+ const pur = await getPurpose()
+ dispatch(getPurposeSuccess(pur))
+ } catch (err) {
+ dispatch(getVisitorsFailure(err.toString()))
+ }
+}
diff --git a/src/features/Invites/InviteForm.tsx b/src/features/Invites/InviteForm.tsx
index ff5fe8e..05d7764 100644
--- a/src/features/Invites/InviteForm.tsx
+++ b/src/features/Invites/InviteForm.tsx
@@ -5,14 +5,18 @@ import { Theme } from "@material-ui/core/styles/createMuiTheme";
import { ArrowBackIos } from "@material-ui/icons";
import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';
import { getBackdropStart, getBackdropStop } from 'app/BackdropSlice';
-import React, { FunctionComponent, useState } from 'react';
-import { useDispatch } from "react-redux";
+import React, { FunctionComponent, useEffect, useState } from 'react';
+import { useDispatch, useSelector } from "react-redux";
import { RouteComponentProps } from 'react-router-dom';
import { createInvite } from "../../api/Apis";
import CustomButton from "../../components/Button";
import TextInput from "../../components/TextInput";
import DateTimeInput from 'components/DateTimeInput'
import { saveInvite } from 'features/Invites/inviteSlice'
+import { RootState } from 'app/rootReducer';
+import { CustomAutoComplete } from 'components/CustomAutoComplete';
+import { fetchVisitors } from 'features/Home/visitorSlice';
+import { fetchEmployees } from 'features/Employees/employeeSlice';
const useStyles = makeStyles((theme: Theme) => createStyles({
paper: {
backgroundColor: '#E7ECF6',
@@ -95,18 +99,22 @@ const InviteForm: FunctionComponent = (props) => {
name: '',
mobileNo: '',
personToMeet: '',
- purpose: '',
+ purpose: 'default',
email: '',
})
- const handleChange = (e: any) => setInputState({
+ const handleChange = (e: any) => {debugger;setInputState({
...inputState,
[e.target.name]: e.target.value
- })
+ })}
const handleDateChange = (date: Date | null) => setInputState({
...inputState,
'time': date
})
+ const handlePurpose = (value: any) => setInputState({
+ ...inputState,
+ purpose: value
+ })
const handleSubmit = async (e: any) => {
e.preventDefault()
@@ -128,6 +136,11 @@ const InviteForm: FunctionComponent = (props) => {
}), () => setInputState(defaultInputState)))
}
+ const {
+ employees
+ } = useSelector((state: RootState) => state.employees)
+ const {purpose} = useSelector((state: RootState) => state.visitors)
+
// const {
// visitors,
// visitorsById,
@@ -137,12 +150,11 @@ const InviteForm: FunctionComponent = (props) => {
//
//
// const id = props.match.params.visitorId
- // useEffect(() => {
- // if (visitorsById[id]) {
- // setInputState(visitorsById[id])
- // }
- // console.log(visitors, inputState)
- // }, [id])
+ useEffect(() => {
+ dispatch(fetchVisitors())
+ dispatch(fetchEmployees(0,9999999))
+ }, [dispatch])
+
return (
@@ -193,17 +205,28 @@ const InviteForm: FunctionComponent = (props) => {
onChange={handleChange}
name="email"
value={inputState.email} />
-
- */}
+ o.fname + " " + o.lname)}
+ label="Person To Meet"
+ onChange={(val:any)=>setInputState({
+ ...inputState,
+ personToMeet:val
+ })}
+ name="personToMeet"
+ value={inputState.personToMeet} />
+
diff --git a/src/features/Invites/InviteView.tsx b/src/features/Invites/InviteView.tsx
index 8f3e45d..f27c2c1 100644
--- a/src/features/Invites/InviteView.tsx
+++ b/src/features/Invites/InviteView.tsx
@@ -25,7 +25,7 @@ import TableWrapper from "../../components/TableWrapper";
import SearchInput from "../../components/SearchInput";
import SelectInput from "../../components/SelectInput";
import { useSelector, useDispatch } from 'react-redux';
-import { fetchInvites } from 'features/Invites/inviteSlice'
+import { fetchInOfficeInvites, fetchInvites } from 'features/Invites/inviteSlice'
import { RootState } from 'app/rootReducer'
import { CustomMenuItem } from 'components/CustomMenuItem';
import HomeDateDropdown from 'features/Home/HomeDateDropdown';
@@ -97,6 +97,14 @@ const useStyles = makeStyles((theme: Theme) =>
},
},
},
+ label: {
+ textTransform: 'capitalize'
+ },
+ buttonRoot: {
+ backgroundColor: 'white',
+ boxShadow: 'none',
+ borderRadius: theme.shape.borderRadius - 5
+ }
})
)
@@ -137,6 +145,8 @@ const InviteView: FunctionComponent = (props) => {
const classes = useStyles()
const [anchorEl, setAnchorEl] = useState(null);
+ const [filter, setFilter] = useState({ visitor: "", purpose: "", site: "" })
+ const [rowPerPage, setRowPerPage] = useState(10);
const handleClick = (event: React.MouseEvent) => {
setAnchorEl(event.currentTarget);
@@ -146,12 +156,14 @@ const InviteView: FunctionComponent = (props) => {
setAnchorEl(null);
};
- let tableRows: any = []
-
-
-
const dispatch = useDispatch()
+ const {
+ sites
+ } = useSelector((state: RootState) => state.sites)
+ const {
+ purpose
+ } = useSelector((state: RootState) => state.visitors)
const {
invites,
currentPageInvites,
@@ -176,13 +188,13 @@ const InviteView: FunctionComponent = (props) => {
)
}
- const toVisitor = (id:any)=>{
- const visitor = {...mapVisitorFromInvite(id)}
+ const toVisitor = (id: any) => {
+ const visitor = { ...mapVisitorFromInvite(id) }
dispatch(setCurrentVisitor(visitor))
}
- const mapVisitorFromInvite: (id:any)=>VisitorInfo = (id:any)=>{
-
- let visitor: VisitorInfo = {...defaultVisitor}
+ const mapVisitorFromInvite: (id: any) => VisitorInfo = (id: any) => {
+
+ let visitor: VisitorInfo = { ...defaultVisitor }
const invite = invitesById[id]
visitor.email = invite.email
//visitor.intime = invite.intime
@@ -190,7 +202,20 @@ const InviteView: FunctionComponent = (props) => {
visitor.name = invite.name
visitor.purpose = invite.purpose
visitor.tomeet = invite.tomeet
- return {...visitor}
+ return { ...visitor }
+ }
+
+ const handleFilterChange = (f: any) => {
+ debugger;
+ const newFilter = { ...filter, ...f }
+ setFilter(newFilter)
+ const {
+ purpose: purpose1,
+ site: site1,
+ visitor: visitor1
+ } = newFilter
+
+ dispatch(fetchInvites(0, rowPerPage, visitor1, purpose1, site1))
}
const TableConfig = {
@@ -201,10 +226,16 @@ const InviteView: FunctionComponent = (props) => {
})),
isLoading: isLoadingInvites,
pagination: true,
- pageChange:(page:number,count:number)=>{
- dispatch(fetchInvites(page,count))
+ pageChange: (page: number, count: number) => {
+ const {
+ purpose: purpose1,
+ site: site1,
+ visitor: visitor1
+ } = filter
+ setRowPerPage(count)
+ dispatch(fetchInvites(page, count, visitor1, purpose1, site1))
},
- totalCount:pageCount,
+ totalCount: pageCount,
menuOptions: [{
key: 'invite_id',
callback: toVisitor,
@@ -217,14 +248,29 @@ const InviteView: FunctionComponent = (props) => {
return (
-
-
+
+
-
+ {/*
-
+ */}
+ { debugger; handleFilterChange({ visitor: e.target.value }) }} value={filter.visitor} placeholder="Search visitor" />
+ {/* */}
+ {/* */}
+ { debugger; handleFilterChange({ purpose: e.target.value }) }} menuOptions={purpose.map(item => ({ title: item }))} defaultValue="All Purpose" value={filter.purpose} />
+ {/* { debugger; handleFilterChange({ site: e.target.value }) }} menuOptions={sites.map(item => ({ title: item.sitename }))} defaultValue="All Sites" value={filter.site} /> */}
+
diff --git a/src/features/Invites/inviteSlice.ts b/src/features/Invites/inviteSlice.ts
index f599ee8..21bc38d 100644
--- a/src/features/Invites/inviteSlice.ts
+++ b/src/features/Invites/inviteSlice.ts
@@ -1,35 +1,38 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { Links } from 'parse-link-header'
-import { getInvitesData, createInvite } from 'api/Apis'
+import { getInvitesData, createInvite, getPurpose, getInOfficeInviteData } from 'api/Apis'
import { AppThunk } from 'app/store'
-import {getBackdropStart, getBackdropStop} from 'app/BackdropSlice'
+import { getBackdropStart, getBackdropStop } from 'app/BackdropSlice'
+import { fetchSites } from 'features/SalesAndOrganisation/siteSlice'
+import { getPurposeSuccess } from 'features/Home/visitorSlice'
+import { startSnackbar } from 'app/SnackbarSlice'
export interface Invite {
- email: any //"admin@gmail.com",
- intime: any //"2020-09-14 20:28:34",
- invite_id: any //"arj1600095514",
- mobileno: any //"123456789",
- name: any //"arjunp",
- purpose: any //"tomeet",
- scheduletime: any //"2020-09-12 15:00"
+ email: any, //"admin@gmail.com",
+ intime: any, //"2020-09-14 20:28:34",
+ invite_id: any,//"arj1600095514",
+ mobileno: any, //"123456789",
+ name: any, //"arjunp",
+ purpose: any, //"tomeet",
+ scheduletime: any, //"2020-09-12 15:00"
tomeet: any //"arjun2"
}
export interface InvitesResult {
//pageLinks: Links | null
- pageCount: number
- invites: Invite[]
+ pageCount: number,
+ invites: Invite[],
}
interface InviteState {
- invites: Invite[]
- invitesById: Record
- currentPageInvites: number[]
- pageCount: number
- pageLinks: Links | null
- isLoading: boolean
- error: string | null
+ invites: Invite[],
+ invitesById: Record,
+ currentPageInvites: number[],
+ pageCount: number,
+ pageLinks: Links | null,
+ isLoading: boolean,
+ error: string | null,
}
const invitesInitialState: InviteState = {
@@ -58,13 +61,13 @@ const invites = createSlice({
getInvitesStart: startLoading,
getInvitesSuccess(state, { payload }: PayloadAction) {
- const { pageCount, invites } = payload
+ const { pageCount, invites } = payload
state.pageCount = pageCount
state.isLoading = false
state.error = null
state.invites = invites
// @ts-ignore
- state.invites.map(invite => (state.invitesById[invite.invite_id]=invite))
+ state.invites.map(invite => (state.invitesById[invite.invite_id] = invite))
},
getInvitesFailure: loadingFailed,
}
@@ -80,13 +83,19 @@ export default invites.reducer
export const fetchInvites = (
page?: number,
- count?: number
+ count?: number,
+ visitor?: string,
+ purpose?: string,
+ site?: string
): AppThunk => async dispatch => {
try {
+ dispatch(fetchSites())
dispatch(getInvitesStart())
- const invites = await getInvitesData(page,count)
+ const invites = await getInvitesData(page, count, visitor, purpose, site)
dispatch(getInvitesSuccess(invites))
+ const pur = await getPurpose()
+ dispatch(getPurposeSuccess(pur))
} catch (err) {
dispatch(getInvitesFailure(err.toString()))
}
@@ -94,18 +103,44 @@ export const fetchInvites = (
export const saveInvite = (
invite: any,
- callback?:Function
+ callback?: Function
): AppThunk => async dispatch => {
try {
//dispatch(saveInviteStart())
dispatch(getBackdropStart())
await createInvite(invite)
- .then(() => dispatch(getBackdropStop())).catch(() => dispatch(getBackdropStop()))
+ .then(() => {
+ dispatch(getBackdropStop())
+ dispatch(startSnackbar({ message: 'Your invitee has been invited' }))
+ })
+ .catch(() => {
+ dispatch(getBackdropStop())
+ dispatch(startSnackbar({ message: 'Something went wrong' }))
+ })
//return setInputState(defaultInputState)
callback && callback();
//dispatch(saveInvitesSuccess(invites))
} catch (err) {
//dispatch(saveInvitesFailure(err.toString()))
dispatch(getBackdropStop())
+ dispatch(startSnackbar({ message: 'Something went wrong' }))
+ }
+}
+
+
+export const fetchInOfficeInvites = (
+ page?: number
+ , count?: number
+): AppThunk => async dispatch => {
+ try {
+ dispatch(fetchSites())
+ dispatch(getInvitesStart())
+ const visitors = await getInOfficeInviteData()
+ dispatch(getInvitesSuccess(visitors))
+
+ const purpose = await getPurpose()
+ dispatch(getPurposeSuccess(purpose))
+ } catch (err) {
+ dispatch(getInvitesFailure(err.toString()))
}
}
diff --git a/src/features/SalesAndOrganisation/CheckInPointForm.tsx b/src/features/SalesAndOrganisation/CheckInPointForm.tsx
new file mode 100644
index 0000000..204a692
--- /dev/null
+++ b/src/features/SalesAndOrganisation/CheckInPointForm.tsx
@@ -0,0 +1,165 @@
+import { Box, createStyles, Grid, Paper } from "@material-ui/core";
+import { makeStyles } from "@material-ui/core/styles";
+import { Theme } from "@material-ui/core/styles/createMuiTheme";
+import { ArrowBackIos } from "@material-ui/icons";
+// import { saveCheckInPoint, setCurrentCheckInPoint } from './checkInPointSlice';
+import { RootState } from 'app/rootReducer';
+import CustomButton from "components/Button";
+import { CustomAutoComplete } from "components/CustomAutoComplete";
+import TextInput from "components/TextInput";
+import React, { FunctionComponent, useEffect } from 'react';
+import { useDispatch, useSelector } from "react-redux";
+import { RouteComponentProps } from 'react-router-dom';
+import { CheckInPointInputState, defaultInputState, saveCheckInPoint, setCurrentCheckInPoint } from './checkInPointSlice';
+import { fetchSites } from "./siteSlice";
+
+const useStyles = makeStyles((theme: Theme) => createStyles({
+ paper: {
+ backgroundColor: '#E7ECF6',
+ borderRadius: theme.shape.borderRadius - 5,
+ marginRight: 30,
+ height: '100%',
+ width: '100%'
+ // marginTop
+ },
+ header: {
+ fontSize: '22px',
+ fontWeight: 'bold',
+ padding: theme.spacing(2, 0, 0, 4),
+ color: theme.palette.text.primary
+ },
+ headerSecondary: {
+ fontSize: '20px',
+ fontWeight: 'bold',
+ padding: theme.spacing(0, 0, 4, 0),
+ color: theme.palette.text.primary,
+ },
+ arrowBack: {
+ height: '30px',
+ verticalAlign: 'bottom',
+ cursor: 'pointer',
+ },
+ rightInputs: {
+ marginTop: 134,
+ },
+ button: {
+ marginRight: 20
+ },
+ inputGrid: {
+ marginTop: '30px',
+ padding: theme.spacing(1, 0, 0, 2)
+ }
+}))
+
+interface OwnProps extends RouteComponentProps {
+}
+
+type Props = OwnProps;
+
+const CheckInPointForm: FunctionComponent = (props) => {
+ const classes = useStyles()
+
+ const dispatch = useDispatch()
+
+ const {
+ checkInPoints,
+ currentCheckInPoint,
+ checkInPointsById,
+ error
+ } = useSelector((state: RootState) => state.checkinpoints)
+
+ const {sites} = useSelector((state: RootState) => state.sites)
+
+ const {
+ sitename,
+ device,
+ checkinpoint,
+ } = currentCheckInPoint
+ const inputState = currentCheckInPoint;
+
+ const setInputState = (checkInPoint: CheckInPointInputState) => {
+ dispatch(setCurrentCheckInPoint(checkInPoint));
+ }
+
+
+ const handleChange = (e: any) => setInputState({
+ ...inputState,
+ [e.target.name]: e.target.value
+ })
+
+ const handleSubmit = async (e: any) => {
+ e.preventDefault()
+ dispatch(saveCheckInPoint(JSON.stringify({
+ "sitename": sitename,
+ "device": device,
+ "checkinpoint": checkinpoint
+ }), () => setInputState(defaultInputState)))
+ }
+
+ const handleSiteChange = (sitename: string) => {
+ setInputState({
+ ...inputState,
+ sitename: sitename
+ });
+ }
+
+ useEffect(() => {
+ dispatch(fetchSites())
+ }, [dispatch])
+
+ return (
+
+
+