Skip to content

Commit

Permalink
fix(#156): Have a user be able to apply in different cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
robsdagreat committed Oct 17, 2024
2 parents dfe840e + 710bf6f commit a412228
Show file tree
Hide file tree
Showing 35 changed files with 964 additions and 128 deletions.
Binary file modified .DS_Store
Binary file not shown.
38 changes: 19 additions & 19 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ checks:
file-lines:
enabled: true
config:
threshold: 25000
threshold: 250
method-complexity:
enabled: true
config:
threshold: 50
threshold: 5
method-count:
enabled: true
config:
threshold: 20
method-lines:
enabled: true
config:
threshold: 900
threshold: 90
nested-control-flow:
enabled: true
config:
Expand All @@ -41,20 +41,20 @@ checks:
config:
threshold: #language-specific defaults. overrides affect all languages.
plugins:
rubocop:
enabled: true
eslint:
enabled: false
channel: eslint-8
rubocop:
enabled: true
eslint:
enabled: false
channel: eslint-8
exclude_patterns:
- "config/"
- "db/"
- "dist/"
- "features/"
- "**/node_modules/"
- "script/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- "**/vendor/"
- "**/*.d.ts"
- "config/"
- "db/"
- "dist/"
- "features/"
- "**/node_modules/"
- "script/"
- "**/spec/"
- "**/test/"
- "**/tests/"
- "**/vendor/"
- "**/*.d.ts"
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@ coverage
dist
buildcoverage
package-lock.json
yarn.lock
.DS_Store
build/
yarn.lock
build/
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@babel/preset-env": "^7.19.3",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@expo/webpack-config": "^0.17.2",
"@expo/webpack-config": "^19.0.1",
"@iconify/react": "^4.0.0",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -53,7 +53,7 @@
"html-webpack-plugin": "^5.6.0",
"i": "^0.3.7",
"node-polyfill-webpack-plugin": "^2.0.1",
"npm": "^8.19.2",
"npm": "^10.8.3",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
"process": "^0.11.10",
Expand Down Expand Up @@ -83,7 +83,7 @@
"@mui/x-date-pickers": "^5.0.6",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@tinymce/tinymce-react": "^4.2.0",
"@tinymce/tinymce-react": "^5.1.1",
"@types/react-i18next": "^8.1.0",
"@types/react-router": "^5.1.19",
"@types/react-router-dom": "^5.3.3",
Expand Down Expand Up @@ -120,14 +120,14 @@
"react-hot-toast": "^2.4.1",
"react-i18next": "^11.18.6",
"react-icons": "^4.6.0",
"react-js-pagination": "^3.0.3",
"react-js-pagination": "^3.0.2",
"react-loader-spinner": "^6.1.6",
"react-modal": "^3.16.1",
"react-paginate": "^8.1.3",
"react-redux": "^8.0.4",
"react-render-html": "^0.6.0",
"react-router-dom": "^6.4.2",
"react-scripts": "^5.0.1",
"react-scripts": "^3.0.1",
"react-select": "^5.7.4",
"react-table": "^7.8.0",
"react-toastify": "^9.0.8",
Expand Down
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
</head>
<body>
<div id="root"></div>

</body>
</html>
9 changes: 9 additions & 0 deletions src/assets/assets/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/assets/collaborative-learning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/assets/performance.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/assets/strategy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/components/form/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ const LoginForm = () => {
const response = await loginAction(validatedData.email, validatedData.password);

const token = response?.data?.data?.login?.token;
const userId = response?.data?.data?.login?.userId;

if (token) {
localStorage.setItem("access_token", token);
if (userId) {
localStorage.setItem("userId", userId);
}
await redirectAfterLogin();
} else {
toast.error(response?.data?.errors[0].message);
Expand Down
19 changes: 15 additions & 4 deletions src/components/form/TraineeApply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { AppDispatch, RootState } from '../../redux/store';
import useFormValidation from '../useFormValidation';
import { useTheme } from '../../hooks/darkmode';
import { loggedUserAction } from '../../redux/actions/getLoggedUser';
import { toast } from "react-toastify";
interface FormData {
firstName: string;
lastName: string;
Expand Down Expand Up @@ -121,10 +122,21 @@ const TraineeApplicationForm: React.FC = () => {
try {
const newTraineeId = await dispatch(createTrainee(formData));
console.log('Trainee created successfully');
navigate(`trainee-success/${newTraineeId}`, { replace: true });
} catch (error) {
navigate(`myApplications/trainee-success/${newTraineeId}`, { replace: true });
} catch (error:any) {
console.error('Error submitting form:', error);
setSubmitError('An error occurred while submitting the form. Please try again.');
console.log('Full error object:', JSON.stringify(error, null, 2));
console.log('Error response:', error.response);
console.log('Error message:', error.message);

let errorMessage = "An error occurred while creating the trainee.";
if (error.response?.data?.errors?.[0]?.message) {
errorMessage = error.response.data.errors[0].message;
} else if (error.message) {
errorMessage = error.message;
}

setSubmitError(errorMessage);
} finally {
setIsSubmitting(false);
}
Expand Down Expand Up @@ -177,7 +189,6 @@ const TraineeApplicationForm: React.FC = () => {
disabled={isSubmitting}
/>
</form>
{submitError && <p className="text-red-500 mt-2">{submitError}</p>}
</div>
</div>
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/form/TraineeAttributeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { createTraineeAttribute } from '../../redux/actions/traineeAttributes';
import TraineeFormPage1 from '../../components/TraineeFormPage1';
import TraineeFormPage2 from '../../components/TraineeFormPage2';
import { useTheme } from '../../hooks/darkmode';
import { useNavigate } from 'react-router-dom'

const TraineeAttributeForm = ({ traineeId }) => {
const dispatch = useDispatch();
const [page, setPage] = useState(1);
const { theme } = useTheme();
const isDarkMode = theme === false;
const navigate = useNavigate();

const [formData, setFormData] = useState({
gender: '',
Expand Down Expand Up @@ -70,6 +72,7 @@ const TraineeAttributeForm = ({ traineeId }) => {
};
console.log('Attribute data being sent:', attributeData);
dispatch(createTraineeAttribute(attributeData));
navigate('/applicant')
};

return (
Expand Down
11 changes: 10 additions & 1 deletion src/components/sidebar/sidebarItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ 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 @@ -44,7 +49,6 @@ export const sidebarItems1 = [
icon: <Icon icon="game-icons:cycle"></Icon>,
title: "Application Cycles",
},

{
path: "grading",
icon: <Icon icon="bxs:dashboard"></Icon>,
Expand All @@ -58,6 +62,11 @@ export const sidebarItems1 = [
];

export const applicantSidebarItems = [
{
path: "/applicant",
icon: <Icon icon="fontisto:pie-chart-1"></Icon>,
title: "Dashboard",
},
{
path: "myApplications",
icon: <Icon icon="material-symbols:wysiwyg-rounded"></Icon>,
Expand Down
Loading

0 comments on commit a412228

Please sign in to comment.