Card changes to show days left for project
This commit is contained in:
parent
19abc42fc6
commit
29caa20250
6
package-lock.json
generated
6
package-lock.json
generated
@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.10.0",
|
"@hookform/resolvers": "^3.10.0",
|
||||||
"@reduxjs/toolkit": "^2.5.0",
|
"@reduxjs/toolkit": "^2.5.0",
|
||||||
|
"@types/web": "^0.0.216",
|
||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"axios-retry": "^4.5.0",
|
"axios-retry": "^4.5.0",
|
||||||
@ -1439,6 +1440,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
|
||||||
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
|
"integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/web": {
|
||||||
|
"version": "0.0.216",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/web/-/web-0.0.216.tgz",
|
||||||
|
"integrity": "sha512-HLaPWQKq1oh6aQv1JLRsiH0vW4VsO+L/zTOeOUmoGBnLVR2wCj4w4oWfa/0O5JFMqZXWC6VpipqQU6B1v2M/qg=="
|
||||||
|
},
|
||||||
"node_modules/@ungap/structured-clone": {
|
"node_modules/@ungap/structured-clone": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.1.tgz",
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"json-server": "json-server --watch ./src/data/demo.json --port 5000",
|
"json-server": "json-server --watch ./src/data/demo.json --port 5000",
|
||||||
@ -14,6 +13,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.10.0",
|
"@hookform/resolvers": "^3.10.0",
|
||||||
"@reduxjs/toolkit": "^2.5.0",
|
"@reduxjs/toolkit": "^2.5.0",
|
||||||
|
"@types/web": "^0.0.216",
|
||||||
"@vitejs/plugin-react": "^4.3.4",
|
"@vitejs/plugin-react": "^4.3.4",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"axios-retry": "^4.5.0",
|
"axios-retry": "^4.5.0",
|
||||||
|
@ -2,13 +2,13 @@ import React, { useState } from "react";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { getDateDifferenceInDays } from "../../utils/dateUtils";
|
import { getDateDifferenceInDays } from "../../utils/dateUtils";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import {useProjectDetails} from "../../hooks/useProjects";
|
import { useProjectDetails } from "../../hooks/useProjects";
|
||||||
import ManageProjectInfo from "./ManageProjectInfo";
|
import ManageProjectInfo from "./ManageProjectInfo";
|
||||||
import ProjectRepository from "../../repositories/ProjectRepository";
|
import ProjectRepository from "../../repositories/ProjectRepository";
|
||||||
import {cacheData, getCachedData} from "../../slices/apiDataManager";
|
import { cacheData, getCachedData } from "../../slices/apiDataManager";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import {MANAGE_PROJECT} from "../../utils/constants";
|
import { MANAGE_PROJECT } from "../../utils/constants";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -33,10 +33,10 @@ const ProjectCard = ({ projectData }) => {
|
|||||||
return (completed * 100) / planned + "%";
|
return (completed * 100) / planned + "%";
|
||||||
};
|
};
|
||||||
const getProgressInNumber = (planned, completed) => {
|
const getProgressInNumber = (planned, completed) => {
|
||||||
return (completed * 100) / planned ;
|
return (completed * 100) / planned;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => setShowModal( false );
|
const handleClose = () => setShowModal(false);
|
||||||
|
|
||||||
const getProjectStatusName = (statusId) => {
|
const getProjectStatusName = (statusId) => {
|
||||||
switch (statusId) {
|
switch (statusId) {
|
||||||
@ -225,25 +225,29 @@ const ProjectCard = ({ projectData }) => {
|
|||||||
{getProjectStatusName(projectInfo.projectStatusId)}
|
{getProjectStatusName(projectInfo.projectStatusId)}
|
||||||
</span>
|
</span>
|
||||||
</p>{" "}
|
</p>{" "}
|
||||||
<span className="badge bg-label-success ms-auto">
|
{getDateDifferenceInDays(projectInfo.endDate, Date()) >= 0 &&
|
||||||
{projectInfo.startDate &&
|
( <span className="badge bg-label-success ms-auto">
|
||||||
projectInfo.endDate &&
|
{projectInfo.endDate &&
|
||||||
getDateDifferenceInDays(
|
getDateDifferenceInDays(projectInfo.endDate, Date())}{" "}
|
||||||
projectInfo.startDate,
|
|
||||||
projectInfo.endDate
|
|
||||||
)}{" "}
|
|
||||||
Days left
|
Days left
|
||||||
</span>
|
</span>) }
|
||||||
|
{getDateDifferenceInDays(projectInfo.endDate, Date()) < 0 &&
|
||||||
|
( <span className="badge bg-label-danger ms-auto">
|
||||||
|
{projectInfo.endDate &&
|
||||||
|
getDateDifferenceInDays(projectInfo.endDate, Date())}{" "}
|
||||||
|
Days overdue
|
||||||
|
</span>)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex justify-content-between align-items-center mb-2">
|
<div className="d-flex justify-content-between align-items-center mb-2">
|
||||||
<small className="text-body">Task: {projectInfo.completedWork} / { projectInfo.plannedWork}</small>
|
<small className="text-body">Task: {projectInfo.completedWork} / {projectInfo.plannedWork}</small>
|
||||||
<small className="text-body">{Math.floor(getProgressInNumber(projectInfo.plannedWork,projectInfo.completedWork)) || 0} % Completed</small>
|
<small className="text-body">{Math.floor(getProgressInNumber(projectInfo.plannedWork, projectInfo.completedWork)) || 0} % Completed</small>
|
||||||
</div>
|
</div>
|
||||||
<div className="progress mb-4 rounded" style={{ height: "8px" }}>
|
<div className="progress mb-4 rounded" style={{ height: "8px" }}>
|
||||||
<div
|
<div
|
||||||
className="progress-bar rounded"
|
className="progress-bar rounded"
|
||||||
role="progressbar"
|
role="progressbar"
|
||||||
style={{ width: getProgress(projectInfo.plannedWork,projectInfo.completedWork) }}
|
style={{ width: getProgress(projectInfo.plannedWork, projectInfo.completedWork) }}
|
||||||
aria-valuenow={projectInfo.completedWork}
|
aria-valuenow={projectInfo.completedWork}
|
||||||
aria-valuemin="0"
|
aria-valuemin="0"
|
||||||
aria-valuemax={projectInfo.plannedWork}
|
aria-valuemax={projectInfo.plannedWork}
|
||||||
@ -255,9 +259,9 @@ const ProjectCard = ({ projectData }) => {
|
|||||||
<div >
|
<div >
|
||||||
<a
|
<a
|
||||||
|
|
||||||
className="text-muted d-flex "
|
className="text-muted d-flex " alt="Active team size"
|
||||||
>
|
>
|
||||||
<i className="bx bx-group bx-sm me-1_5"></i>{projectInfo?.teamSize}
|
<i className="bx bx-group bx-sm me-1_5"></i>{projectInfo?.teamSize} Members
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -265,7 +269,7 @@ const ProjectCard = ({ projectData }) => {
|
|||||||
<a
|
<a
|
||||||
className="text-muted d-flex align-items-center"
|
className="text-muted d-flex align-items-center"
|
||||||
>
|
>
|
||||||
<i className="bx bx-chat me-1"></i> 15
|
<i className="bx bx-chat me-1 "></i> <span className="text-decoration-line-through">15</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,56 +13,50 @@ export const getDateDifferenceInDays = (startDate, endDate) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the difference in milliseconds
|
// Calculate the difference in milliseconds
|
||||||
const differenceInMs = end - start;
|
const differenceInMs = start - end;
|
||||||
|
|
||||||
// Convert milliseconds to days
|
// Convert milliseconds to days
|
||||||
const differenceInDays = Math.floor(differenceInMs / (1000 * 60 * 60 * 24));
|
const differenceInDays = Math.floor(differenceInMs / (1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
return differenceInDays;
|
return differenceInDays;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const formatDate = (date) => {
|
export const formatDate = (date) => {
|
||||||
if (!date) return ''; // Return an empty string if no date
|
if (!date) return ""; // Return an empty string if no date
|
||||||
const dateObj = new Date(date);
|
const dateObj = new Date(date);
|
||||||
return dateObj.toISOString().split('T')[0]; // Get the date in YYYY-MM-DD format
|
return dateObj.toISOString().split("T")[0]; // Get the date in YYYY-MM-DD format
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const convertShortTime = (dateString) => {
|
||||||
export const convertShortTime=(dateString)=> {
|
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
|
|
||||||
let hours = date.getHours();
|
let hours = date.getHours();
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
const minutes = String(date.getMinutes()).padStart(2, "0");
|
||||||
|
|
||||||
const ampm = hours >= 12 ? 'PM' : 'AM';
|
const ampm = hours >= 12 ? "PM" : "AM";
|
||||||
hours = hours % 12; // Convert to 12-hour format
|
hours = hours % 12; // Convert to 12-hour format
|
||||||
hours = hours ? hours : 12; // If hours is 0, set it to 12
|
hours = hours ? hours : 12; // If hours is 0, set it to 12
|
||||||
|
|
||||||
return `${String(hours).padStart(2, '0')}:${minutes} ${ampm}`;
|
return `${String(hours).padStart(2, "0")}:${minutes} ${ampm}`;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const timeElapsed = (checkInTime, timeElapsedInHours) =>{
|
export const timeElapsed = (checkInTime, timeElapsedInHours) => {
|
||||||
const checkInDate = new Date(checkInTime);
|
const checkInDate = new Date(checkInTime);
|
||||||
|
|
||||||
const currentTime = new Date();
|
const currentTime = new Date();
|
||||||
|
|
||||||
const timeDifference = currentTime - checkInDate;
|
const timeDifference = currentTime - checkInDate;
|
||||||
|
|
||||||
|
|
||||||
const timeDifferenceInHours = timeDifference / (1000 * 60 * 60);
|
const timeDifferenceInHours = timeDifference / (1000 * 60 * 60);
|
||||||
|
|
||||||
return timeDifferenceInHours >= timeElapsedInHours;
|
return timeDifferenceInHours >= timeElapsedInHours;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export const checkIfCurrentDate = (dateString) => {
|
||||||
|
|
||||||
export const checkIfCurrentDate = (dateString) => {
|
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
const inputDate = new Date(dateString);
|
const inputDate = new Date(dateString);
|
||||||
|
|
||||||
|
|
||||||
currentDate.setHours(0, 0, 0, 0);
|
currentDate.setHours(0, 0, 0, 0);
|
||||||
inputDate.setHours(0, 0, 0, 0);
|
inputDate.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
return currentDate.getTime() === inputDate.getTime();
|
return currentDate.getTime() === inputDate.getTime();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user