forked from NIUANULP/nulp-elite-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TASK : #0000 If user is created from admin, that user will be shown f…
…or update user profile for the first time login
- Loading branch information
1 parent
86771b6
commit c6f7b93
Showing
6 changed files
with
397 additions
and
4 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
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,5 @@ | ||
{ | ||
"designations": [ "Accountant", "Accountant & Cashier", "Accounts Clerk & Computer Operator", "Accounts Officer", "Additional City Engineer", "Additional Commissioner", "Additional Municipal Commissioner/ Additional Administrator", "Administrative Officer", "Advocate", "Analyst", "Architect", "Architect and Urban Designer", "Architect and Urban Planner", "Assessor", "Assistant Accounts Officer", "Assistant Architect", "Assistant Assessment", "Assistant Commissioner", "Assistant Engineer (Civil)", "Assistant Engineer (Electrical)", "Assistant Engineer (Mechanical)", "Assistant Engineer (Transport)", "Assistant Executive Engineer", "Assistant Law Officer", "Assistant Manager", "Assistant Municipal Commissioner", "Assistant Planner", "Assistant Professor", "Assistant Programmer", "Assistant Public Health Officer", "Assistant Public Information Officer", "Assistant Revenue Inspector", "Assistant Sanitary Inspector", "Assistant Tax Superintendent", "Assistant Town Planner", "Associate Manager", "Associate Town Planner", "Associate Vice President", "Auditor", "Billing Assistant", "Brand Ambassador", "Building Inspector", "C&D/ GIS operator", "Capacity Building Expert", "Chairperson", "Chief Accountant", "Chief Accounts Officer", "Chief Archives Officer", "Chief Auditor", "Chief Engineer/ Engineer-in-Chief", "Chief Enquiry Officer", "Chief Ethnographer", "Chief Executive Officer", "Chief Facilitator", "Chief Finance Officer", "Chief Fire Officer", "Chief Information Technology (IT) Officer", "Chief Labour Officer", "Chief Municipal Officer", "Chief Operating Officer", "Chief Personnel Officer", "Chief Sanitary Inspector", "Chief Security Officer", "Chief Town Planner", "City Coordinator", "City Data Officer", "City Engineer", "City Health Officer", "City Manager", "City Project Officer", "Civil Engineer", "Clerk", "Collector", "Commissioner", "Company Secretary", "Computer Operator", "Computer Programmer", "Consultant", "Councillor", "Customer Support Leader", "Data Analyst", "Data Entry Operator", "Deputy Administrator", "Deputy Director", "Deputy General Manager", "Deputy Municipal Commissioner", "Development Fellow", "Director", "Director Town Planning", "District Coordinator", "Divisional Coordinator", "Draughtsman", "Education Officer", "Engineer", "Environment officer - climate change", "Executive Engineer", "Executive Engineer (Civil)", "Executive Health Officer", "Executive Officer", "Executive Town Planner", "Fellow", "Finance Officer", "Garden Superintendent", "General Manager", "Geologist", "GIS Expert", "Head Clerk", "Head of Department", "Health Assistant", "Health Officer", "Heavy Vehicle Driver", "Horticulture Officer", "Human Resource Officer", "IEC Expert", "Information Technology (IT) Officer", "Joint City Engineer", "Joint Commissioner", "Junior Architect", "Junior Assistant", "Junior Engineer (Civil)", "Junior Engineer (Electrical)", "Junior Engineer (Mechanical)", "Junior Planner", "Law Assistant", "Law Officer", "Lead Architect", "Legal assistant", "Legal Officer", "Light Vehicle Driver", "Lower Divisional Clerk", "Manager", "Medical Officer", "Member Secretary", "Monitoring Evaluation Expert", "Municipal Architect", "Municipal Commissioner/ Administrator", "Municipal Secretary", "Office Assistant cum Accountant", "Office Assistant cum Comp Operator", "Peon", "Personal Assistant", "PG Student", "PHD Scholar", "Planning Assistant", "Professor", "Program Associate", "Program Fellow", "Programmer", "Project Coordinator", "Project Lead", "Public Health Officer", "Public Information Officer", "Public Relations Officer", "Publicity Assistant", "Revenue Inspector", "Sanitary & Food Inspector", "Sanitary Supervisor", "Sanitation Inspector", "Sanitation Worker/ Sweeper", "Secretary", "Section Officer/ Land Revenue Officer", "Security Officer", "Senior Assistant Urban Planner", "Senior Associate", "Senior Clerk", "Senior Consultant", "Senior Research Associate", "Software Developer", "Special Officer", "Stenographer", "Street Light Inspector", "Student", "Sub Engineer", "Superintendent Engineer", "Supervisor", "Surveyor/ Tracer", "Sweeper", "SWM Expert", "System Analyst", "Tax collector", "Tax Recovery Officer", "Team Lead", "Technical Advisor to Chief Engineer", "Technical Assistant", "Town Planner", "Transport Planner", "Undergraduate", "Upper Division Clerk", "Urban Designer", "Urban Development Expert", "Urban Planner", "Valuation Officer", "Veterinary Assistant", "Veterinary Officer", "Vice Chairman", "Vice President", "Vigilance Officer", "Ward Officer", | ||
"Zonal and Taxation Officer","other"], | ||
"userTypes": ["State Governments / Parastatal Bodies", "Urban Local Bodies / Special Purpose Vehicles", "Academia and Research Organisations", "Multilateral / Bilateral Agencies", "Industries"] | ||
} |
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,136 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogTitle, | ||
TextField, | ||
FormControl, | ||
Button, | ||
DialogActions, | ||
} from '@mui/material'; | ||
import Select from 'react-select'; | ||
import axios from 'axios'; | ||
const userData = require('../assets/userData.json'); | ||
import * as util from '../services/utilService'; | ||
const urlConfig = require('../configs/urlConfig.json'); | ||
|
||
const PopupForm = ({ open, handleClose }) => { | ||
const [organization, setOrganization] = useState(''); | ||
const [bio, setBio] = useState(''); | ||
const [designation, setDesignation] = useState(''); | ||
const [userType, setUserType] = useState(''); | ||
const [designations, setDesignations] = useState([]); | ||
const [userTypes, setUserTypes] = useState([]); | ||
const [customDesignation, setCustomDesignation] = useState(''); | ||
const [customUserType, setCustomUserType] = useState(''); | ||
const _userId = util.userId(); | ||
|
||
useEffect(() => { | ||
setDesignations([ | ||
...userData.designations.map((type) => ({ value: type, label: type })), | ||
{ value: 'other', label: 'Other' } | ||
]); | ||
setUserTypes([ | ||
...userData.userTypes.map((type) => ({ value: type, label: type })), | ||
{ value: 'other', label: 'Other' } | ||
]); | ||
}, []); | ||
|
||
const isSubmitDisabled = !organization || !designation || !userType || (designation === 'other' && !customDesignation) || (userType === 'other' && !customUserType); | ||
|
||
const handleSubmit = async () => { | ||
const finalDesignation = designation === 'other' ? customDesignation : designation; | ||
const finalUserType = userType === 'other' ? customUserType : userType; | ||
|
||
const requestData = { | ||
organisation: organization, | ||
designation: finalDesignation, | ||
user_type: finalUserType, | ||
bio: bio | ||
}; | ||
|
||
try { | ||
const url = `${urlConfig.URLS.POFILE_PAGE.USER_UPDATE}?user_id=${_userId}`; | ||
const response = await axios.put(url, requestData); | ||
console.log('API Response:', response.data); | ||
} catch (error) { | ||
console.error('API Error:', error); | ||
} | ||
|
||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open}> | ||
<DialogTitle>User Information</DialogTitle> | ||
<DialogContent> | ||
<TextField | ||
autoFocus | ||
margin="dense" | ||
label={<span>Organization <span style={{ color: 'red' }}>*</span></span>} | ||
type="text" | ||
fullWidth | ||
value={organization} | ||
onChange={(e) => setOrganization(e.target.value)} | ||
/> | ||
<TextField | ||
margin="dense" | ||
label="Bio" | ||
type="text" | ||
fullWidth | ||
value={bio} | ||
onChange={(e) => setBio(e.target.value)} | ||
/> | ||
<FormControl fullWidth margin="dense"> | ||
<Select | ||
options={designations} | ||
value={designations.find((option) => option.value === designation)} | ||
onChange={(selectedOption) => setDesignation(selectedOption.value)} | ||
placeholder="Select Designation" | ||
isClearable | ||
/> | ||
{designation === 'other' && ( | ||
<TextField | ||
margin="dense" | ||
label="Enter Custom Designation" | ||
type="text" | ||
fullWidth | ||
value={customDesignation} | ||
onChange={(e) => setCustomDesignation(e.target.value)} | ||
/> | ||
)} | ||
</FormControl> | ||
<FormControl fullWidth margin="dense"> | ||
<Select | ||
options={userTypes} | ||
value={userTypes.find((option) => option.value === userType)} | ||
onChange={(selectedOption) => setUserType(selectedOption.value)} | ||
placeholder="Select User Type" | ||
isClearable | ||
/> | ||
{userType === 'other' && ( | ||
<TextField | ||
margin="dense" | ||
label="Enter Custom User Type" | ||
type="text" | ||
fullWidth | ||
value={customUserType} | ||
onChange={(e) => setCustomUserType(e.target.value)} | ||
/> | ||
)} | ||
</FormControl> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={handleSubmit} | ||
color="primary" | ||
disabled={isSubmitDisabled} | ||
> | ||
Submit | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default PopupForm; |
Oops, something went wrong.