Checking all the popups and adding header on it.
This commit is contained in:
parent
d117c0d09b
commit
e659b9bb04
@ -7,17 +7,17 @@ import { usePositionTracker } from "../../hooks/usePositionTracker";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { markAttendance } from "../../slices/apiSlice/attedanceLogsSlice";
|
||||
import showToast from "../../services/toastService";
|
||||
import {checkIfCurrentDate} from "../../utils/dateUtils";
|
||||
import { checkIfCurrentDate } from "../../utils/dateUtils";
|
||||
|
||||
|
||||
const schema = z.object({
|
||||
markTime: z.string().nonempty({message:"Time is required"}),
|
||||
description:z.string().max(200,"description should less than 200 chracters").optional()
|
||||
markTime: z.string().nonempty({ message: "Time is required" }),
|
||||
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 coords = usePositionTracker();
|
||||
const dispatch = useDispatch()
|
||||
@ -29,60 +29,60 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||
reset,
|
||||
setValue,
|
||||
} = useForm({
|
||||
resolver: zodResolver( schema ),
|
||||
mode:"onChange"
|
||||
resolver: zodResolver(schema),
|
||||
mode: "onChange"
|
||||
});
|
||||
|
||||
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}
|
||||
if(modeldata.forWhichTab === 1){
|
||||
handleSubmitForm(record)
|
||||
} else
|
||||
{
|
||||
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 }
|
||||
if (modeldata.forWhichTab === 1) {
|
||||
handleSubmitForm(record)
|
||||
} else {
|
||||
|
||||
// if ( modeldata?.currentDate && checkIfCurrentDate( modeldata?.currentDate ) )
|
||||
// {
|
||||
dispatch(markAttendance(record))
|
||||
.unwrap()
|
||||
.then( ( data ) =>
|
||||
{
|
||||
|
||||
showToast("Attendance Marked Successfully", "success");
|
||||
})
|
||||
.catch( ( error ) =>
|
||||
{
|
||||
// if ( modeldata?.currentDate && checkIfCurrentDate( modeldata?.currentDate ) )
|
||||
// {
|
||||
dispatch(markAttendance(record))
|
||||
.unwrap()
|
||||
.then((data) => {
|
||||
|
||||
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()
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
|
||||
|
||||
|
||||
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
||||
|
||||
|
||||
<div className="col-12 col-md-12">
|
||||
<TimePicker
|
||||
label="Choose a time"
|
||||
onChange={(e) => setValue("markTime", e)}
|
||||
interval={10}
|
||||
checkOutTime={modeldata?.checkOutTime}
|
||||
<label className="fs-5 text-dark text-center d-flex align-items-center flex-wrap">
|
||||
{modeldata?.checkInTime && !modeldata?.checkOutTime ? 'Check-out :' : 'Check-in :'}
|
||||
</label>
|
||||
</div>
|
||||
<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}
|
||||
/>
|
||||
{errors. markTime && <p className="text-danger">{errors.markTime.message}</p>}
|
||||
/>
|
||||
{errors.markTime && <p className="text-danger">{errors.markTime.message}</p>}
|
||||
</div>
|
||||
|
||||
|
||||
<div className="col-12 col-md-12">
|
||||
<label className="form-label" htmlFor="description">
|
||||
Description
|
||||
@ -91,7 +91,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||
rows="3"
|
||||
name="description"
|
||||
className="form-control"
|
||||
{...register( "description" )}
|
||||
{...register("description")}
|
||||
maxLength={200}
|
||||
/>
|
||||
{errors.description && (
|
||||
@ -99,7 +99,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="col-12 text-center">
|
||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
||||
{isLoading ? "Please Wait..." : "Submit"}
|
||||
@ -109,7 +109,7 @@ const CheckCheckOutmodel = ({modeldata,closeModal,handleSubmitForm,}) => {
|
||||
className="btn btn-sm btn-label-secondary"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Close"
|
||||
onClick={()=>closeModal()}
|
||||
onClick={() => closeModal()}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
@ -124,15 +124,15 @@ export default CheckCheckOutmodel;
|
||||
|
||||
|
||||
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 coords = usePositionTracker();
|
||||
|
||||
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@ -146,22 +146,21 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
|
||||
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)
|
||||
closeModal()
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
|
||||
|
||||
|
||||
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
||||
|
||||
|
||||
<div className="col-12 col-md-12">
|
||||
<p>Regularize Attendance</p>
|
||||
<p>Regularize Attendance</p>
|
||||
<label className="form-label" htmlFor="description">
|
||||
Description
|
||||
</label>
|
||||
@ -176,7 +175,7 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="col-12 text-center">
|
||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
||||
{isLoading ? "Please Wait..." : "Submit"}
|
||||
@ -186,7 +185,7 @@ export const Regularization = ({modeldata,closeModal,handleSubmitForm})=>{
|
||||
className="btn btn-sm btn-label-secondary"
|
||||
data-bs-dismiss="modal"
|
||||
aria-label="Close"
|
||||
onClick={()=>closeModal()}
|
||||
onClick={() => closeModal()}
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
|
@ -70,7 +70,9 @@ const CreateJobRole = ({onClose}) => {
|
||||
const maxDescriptionLength = 255;
|
||||
return (<>
|
||||
<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">
|
||||
<label className="form-label">Role</label>
|
||||
<input type="text"
|
||||
|
@ -96,7 +96,10 @@ const CreateRole = ({ modalType, onClose }) => {
|
||||
return (
|
||||
|
||||
<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">
|
||||
<label className="form-label">Role</label>
|
||||
<input type="text"
|
||||
|
@ -70,6 +70,9 @@ const CreateWorkCategory = ({onClose}) => {
|
||||
const maxDescriptionLength = 255;
|
||||
return (<>
|
||||
<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">
|
||||
<label className="form-label">Category Name</label>
|
||||
|
@ -77,6 +77,9 @@ const EditJobRole = ({data,onClose}) => {
|
||||
|
||||
return (<>
|
||||
<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">
|
||||
<label className="form-label">Role</label>
|
||||
<input type="text"
|
||||
|
@ -146,7 +146,9 @@ const EditMaster = ({ master, onClose }) => {
|
||||
return (
|
||||
|
||||
<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">
|
||||
<label className="form-label">Role</label>
|
||||
<input type="text"
|
||||
|
@ -77,6 +77,10 @@ const EditWorkCategory = ({data,onClose}) => {
|
||||
|
||||
return (<>
|
||||
<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">
|
||||
<label className="form-label">Category Name</label>
|
||||
<input type="text"
|
||||
|
Loading…
x
Reference in New Issue
Block a user