Merge pull request 'Checking all the popups and adding header on it.' (#120) from Kartik_Enhancement#308 into Issue_May_3W

Reviewed-on: #120
This commit is contained in:
Vikas Nale 2025-05-19 07:15:50 +00:00
commit 0587351cdb
7 changed files with 80 additions and 64 deletions

View File

@ -7,17 +7,17 @@ import { usePositionTracker } from "../../hooks/usePositionTracker";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { markAttendance } from "../../slices/apiSlice/attedanceLogsSlice"; import { markAttendance } from "../../slices/apiSlice/attedanceLogsSlice";
import showToast from "../../services/toastService"; import showToast from "../../services/toastService";
import {checkIfCurrentDate} from "../../utils/dateUtils"; import { checkIfCurrentDate } from "../../utils/dateUtils";
const schema = z.object({ const schema = z.object({
markTime: z.string().nonempty({message:"Time is required"}), markTime: z.string().nonempty({ message: "Time is required" }),
description:z.string().max(200,"description should less than 200 chracters").optional() description: z.string().max(200, "description should less than 200 chracters").optional()
}); });
const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => { const CheckCheckOutmodel = ({ modeldata, closeModal, handleSubmitForm, }) => {
const projectId = useSelector((store)=>store.localVariables.projectId) const projectId = useSelector((store) => store.localVariables.projectId)
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const coords = usePositionTracker(); const coords = usePositionTracker();
const dispatch = useDispatch() const dispatch = useDispatch()
@ -29,60 +29,60 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
reset, reset,
setValue, setValue,
} = useForm({ } = useForm({
resolver: zodResolver( schema ), resolver: zodResolver(schema),
mode:"onChange" mode: "onChange"
}); });
const onSubmit = ( data ) => const onSubmit = (data) => {
{ let record = { ...data, date: new Date().toLocaleDateString(), latitude: coords.latitude, longitude: coords.longitude, employeeId: modeldata.employeeId, action: modeldata.action, id: modeldata?.id || null }
let record = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude,employeeId:modeldata.employeeId,action:modeldata.action,id:modeldata?.id || null} if (modeldata.forWhichTab === 1) {
if(modeldata.forWhichTab === 1){ handleSubmitForm(record)
handleSubmitForm(record) } else {
} else
{
// if ( modeldata?.currentDate && checkIfCurrentDate( modeldata?.currentDate ) ) // if ( modeldata?.currentDate && checkIfCurrentDate( modeldata?.currentDate ) )
// { // {
dispatch(markAttendance(record)) dispatch(markAttendance(record))
.unwrap() .unwrap()
.then( ( data ) => .then((data) => {
{
showToast("Attendance Marked Successfully", "success");
})
.catch( ( error ) =>
{
showToast(error, "error" ); showToast("Attendance Marked Successfully", "success");
})
.catch((error) => {
showToast(error, "error");
});
// } else
// {
// let formData = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude,employeeId:modeldata.employeeId,projectId:projectId,action:modeldata.action,id:modeldata?.id || null}
// }
}
});
// } else
// {
// let formData = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude,employeeId:modeldata.employeeId,projectId:projectId,action:modeldata.action,id:modeldata?.id || null}
// }
}
closeModal() closeModal()
}; };
return ( return (
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<TimePicker <label className="fs-5 text-dark text-center d-flex align-items-center flex-wrap">
label="Choose a time" {modeldata?.checkInTime && !modeldata?.checkOutTime ? 'Check-out :' : 'Check-in :'}
onChange={(e) => setValue("markTime", e)} </label>
interval={10} </div>
checkOutTime={modeldata?.checkOutTime} <div className="col-12 col-md-12">
<TimePicker
label="Choose a time"
onChange={(e) => setValue("markTime", e)}
interval={10}
checkOutTime={modeldata?.checkOutTime}
checkInTime={modeldata?.checkInTime} checkInTime={modeldata?.checkInTime}
/> />
{errors. markTime && <p className="text-danger">{errors.markTime.message}</p>} {errors.markTime && <p className="text-danger">{errors.markTime.message}</p>}
</div> </div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label" htmlFor="description"> <label className="form-label" htmlFor="description">
Description Description
@ -91,7 +91,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
rows="3" rows="3"
name="description" name="description"
className="form-control" className="form-control"
{...register( "description" )} {...register("description")}
maxLength={200} maxLength={200}
/> />
{errors.description && ( {errors.description && (
@ -99,7 +99,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
)} )}
</div> </div>
<div className="col-12 text-center"> <div className="col-12 text-center">
<button type="submit" className="btn btn-sm btn-primary me-3"> <button type="submit" className="btn btn-sm btn-primary me-3">
{isLoading ? "Please Wait..." : "Submit"} {isLoading ? "Please Wait..." : "Submit"}
@ -109,7 +109,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
className="btn btn-sm btn-label-secondary" className="btn btn-sm btn-label-secondary"
data-bs-dismiss="modal" data-bs-dismiss="modal"
aria-label="Close" aria-label="Close"
onClick={()=>closeModal()} onClick={() => closeModal()}
> >
Cancel Cancel
</button> </button>
@ -124,15 +124,15 @@ export default CheckCheckOutmodel;
const schemaReg = z.object({ const schemaReg = z.object({
description:z.string().min(1,{message:"please give reason!"}) description: z.string().min(1, { message: "please give reason!" })
} ); });
export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{ export const Regularization = ({ modeldata, closeModal, handleSubmitForm }) => {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const coords = usePositionTracker(); const coords = usePositionTracker();
const { const {
register, register,
handleSubmit, handleSubmit,
@ -146,22 +146,21 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
return today.toLocaleDateString('en-CA'); return today.toLocaleDateString('en-CA');
}; };
const onSubmit = ( data ) =>
{
let record = {...data, date: new Date().toLocaleDateString(),latitude:coords.latitude,longitude:coords.longitude, } const onSubmit = (data) => {
let record = { ...data, date: new Date().toLocaleDateString(), latitude: coords.latitude, longitude: coords.longitude, }
handleSubmitForm(record) handleSubmitForm(record)
closeModal() closeModal()
}; };
return ( return (
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<p>Regularize Attendance</p> <p>Regularize Attendance</p>
<label className="form-label" htmlFor="description"> <label className="form-label" htmlFor="description">
Description Description
</label> </label>
@ -176,7 +175,7 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
)} )}
</div> </div>
<div className="col-12 text-center"> <div className="col-12 text-center">
<button type="submit" className="btn btn-sm btn-primary me-3"> <button type="submit" className="btn btn-sm btn-primary me-3">
{isLoading ? "Please Wait..." : "Submit"} {isLoading ? "Please Wait..." : "Submit"}
@ -186,7 +185,7 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
className="btn btn-sm btn-label-secondary" className="btn btn-sm btn-label-secondary"
data-bs-dismiss="modal" data-bs-dismiss="modal"
aria-label="Close" aria-label="Close"
onClick={()=>closeModal()} onClick={() => closeModal()}
> >
Cancel Cancel
</button> </button>

View File

@ -70,7 +70,9 @@ const CreateJobRole = ({onClose}) => {
const maxDescriptionLength = 255; const maxDescriptionLength = 255;
return (<> return (<>
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Create Job Role</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Role</label> <label className="form-label">Role</label>
<input type="text" <input type="text"

View File

@ -96,7 +96,10 @@ const CreateRole = ({ modalType, onClose }) => {
return ( return (
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Create Application Role</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Role</label> <label className="form-label">Role</label>
<input type="text" <input type="text"

View File

@ -70,6 +70,9 @@ const CreateWorkCategory = ({onClose}) => {
const maxDescriptionLength = 255; const maxDescriptionLength = 255;
return (<> return (<>
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Create Work Category</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Category Name</label> <label className="form-label">Category Name</label>

View File

@ -77,6 +77,9 @@ const EditJobRole = ({data,onClose}) => {
return (<> return (<>
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Edit Job Role</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Role</label> <label className="form-label">Role</label>
<input type="text" <input type="text"

View File

@ -146,7 +146,9 @@ const EditMaster = ({ master, onClose }) => {
return ( return (
<form className="row g-2 " onSubmit={handleSubmit(onSubmit)}> <form className="row g-2 " onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Edit Application Role</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Role</label> <label className="form-label">Role</label>
<input type="text" <input type="text"

View File

@ -77,6 +77,10 @@ const EditWorkCategory = ({data,onClose}) => {
return (<> return (<>
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}> <form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
<div className="col-12 col-md-12">
<label className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">Edit Work Category</label>
</div>
<div className="col-12 col-md-12"> <div className="col-12 col-md-12">
<label className="form-label">Category Name</label> <label className="form-label">Category Name</label>
<input type="text" <input type="text"