-
Notifications
You must be signed in to change notification settings - Fork 2
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
Profile page #14
base: master
Are you sure you want to change the base?
Profile page #14
Conversation
const extractUserInfoFromToken = (token: string) => { | ||
// Example: Assuming the token contains user information in the payload | ||
const decodedToken = JSON.parse(atob(token.split('.')[1])); // Decoding JWT payload | ||
const { firstname, lastname, avatar, state, city } = decodedToken; // Extracting user details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
token only contains email and id of the user
access_token: this.jwtService.sign(
{ email: user.email, sub: user.id },
{ expiresIn: "1d", secret: process.env.JWT_SECRET },
)
|
||
@Field({ nullable: true }) | ||
@Column({ length: 50, nullable: true }) | ||
city: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We gotta add the e-wallet id as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be discussed with @DogWitDaButter
] as const; | ||
|
||
async function fetchUserData(token: string): Promise<any> { | ||
const response = await fetch('http://localhost:3000/userProfile', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using GraphQL not REST API, so the url is always localhost:xxxx/graphql, and we use Apolo client not AJAX nor Axios !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be discussed, we might switch to axios, apollo client doesn't support interceptors :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that.
I also found in the Apollo docs that "Apollo also supports interceptors at the GraphQL level: ApolloInterceptor. They are useful to customize operations before they are sent, or to react to the response, in a centralized way. "
Ok, we'll discuss this matter as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I prefer Axios cause more familiar but thought that Apollo client is necessary when using GraphQL
}, []); | ||
async function updateUserProfile(userData: UserData, authToken: string) { | ||
const response = await fetch('http://localhost:3000/updateUserProfile', { | ||
method: 'PUT', // Assuming you're updating user profile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here : No PUT method in GraphQL, the url is always localhost:xxxx/graphql, and we use Apolo client not AJAX nor Axios !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be discussed, same as above
lastName: string; | ||
email: string; | ||
phone: number; | ||
state: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to add the e-wallet here as well.
btw, I don't get why we have two interfaces for the user (UserInfo and UserData)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes required on commented stuff + branch gotta be up to date with master
@@ -176,4 +176,22 @@ export class RentalCarService { | |||
const results = await searchQuery.getMany(); | |||
return results; | |||
} | |||
|
|||
async findOverdueCars(): Promise<Rentalcar[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to perform a join with the cars and return the car
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT C.* FROM CarsTable as C
JOIN CarRental CR on CR.CarId = C.Id
WHERE CR.reservedTo <= currentDate
}); | ||
} | ||
|
||
async updateCarLocation(id: number, location: string): Promise<Car> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this exist in carRenatl service? it should be under cars service
@@ -31,4 +32,23 @@ export class UsersResolver { | |||
findOne(@Args("email", { type: () => String }) email: string) { | |||
return this.usersService.findByEmail(email); | |||
} | |||
/*@Query(() => User, { name: "userProfile" }) | |||
@UseGuards(JwtAuthGuard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to remove i guess
No description provided.