added back button,master-header

This commit is contained in:
Pramod Mahajan 2025-04-02 13:42:17 +05:30
parent fba9a8fc06
commit 79a1a08620
9 changed files with 27 additions and 29 deletions

View File

@ -7,7 +7,7 @@ import { z } from "zod";
import useMaster from "../../hooks/masterHook/useMaster"; import useMaster from "../../hooks/masterHook/useMaster";
import { useDispatch } from "react-redux"; import { useDispatch } from "react-redux";
import { changeMaster } from "../../slices/localVariablesSlice"; import { changeMaster } from "../../slices/localVariablesSlice";
import { useNavigate, useParams } from "react-router-dom"; import { Link, useNavigate, useParams } from "react-router-dom";
import { formatDate } from "../../utils/dateUtils"; import { formatDate } from "../../utils/dateUtils";
import { useEmployeeProfile } from "../../hooks/useEmployees"; import { useEmployeeProfile } from "../../hooks/useEmployees";
import { clearCacheKey, getCachedData } from "../../slices/apiDataManager"; import { clearCacheKey, getCachedData } from "../../slices/apiDataManager";
@ -17,6 +17,7 @@ const mobileNumberRegex = /^(?:\d{10}|\d{3}[-\s]?\d{3}[-\s]?\d{4})$/;
const ManageEmployee = () => { const ManageEmployee = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { employeeId } = useParams(); const { employeeId } = useParams();
const { const {
employee, employee,
@ -29,7 +30,7 @@ const ManageEmployee = () => {
const [isloading, setLoading] = useState(false); const [isloading, setLoading] = useState(false);
const navigation = useNavigate(); const navigation = useNavigate();
const [currentEmployee, setCurrentEmployee] = useState(); const [currentEmployee, setCurrentEmployee] = useState();
console.log(currentEmployee);
const userSchema = z const userSchema = z
.object({ .object({
@ -50,7 +51,9 @@ const ManageEmployee = () => {
EmergencyContactPerson: z EmergencyContactPerson: z
.string() .string()
.min(1, { message: "Emergency Contact Person is required" }), .min(1, { message: "Emergency Contact Person is required" }),
AadharNumber: z.string().optional(), AadharNumber: z.string()
.regex(/^\d{12}$/, "Aadhar card must be exactly 12 digits long") // Regex to ensure only 12 digits
.nonempty("Aadhar card is required"),
Gender: z Gender: z
.string() .string()
.min(1, { message: "Gender is required" }) .min(1, { message: "Gender is required" })
@ -223,8 +226,6 @@ const ManageEmployee = () => {
// if(currentEmployee && currentEmployee.email) setDisabledEmail(true) // if(currentEmployee && currentEmployee.email) setDisabledEmail(true)
}, [currentEmployee, reset]); }, [currentEmployee, reset]);
console.log(currentEmployee);
return ( return (
<> <>
<div className="row"> <div className="row">
@ -232,9 +233,14 @@ const ManageEmployee = () => {
<div className="card mb-4"> <div className="card mb-4">
<div className="card-header d-flex align-items-center justify-content-between"> <div className="card-header d-flex align-items-center justify-content-between">
<h6 className="mb-0"> <h6 className="mb-0">
{" "}
{employee ? "Update Employee" : "Create Employee"} {employee ? "Update Employee" : "Create Employee"}
</h6> </h6>
{/* <h6 className="cursor-pointer" onClick={() => navigation( "/employees" )}><i class='bx bx-arrow-back'></i>Back</h6> */}
<button className="btn btn-sm btn-secondary btn-prev" onClick={() => navigation( "/employees" )} >
<i className="icon-base bx bx-left-arrow-alt me-sm-2 me-0 scaleX-n1-rtl"></i>
<span className="align-middle d-sm-inline-block d-none">Back</span>
</button>
</div> </div>
<div className="card-body"> <div className="card-body">
{!currentEmployee && empLoading && ( {!currentEmployee && empLoading && (
@ -479,7 +485,7 @@ const ManageEmployee = () => {
Select Role Select Role
</option> </option>
{job_role?.map((item) => ( {job_role?.map((item) => (
<option value={item?.id}>{item?.name} </option> <option value={item?.id} key={item.id}>{item?.name} </option>
))} ))}
</select> </select>
</div> </div>
@ -562,10 +568,10 @@ const ManageEmployee = () => {
/> />
{/* {errors.PanNumber && <div className="danger-text text-start" style={{fontSize:"12px"}}>{errors.PanNumber.message}</div>} */} {/* {errors.PanNumber && <div className="danger-text text-start" style={{fontSize:"12px"}}>{errors.PanNumber.message}</div>} */}
</div> </div>
{(errors.PanNumber || errors.AadharNumber) && ( {(errors.AadharNumber || errors.PanNumber ) && (
<div className="danger-text text-start"> <div className="danger-text text-start">
{errors.PanNumber?.message || {errors.AadharNumber?.message ||errors.PanNumber?.message
errors.AadharNumber?.message} }
</div> </div>
)} )}
</div> </div>

View File

@ -27,7 +27,7 @@ const ManageProjectInfo = ( {project,handleSubmitForm, onClose} ) =>
...(project?.id ? { id: z.number().optional() } : {}), ...(project?.id ? { id: z.number().optional() } : {}),
name: z.string().min( 1, {message: "Project Name is required"} ), name: z.string().min( 1, {message: "Project Name is required"} ),
contactPerson: z.string().min( 1, {message: "Contact Person Name is required"} ), contactPerson: z.string().min( 1, {message: "Contact Person Name is required"} ),
projectAddress: z.string().min( 1, {message: "Address is required"} ), projectAddress: z.string().min( 1, {message: "Address is required"} ).max(150, 'Address must not exceed 150 characters'),
startDate: z.string().min( 1, {message: "Start Date is required"} ).default(currentDate), startDate: z.string().min( 1, {message: "Start Date is required"} ).default(currentDate),
endDate: z.string().min( 1, {message: "End Date is required"} ).default(currentDate), endDate: z.string().min( 1, {message: "End Date is required"} ).default(currentDate),
projectStatusId: z projectStatusId: z

View File

@ -134,12 +134,12 @@ const allocationEmployeesData = employeesList
</ul> </ul>
</div> </div>
<div className="modal-footer"> <div className="modal-footer">
<button className="btn btn-success" onClick={handleSubmit}> <button className="btn btn-sm btn-success" onClick={handleSubmit}>
Assign to Project Assign to Project
</button> </button>
<button <button
type="button" type="button"
className="btn btn-secondary" className="btn btn-sm btn-secondary"
data-dismiss="modal" data-dismiss="modal"
aria-label="Close" aria-label="Close"
onClick={onClose} onClick={onClose}

View File

@ -79,8 +79,8 @@ const Teams = ( {project} ) =>
}; };
}); });
console.log(item)
submitAllocations(items) // submitAllocations(items)
}; };
const getRole = ( jobRoleId ) => const getRole = ( jobRoleId ) =>

View File

@ -1,4 +1,4 @@
export const mastersList = [{id:1, name: "Role"},{id:2, name: "Job Role"}, {id:3, name: "Status"},{id:4,name:"Module"}] export const mastersList = [{id:1, name: "Role"},{id:2, name: "Job Role"}]
export const dailyTask = [ export const dailyTask = [
{ {

View File

@ -17,7 +17,6 @@ const AttendancePage = () =>
{ {
const loginUser = getCachedProfileData() const loginUser = getCachedProfileData()
var selectedProject = useSelector( ( store ) => store.localVariables.projectId ) var selectedProject = useSelector( ( store ) => store.localVariables.projectId )
selectedProject = 5;
const {projects,loading:projectLoading} = useProjects() const {projects,loading:projectLoading} = useProjects()
const {attendance,loading:attLoading} = useAttendace(selectedProject) const {attendance,loading:attLoading} = useAttendace(selectedProject)
const[attendances,setAttendances] = useState() const[attendances,setAttendances] = useState()

View File

@ -13,7 +13,6 @@ import {useHasUserPermission} from "../../hooks/useHasUserPermission";
const EmployeeList = () => const EmployeeList = () =>
{ {
const {profile:loginUser}= useProfile() const {profile:loginUser}= useProfile()
const [selectedProject, setSelectedProject] = useState(""); const [selectedProject, setSelectedProject] = useState("");
const {projects, loading: projectLoading} = useProjects() const {projects, loading: projectLoading} = useProjects()
@ -100,8 +99,6 @@ const EmployeeList = () =>
}, [ modelConfig, isCreateModalOpen ] ); }, [ modelConfig, isCreateModalOpen ] );
console.log("employeManage : ", ManageEmployee)
return ( return (
<> <>
{isCreateModalOpen && ( {isCreateModalOpen && (
@ -297,7 +294,6 @@ const EmployeeList = () =>
aria-controls="DataTables_Table_0" aria-controls="DataTables_Table_0"
rowSpan="1" rowSpan="1"
colSpan="1" colSpan="1"
// style={{ width: "107px" }}
aria-label="Plan: activate to sort column ascending" aria-label="Plan: activate to sort column ascending"
> >
Joining Date Joining Date
@ -312,9 +308,8 @@ const EmployeeList = () =>
> >
Status Status
</th> </th>
<th <th
className={`sorting_disabled d-none ${!ManageEmployee && 'd-none'}`} className={`sorting_disabled ${!ManageEmployee && 'd-none'}`}
rowSpan="1" rowSpan="1"
colSpan="1" colSpan="1"
style={{ width: "50px" }} style={{ width: "50px" }}
@ -333,7 +328,6 @@ const EmployeeList = () =>
{( !loading && employeeList?.length === 0 ) && <td colSpan={8}>Not Data Found </td>} {( !loading && employeeList?.length === 0 ) && <td colSpan={8}>Not Data Found </td>}
{( !loading && employeeList && currentItems.length === 0 && employeeList.length !==0 ) && <td colSpan={8}><small className="muted">'{searchText}' employee not found</small> </td>} {( !loading && employeeList && currentItems.length === 0 && employeeList.length !==0 ) && <td colSpan={8}><small className="muted">'{searchText}' employee not found</small> </td>}
{(currentItems && !loading) && currentItems.map((item) => ( {(currentItems && !loading) && currentItems.map((item) => (
<tr className="odd" key={item.id}> <tr className="odd" key={item.id}>
<td className="sorting_1" colSpan={2}> <td className="sorting_1" colSpan={2}>
@ -399,7 +393,6 @@ const EmployeeList = () =>
<Link <Link
className={`dropdown-item `} className={`dropdown-item `}
// ${hasUserPermission("81ab8a87-8ccd-4015-a917-0627cee6a100")?"":"d-none"}
to={`/employee/manage/${item.id}`} to={`/employee/manage/${item.id}`}
> >
Edit Edit

View File

@ -46,8 +46,8 @@ const MasterTable = ( {data, columns, loading, handleModalData} ) =>
<tr> <tr>
<th></th> <th></th>
<th>Name</th> <th>{ selectedMaster} Name</th>
<th>Description</th> <th>{selectedMaster } Description</th>
<th className={` ${!hasMasterPermission && 'd-none'}`}>Actions</th> <th className={` ${!hasMasterPermission && 'd-none'}`}>Actions</th>
</tr> </tr>
</thead> </thead>

View File

@ -5,7 +5,7 @@ const localVariablesSlice = createSlice({
initialState: { initialState: {
selectedMaster:"Role", selectedMaster:"Role",
regularizationCount:0, regularizationCount:0,
projectId:1, projectId:5,
}, },
reducers: { reducers: {