Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Profile page #14

wants to merge 5 commits into from

Conversation

neirezcher
Copy link
Collaborator

No description provided.

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
Copy link
Collaborator

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 },
)

@chamsTmar1 chamsTmar1 self-requested a review April 30, 2024 18:40

@Field({ nullable: true })
@Column({ length: 50, nullable: true })
city: string;
Copy link
Collaborator

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

Copy link
Owner

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', {
Copy link
Collaborator

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 !!

Copy link
Owner

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 :(

Copy link
Collaborator

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

Copy link
Collaborator

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
Copy link
Collaborator

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 !!

Copy link
Owner

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;
Copy link
Collaborator

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)

Copy link
Collaborator

@chamsTmar1 chamsTmar1 left a 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[]> {
Copy link
Owner

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

Copy link
Owner

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> {
Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why commented?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to remove i guess

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants