Skip to content

Commit

Permalink
fix/profile page bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Dereje1 committed Feb 1, 2023
1 parent d925da4 commit 54c98d4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion client/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const actionCreators = {
export function Brand() {
return (
<div className="brand">
<a href="/">
<a href="https://github.com/Dereje1/Pinterest-Clone" target="_blank" rel="noopener noreferrer">
<i className="fa fa-pinterest" aria-hidden="true" />
{' Clone'}
</a>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"server": "nodemon ./bin/www.ts",
"dev": "concurrently --kill-others-on-fail \"npm run server\" \"npm run client\"",
"lint": "./node_modules/.bin/eslint server client tests",
"test": "jest --watch",
"test": "jest --watchAll",
"coverage": "jest --coverage",
"compileTS": "tsc -p ./client && tsc -p ./server --noEmit"
},
Expand Down
8 changes: 6 additions & 2 deletions server/crudroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { reqUser, PinnerType, genericResponseType } from './interfaces';
import { getUserProfile, filterPins, uploadImageToS3 } from './utils';
import isLoggedIn from './auth/isloggedin';
import pins from './models/pins';
import users from './models/user';
import users, { UserType } from './models/user';
import pinLinks from './models/pinlinks';
import savedTags from './models/tags';

Expand Down Expand Up @@ -109,7 +109,11 @@ export const getProfilePins = async (
return res.json({
createdPins: filterPins({ rawPins: createdPins, userId: loggedInUserid, isAdmin: false }),
savedPins: filterPins({ rawPins: savedPins, userId: loggedInUserid, isAdmin: false }),
user: { userId: user.id, service, displayName: user.displayName },
user: {
userId: user[service as keyof UserType].id,
service,
displayName: user[service as keyof UserType].displayName,
},
});
} catch (error) {
return res.json(error);
Expand Down
21 changes: 18 additions & 3 deletions server/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
import mongoose from 'mongoose';

export interface UserType extends mongoose.Document {
displayName: string,
username: string,
id: string
twitter: {
id: string,
token: string,
displayName: string,
username: string,
},
google: {
id: string,
token: string,
displayName: string,
username: string,
},
github: {
id: string,
token: string,
displayName: string,
username: string,
}
}

// define the schema for our user model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ exports[`The Menu component will render the brand 1`] = `
className="brand"
>
<a
href="/"
href="https://github.com/Dereje1/Pinterest-Clone"
rel="noopener noreferrer"
target="_blank"
>
<i
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion tests/server/crudroutes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const setupMocks = (response = rawPinsStub) => {
);
users.find = jest.fn().mockImplementation(
() => ({
exec: jest.fn().mockResolvedValue([{ id: 'requestUserId', displayName: 'requestDisplayName' }]),
exec: jest.fn().mockResolvedValue([{ twitter: { id: 'requestUserId', displayName: 'requestDisplayName' } }]),
}),
);
};
Expand Down

0 comments on commit 54c98d4

Please sign in to comment.