Skip to content

Commit

Permalink
fix bug when loading user profile data
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj1089 committed Jan 19, 2025
1 parent 651aab4 commit 1169d5b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 53 deletions.
56 changes: 21 additions & 35 deletions client/public/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Open Source Invoicing App made using the MERN Stack"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--

<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Open Source Invoicing App made using the MERN Stack" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap"
/>
<!--
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Expand All @@ -28,22 +23,13 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Aiinterviewer</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css
"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js
"
/>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
<title>Aiinterviewer</title>
</head>

<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand All @@ -53,5 +39,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
</body>
</html>
14 changes: 4 additions & 10 deletions client/src/api/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import axios from 'axios'
import dotenv from 'dotenv'
import axios from 'axios';
import dotenv from 'dotenv';

dotenv.config()

const NODE_ENV = process.env.NODE_ENV
let url;
if (NODE_ENV === 'development') {
url = 'http://localhost:5000'
} else {
url = process.env.REACT_APP_API
}
export const baseURL = url;
const baseURL = process.env.REACT_APP_API;
console.log('baseURl is ', baseURL)
const API = axios.create({ baseURL: baseURL})
export const AI_URL = process.env.AI_APP_API;
const AI_APP_API = axios.create({ baseURL: 'http://localhost:8000'})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const SeeScheduledInterviews = () => {
({ id, role } = checkUserRole(user));
setUserRole(role);
}

console.log("id", id);
const fetchData = async (id) => {
try {
let response = null;
Expand All @@ -48,6 +48,7 @@ const SeeScheduledInterviews = () => {
} else if (userRole === "hr") {
response = await dispatch(getInterviewsHR(id));
}
console.log(response);
if (response && response[0]) {
// Sort interviews by date and time before setting the state
const sortedInterviews = response.sort((a, b) => {
Expand All @@ -66,8 +67,10 @@ const SeeScheduledInterviews = () => {
setDataFetched(true);
} else if (!response[0]) {
openSnackbar("Loading interviews");
setDataFetched(true);
} else {
openSnackbar("Failed to get interviews");
setDataFetched(true);
}
} catch (error) {
openSnackbar("Loading Interviews");
Expand Down
9 changes: 4 additions & 5 deletions client/src/components/UpdateProfile/UpdateProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,17 @@ const UpdateProfile = () => {
const fetchData = async (id) => {
try {
let response = await dispatch(getProfile(id));

if (response) {
let technicalSkills = response.technicalSkills[0].split(",").map(skill => skill.trim());
let softSkills = response.softSkills[0].split(",").map(skill => skill.trim());
console.log(response)
setInitialData({
company: response.company,
firstName: response.firstName,
lastName: response.lastName,
dob: response.dob,
technicalSkills: technicalSkills,
technicalSkills: response.technicalSkills,
experience: response.experience,
softSkills: softSkills,
softSkills: response.softSkills,
education: response.education,
strengths: response.strengths,
weaknesses: response.weaknesses,
Expand Down
6 changes: 5 additions & 1 deletion server/src/controllers/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";
import bcrypt from "bcryptjs";
import jwt from 'jsonwebtoken'
import jwt from 'jsonwebtoken';
// @ts-ignore
import dotenv from "dotenv";
import { Request, Response } from "express";
Expand Down Expand Up @@ -110,6 +110,10 @@ export const signup = async (req: Request, res: Response): Promise<void> => {
return;
}

if (role == null) {
res.status(400).json({message: 'Invalid details. user role is required.'})
}

const existingUser = await User.findOne({ email });

if (existingUser) res.status(400).json({ message: "User already exists" });
Expand Down
2 changes: 1 addition & 1 deletion server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.get('/', (req: Request, res: Response) => {
res.send('Server is ready');
});

const PORT: number = 5000;
const PORT: number = 8000;

server.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
Expand Down

0 comments on commit 1169d5b

Please sign in to comment.