Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#161: Skeleton Implementation #227

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ dist
buildcoverage
package-lock.json
.DS_Store
build/
build/
yarn.lock
30 changes: 18 additions & 12 deletions src/hooks/useDashboardData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ export const useDashboardData = () => {
const [coordinatorCount, setCoordinatorCount] = useState(0);
const [programCount, setProgramCount] = useState(0);
const [averagePerformance, setAveragePerformance] = useState(0);
const [performanceData, setPerformanceData] = useState<PerformanceMetric[]>([]);
const [performanceData, setPerformanceData] = useState<PerformanceMetric[]>(
[]
);
const [currentDate, setCurrentDate] = useState<string>("");
const [loading, setLoading] = useState<boolean>(true);
const dispatch = useDispatch();
useEffect(() => {
const fetchData = async () => {
Expand All @@ -31,17 +34,17 @@ export const useDashboardData = () => {
setCoordinatorCount(coordinators);
setProgramCount(programs);

const performanceMetric: PerformanceMetric[] = [{name: "0",performance: trainees / coordinators,},
{name: "1",performance: trainees / programs,},
{name: "2",performance: cohorts / programs,},
{name: "3",performance: programs / coordinators,},
{name: "4",performance: trainees / cohorts,},
{name: "5",performance: coordinators / cohorts,
},
{name: "6",performance: programs / trainees,},
{name: "7",performance: coordinators / programs,},
{name: "8",performance: programs / cohorts,},
{name: "9 Sprint",performance: coordinators / trainees,},
const performanceMetric: PerformanceMetric[] = [
{ name: "0", performance: trainees / coordinators },
{ name: "1", performance: trainees / programs },
{ name: "2", performance: cohorts / programs },
{ name: "3", performance: programs / coordinators },
{ name: "4", performance: trainees / cohorts },
{ name: "5", performance: coordinators / cohorts },
{ name: "6", performance: programs / trainees },
{ name: "7", performance: coordinators / programs },
{ name: "8", performance: programs / cohorts },
{ name: "9 Sprint", performance: coordinators / trainees },
];
setPerformanceData(performanceMetric);
const totalPerformance = performanceMetric.reduce(
Expand All @@ -50,6 +53,8 @@ export const useDashboardData = () => {
);
setAveragePerformance(totalPerformance / performanceMetric.length);
} catch (error) {
} finally {
setLoading(false);
}
};
const formatDate = () => {
Expand All @@ -72,5 +77,6 @@ export const useDashboardData = () => {
performanceData,
averagePerformance,
currentDate,
loading,
};
};
16 changes: 10 additions & 6 deletions src/pages/ApplicationCycle/ApplicationCycle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ import * as BsIcons from "react-icons/bs";
import * as AiIcons from "react-icons/ai";
import * as IoIcons from "react-icons/io5";
import NavBar from "../../components/sidebar/navHeader";
import { CycleSkeleton } from '../../skeletons/cycleSkeleton'

const ApplicationCycle = (props: any) => {
const { allCycles, errors } = props;

const [loading, setLoading] = useState(true);
const cycles = allCycles.data;

useEffect(() => {
props.getAllCycles();
}, []);
if (allCycles.data) {
setLoading(false);
}
}, [allCycles.data]);

const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
Expand Down Expand Up @@ -94,10 +98,6 @@ const ApplicationCycle = (props: any) => {

props.createCycle(data);
setOpenCreateModal(false);

// setTimeout(() => {
// window.location.reload();
// }, 3000);
};

const updateCycle = (e: any) => {
Expand Down Expand Up @@ -202,6 +202,9 @@ const ApplicationCycle = (props: any) => {
</button>
<div>
<div className=" w-[100%] dark:bg-dark-bg max-h-[70vh] m-auto bg-[#fff] shadow-md rounded-[10px] relative pb-[20px] overflow-x-auto overflow-y-scroll md:w-[100%]">
{loading || Object.keys(cycles).length === 0 ? (
<CycleSkeleton />
) : (
<table
{...getTableProps()}
className="border-collapse w-[100%] m-auto rounded-[15px] whitespace-nowrap "
Expand Down Expand Up @@ -251,6 +254,7 @@ const ApplicationCycle = (props: any) => {
})}
</tbody>
</table>
)}
</div>{" "}
</div>

Expand Down
Loading
Loading