Commit e4e43f47 authored by Venkaiah Naidu Singamchetty's avatar Venkaiah Naidu Singamchetty

Merge branch 'initailSetup' into 'master'

revert aid from create activity

See merge request !98
parents e6ca5e9d 36bd54aa
...@@ -157,7 +157,7 @@ app.post('/createActivity',async (req, res) => { ...@@ -157,7 +157,7 @@ app.post('/createActivity',async (req, res) => {
let { data } = req.body; let { data } = req.body;
//data validation //data validation
if (!_.get(data, "aName", "") || !_.get(data, "aId", "") || !_.get(data, "type", "") || !_.get(data, "score", "") || !_.get(data,"comments","") ||!_.get(data,"ratedBy","") ) { if (!_.get(data, "aName", "") || !_.get(data, "type", "") || !_.get(data, "score", "") || !_.get(data,"comments","") ||!_.get(data,"ratedBy","") ) {
res.status(401).json({ "error": "Invalid Activity data" }); res.status(401).json({ "error": "Invalid Activity data" });
return; return;
} }
......
...@@ -10,7 +10,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -10,7 +10,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
const { user } = useSelector((state) => state.userDetails) const { user } = useSelector((state) => state.userDetails)
const [activitiesList, setActivitiesList] = useState([]) const [activitiesList, setActivitiesList] = useState([])
const [enableSubmit, setEnableSubmit] = useState(false) const [enableSubmit, setEnableSubmit] = useState(false)
const [activityData, setActivityData] = useState({ aName: "", ratedBy: "", aId: "", type: type, score: 0, comments: "" }) const [activityData, setActivityData] = useState({ aName: "", ratedBy: "", type: type, score: 0, comments: "" })
const [activityType, setActivtyType] = useState("") const [activityType, setActivtyType] = useState("")
const [showCustActivity, setShowActivity] = useState(false); const [showCustActivity, setShowActivity] = useState(false);
const [modalLoading, setModalLoading] = useState(true) const [modalLoading, setModalLoading] = useState(true)
...@@ -27,18 +27,17 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -27,18 +27,17 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
const handleActivityName = (e) => { const handleActivityName = (e) => {
if (e.target.value === "custom") { if (e.target.value === "custom") {
setActivityData({ ...activityData, aName: "", aId: "" }) setActivityData({ ...activityData, aName: "" })
setShowActivity(true) setShowActivity(true)
} }
else { else {
setShowActivity(false) setShowActivity(false)
setActivityData({ ...activityData, aName: e.target.value, aId: e.target.options[e.target.selectedIndex].id }) setActivityData({ ...activityData, aName: e.target.value })
} }
} }
const handleCustumActivity = (e) => { const handleCustumActivity = (e) => {
const randomId = uuidv4(); setActivityData({ ...activityData, aName: e.target.value })
setActivityData({ ...activityData, aName: e.target.value, aId: randomId })
} }
...@@ -75,7 +74,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -75,7 +74,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
useEffect(() => { useEffect(() => {
if (activityData.aName !== "" && activityData.aId !== "" && activityData.comments !== "" && activityData.score != (0 || -0)) { if (activityData.aName !== "" && activityData.comments !== "" && activityData.score != (0 || -0)) {
setEnableSubmit(true); setEnableSubmit(true);
} else { } else {
setEnableSubmit(false); setEnableSubmit(false);
...@@ -94,7 +93,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -94,7 +93,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
} }
SentenceCase(type) SentenceCase(type)
if (visible === false) { if (visible === false) {
setActivityData({ aName: "", ratedBy: "", aId: "", type: type, score: 0, comments: "" }) setActivityData({ aName: "", ratedBy: "", type: type, score: 0, comments: "" })
} else { } else {
setActivityData({ ...activityData, ratedBy: user.empName }) setActivityData({ ...activityData, ratedBy: user.empName })
getActivitysList(type); getActivitysList(type);
...@@ -105,7 +104,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -105,7 +104,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
const handleCustBtn = (e) => { const handleCustBtn = (e) => {
e.preventDefault(); e.preventDefault();
setShowActivity(!showCustActivity); setShowActivity(!showCustActivity);
setActivityData({ ...activityData, aName: "", aId: "" }) setActivityData({ ...activityData, aName: "" })
} }
...@@ -126,7 +125,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) { ...@@ -126,7 +125,7 @@ export default function MyModal({ visible, onClose, type, handleAddActivity }) {
<select className="bg-gray-50 ml-2 w-6/12 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 " onChange={(e) => handleActivityName(e)} > <select className="bg-gray-50 ml-2 w-6/12 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 " onChange={(e) => handleActivityName(e)} >
<option id="" value="">Select</option> <option id="" value="">Select</option>
{ {
activitiesList && activitiesList.map((activity) => <option className=" w-7/12" key={activity.aId} id={activity.aId} value={activity.aName}>{activity.aName}</option>) activitiesList && activitiesList.map((activity) => <option className=" w-7/12" value={activity.aName}>{activity.aName}</option>)
} }
<option value="custom" className={`${showCustActivity || type == "duties" && 'hidden'}`}>Add Activity</option> <option value="custom" className={`${showCustActivity || type == "duties" && 'hidden'}`}>Add Activity</option>
</select> </select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment