Skip to content

Commit 662b4bf

Browse files
committed
populate fields
1 parent 45a8bfe commit 662b4bf

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/features/Home/VisitorDetailsView1.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { config as VisitorFormConfig } from 'features/Settings/VisitorFormConfig
1616
import { fetchVisitorConfigs } from "features/Settings/visitorConfigSlice";
1717
import img from 'assets/logo/logo.png'
1818
import { fetchSites } from "features/SalesAndOrganisation/siteSlice";
19+
import { fetchEmployees } from "features/Employees/employeeSlice";
1920

2021
const useStyles = makeStyles((theme: Theme) => createStyles({
2122
paper: {
@@ -138,6 +139,9 @@ const VisitorDetailsView: FunctionComponent<Props> = (props) => {
138139
const {
139140
sites
140141
} = useSelector((state: RootState) => state.sites)
142+
const {
143+
employees
144+
} = useSelector((state: RootState) => state.employees)
141145
//const inputState = currentVisitor
142146
const {
143147
mask
@@ -182,6 +186,7 @@ sites
182186
useEffect(() => {
183187
dispatch(fetchVisitors())
184188
dispatch(fetchSites())
189+
dispatch(fetchEmployees())
185190
}, [dispatch])
186191

187192
const handleSubmit = async (e: any) => {
@@ -259,6 +264,11 @@ sites
259264
onChange: handleAutoComplete,
260265
value: purpose
261266
},
267+
visitors: {
268+
options: ['0','1','2','3','4','5','6','7','8','9','10'],
269+
onChange: handleAutoComplete,
270+
value: noofvisitor
271+
},
262272
style: {
263273
width: 446,
264274
marginLeft: i % 2 === 0 ? '64px' : '28px'
@@ -286,6 +296,11 @@ sites
286296
onChange: handleAutoComplete,
287297
value: site
288298
},
299+
person: {
300+
options: employees.map(o => o.fname + o.lname), //siteOptions ||
301+
onChange: handleAutoComplete,
302+
value: tomeet
303+
},
289304
style: {
290305
width: 446,
291306
marginLeft: i % 2 === 0 ? '64px' : '28px'

src/features/Settings/VisitorFormConfig.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ export const config = [{
5050
name: 'No. Of visitors',
5151
id: 'noofvisitor',
5252
section: 'VI',
53-
seq: 7
53+
seq: 7,
54+
component: ({ visitors, style }: any) => <CustomAutoComplete
55+
style={style}
56+
required
57+
options={visitors.options}
58+
label="no of visitors"
59+
name="noofvisitor"
60+
onChange={(value: any) => visitors.onChange({
61+
noofvisitor: value
62+
})}
63+
value={visitors.value} />
5464
}, {
5565
name: 'Vehicle Number',
5666
id: 'vehicle',
@@ -70,7 +80,17 @@ export const config = [{
7080
name: 'Person to visit',
7181
id: 'tomeet',
7282
section: 'AR',
73-
seq: 1
83+
seq: 1,
84+
component: ({ person, style }: any) => <CustomAutoComplete
85+
style={style}
86+
required
87+
options={person.options}
88+
label="Person"
89+
name="person"
90+
onChange={(value: any) => person.onChange({
91+
tomeet: value
92+
})}
93+
value={person.value} />
7494
}, {
7595
name: 'Purpose of visit',
7696
id: 'purpose',

0 commit comments

Comments
 (0)