Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishimwe7 committed Oct 8, 2024
2 parents cae0273 + 1fd351f commit ae48f11
Show file tree
Hide file tree
Showing 18 changed files with 544 additions and 456 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ package-lock.json
yarn.lock
.DS_Store
build/
yarn.lock
yarn.lock
10 changes: 0 additions & 10 deletions src/components/sidebar/sidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ export const sidebarItems1 = [
icon: <Icon icon="akar-icons:globe"></Icon>,
title: "Applications",
},
{
path: "Trainee-applicants",
icon: <Icon icon="ic:round-people"></Icon>,
title: "Trainees-Applicants",
},
{
path: "cohort",
icon: <Icon icon="fa6-solid:graduation-cap"></Icon>,
Expand All @@ -49,11 +44,6 @@ export const sidebarItems1 = [
icon: <Icon icon="game-icons:cycle"></Icon>,
title: "Application Cycles",
},
{
path: 'Trainee-applicants',
icon: <Icon icon="ic:round-people"></Icon>,
title: 'Trainees/Applicants',
},

{
path: "grading",
Expand Down
64 changes: 40 additions & 24 deletions src/pages/Applications.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useEffect, useState } from 'react';
import { ToastContainer } from 'react-toastify';
import * as icons from 'react-icons/ai';
import { Link } from 'react-router-dom';
import Select from 'react-select';
import * as AiIcons from 'react-icons/ai';
import React, { useEffect, useState } from "react";
import { ToastContainer } from "react-toastify";
import * as icons from "react-icons/ai";
import { Link, useNavigate } from "react-router-dom";
import Select from "react-select";
import * as AiIcons from "react-icons/ai";
import {
deleteApplication,
getMyApplications,
Expand All @@ -24,17 +24,20 @@ interface Update {
}
const Applications = (props: any) => {
const dispatch = useAppDispatch();
const { myApplications, currentApplication } = props;
const navigate = useNavigate();

const [moredrop, setmoredrop] = useState('');
const [filter, setFilter] = useState('submitted');
const { myApplications, currentApplication, loading } = props;
console.log("My Applications:", myApplications);

const [moredrop, setmoredrop] = useState("");
const [filter, setFilter] = useState("submitted");
const [pagination, setPagination] = useState({
pageSize: 5,
page: 1,
});

const [deleteWarn, setDeleteWarn] = useState<Update>({
id: '',
id: "",
open: false,
});

Expand All @@ -50,7 +53,7 @@ const Applications = (props: any) => {
};
const handleMoreOptions = (item_id: any) => {
if (!moredrop) setmoredrop(item_id);
if (moredrop) setmoredrop('');
if (moredrop) setmoredrop("");
};

const handleDeleteApplication = (item_id: any) => {
Expand All @@ -61,11 +64,20 @@ const Applications = (props: any) => {
}
};
const handleDateOfSubmission = (dateString: any) => {
const datePart = dateString.slice(0, dateString.indexOf('T'));
const datePart = dateString.slice(0, dateString.indexOf("T"));
return datePart;
};
useEffect(() => {
dispatch(getMyApplications(filter, pagination));
const result = dispatch(getMyApplications(filter, pagination));

if (
result.error === "Oops! You must be logged in to proceed" ||
result.error === "Session expired. Please login again to continue."
) {
setTimeout(() => {
navigate("/login");
}, 5000);
}
}, [filter, pagination, dispatch]);

const isLoading = myApplications.loading;
Expand All @@ -84,8 +96,11 @@ const Applications = (props: any) => {
<div className="bg-light-bg dark:bg-dark-frame-bg min-h-screen overflow-y-hidden overflow-x-hidden">
<div className="flex items-left px-8 pt-1">
<Link to="/filter_trainee-applicants">
<button className="flex bg-primary dark:bg-[#56C870] rounded-md py-2 mt-2 px-4 text-white font-medium cursor-pointer" disabled>
<icons.AiOutlineSearch className="mt-1 mr-1 font-bold" />{' '}
<button
className="flex bg-primary dark:bg-[#56C870] rounded-md py-2 mt-2 px-4 text-white font-medium cursor-pointer"
disabled
>
<icons.AiOutlineSearch className="mt-1 mr-1 font-bold" />{" "}
Search
</button>
</Link>
Expand All @@ -95,21 +110,21 @@ const Applications = (props: any) => {
<ul className=" flex dark:text-white semi-md:space-x-5 p-5 text-sm lg:px-8 semi-md:flex-row sm:flex-col ">
<li
className={`${
filter === 'submitted'
? 'underline underline-offset-8 decoration-green'
: ''
filter === "submitted"
? "underline underline-offset-8 decoration-green"
: ""
} cursor-pointer`}
onClick={() => setFilter('submitted')}
onClick={() => setFilter("submitted")}
>
Submitted
</li>
<li
className={`${
filter === 'withdrawn'
? 'underline underline-offset-8 decoration-green'
: ''
filter === "withdrawn"
? "underline underline-offset-8 decoration-green"
: ""
} cursor-pointer`}
onClick={() => setFilter('withdrawn')}
onClick={() => setFilter("withdrawn")}
>
Withdrawn
</li>
Expand Down Expand Up @@ -406,7 +421,7 @@ const Applications = (props: any) => {
?.dateOfSubmission !== undefined
? handleDateOfSubmission(
currentApplication.data
?.dateOfSubmission,
?.dateOfSubmission
)
: null}
</p>
Expand Down Expand Up @@ -548,6 +563,7 @@ const Applications = (props: any) => {
const mapState = (state: any) => ({
myApplications: state.myApplications,
currentApplication: state.currentApplication,
loading: state.myApplications.loading,
});

export default connect(mapState, {
Expand Down
47 changes: 27 additions & 20 deletions src/pages/Applications/AdminViewApplications.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
import React, { useState, useEffect } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import NavBar from '../../components/sidebar/navHeader';
import { fetchApplications } from '../../redux/actions/adminListApplications';
import { Pagination } from 'flowbite-react';
import { ApplicationsSkeleton } from '../../skeletons/applicationsSkeleton';
import ApplicationsTable from './ApplicationsTable';
const ListApplications = () => {
const [applications, setApplications] = useState([]);
const navigate = useNavigate();

const [activePage, setActivePage] = useState(1);
const [itemsCountPerPage, setItemsCountPerPage] = useState(10);
const [loading, setLoading] = useState(false);
const [isDrop, setDrop] = useState("");
useEffect(() => {
const fetchData = async () => {
setLoading(true);
try {
const data = await fetchApplications();
if (data?.applications) {
const slicedData = data.applications.slice(
(activePage - 1) * itemsCountPerPage,
activePage * itemsCountPerPage
);
setApplications(slicedData);
} else {
setApplications([]);
}
} catch (error) {
console.error('Error fetching applications', error);
const fetchData = async () => {
setLoading(true);
try {
const { data, error } = await fetchApplications();

if (error) {
setApplications([]);
} finally {
setLoading(false);
} else if (data?.applications) {
const slicedData = data.applications.slice(
(activePage - 1) * itemsCountPerPage,
activePage * itemsCountPerPage
);
setApplications(slicedData);
}
};
fetchData();
}, [activePage, itemsCountPerPage]);
} catch (error) {
console.error('Error fetching applications', error);
setApplications([]);
} finally {
setLoading(false);
}
};

fetchData();
}, [activePage, itemsCountPerPage]);

const handlePageChange = (pageNumber) => setActivePage(pageNumber);
const handleItemsCountPerPageChange = (event) => {
setItemsCountPerPage(Number(event.target.value));
Expand Down
55 changes: 55 additions & 0 deletions src/pages/JobPost/jobTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
export interface Program {
_id: string;
title: string;
}

export interface Cycle {
id: string;
name: string;
}

export interface Cohort {
id: string;
title: string;
}

export interface JobPost {
_id: string;
title: string;
program: Program;
cycle: Cycle;
cohort: Cohort;
description: string;
published: boolean;
}

export interface FormData {
title: string;
program: string; // Stores program title
cycle: string; // Stores cycle name
cohort: string; // Stores cohort title
description: string;
published: boolean;
}

export interface RootState {
fetchSingleJobPost: {
data: JobPost | null;
loading: boolean;
serverResponded: boolean;
};
updateProgram: {
loading: boolean;
error: string | null;
};
programs: {
data: Program[];
};
cycles: {
data: Cycle[];
};
cohorts: {
data: Cohort[];
};
}

Loading

0 comments on commit ae48f11

Please sign in to comment.