Skip to content

Commit

Permalink
created tuto for creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Othmandn committed Sep 20, 2024
1 parent 6d3d84f commit eb3cdf0
Show file tree
Hide file tree
Showing 18 changed files with 769 additions and 134 deletions.
4 changes: 4 additions & 0 deletions backend/src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export class User extends BaseEntity {
@Column()
role: string;

@Field()
@Column({ default: false })
isFirstTourCompleted: boolean;

@OneToMany(() => Contact, (contact) => contact.user)
@Field(() => [Contact], { nullable: true })
contacts?: Contact[];
Expand Down
10 changes: 10 additions & 0 deletions backend/src/resolvers/user.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,14 @@ export class UserResolver {
throw new Error(String(error));
}
}

@Mutation(() => String)
async updateUserTour(@Arg("userId") userId: number): Promise<string> {
try {
return await UserService.updateUserTour(userId);
} catch (error) {
console.error("Error updating user tour: ", error);
throw new Error("Failed to update user tour");
}
}
}
17 changes: 16 additions & 1 deletion backend/src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export async function updateSocialLink(
throw new Error("No social links found for the user");
}

const socialLink = user.socialLinks.find(link => link.id === id);
const socialLink = user.socialLinks.find((link) => link.id === id);
if (!socialLink) {
throw new Error("Social link not found");
}
Expand All @@ -133,3 +133,18 @@ export async function updateSocialLink(
throw new Error("Failed to update the social link");
}
}

export const updateUserTour = async (userId: number): Promise<string> => {
try {
const user = await User.findOneByOrFail({ id: userId });

user.isFirstTourCompleted = true;

await user.save();

return "first tour completed";
} catch (error) {
console.error("Error updating user tour:", error);
throw new Error("Unable to update user tour");
}
};
136 changes: 136 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"react-beautiful-dnd": "^13.1.1",
"react-color": "^2.19.3",
"react-dom": "^18.3.1",
"react-joyride": "^2.9.2",
"react-loader-spinner": "^6.1.6",
"react-modal": "^3.16.1",
"react-resizable": "^3.0.5",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 35 additions & 12 deletions frontend/src/client/mutations/user/user-mutations.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
import { gql } from "@apollo/client";

export const UPDATE_USER_INFORMATION = gql`
mutation UpdateUser($email: String!, $firstname: String!, $lastname: String!) {
updateUserName(email: $email, firstname: $firstname, lastname: $lastname)
}
mutation UpdateUser(
$email: String!
$firstname: String!
$lastname: String!
) {
updateUserName(email: $email, firstname: $firstname, lastname: $lastname)
}
`;

export const VERIFY_PASSWORD = gql`
mutation VerifyPassword($email: String!, $password: String!) {
verifyPassword(email: $email, password: $password)
}
mutation VerifyPassword($email: String!, $password: String!) {
verifyPassword(email: $email, password: $password)
}
`;

export const CREATE_USER_LINKS = gql`
mutation CreateUserLinks($socialLinkData: SocialLinkInput!, $email: String!) {
createUserLinks(socialLinkData: $socialLinkData, email: $email)
}`;
mutation CreateUserLinks($socialLinkData: SocialLinkInput!, $email: String!) {
createUserLinks(socialLinkData: $socialLinkData, email: $email)
}
`;

export const UPDATE_USER_LINKS = gql`
mutation UpdateUserLinks($email: String!, $id: Float!, $facebook: String!, $twitter: String!, $linkedin: String!) {
updateUserLinks(email: $email, id: $id, facebook: $facebook, twitter: $twitter, linkedin: $linkedin)
}
mutation UpdateUserLinks(
$email: String!
$id: Float!
$facebook: String!
$twitter: String!
$linkedin: String!
) {
updateUserLinks(
email: $email
id: $id
facebook: $facebook
twitter: $twitter
linkedin: $linkedin
)
}
`;

export const UPDATE_USER_TOUR = gql`
mutation UpdateUserTour($userId: Float!) {
updateUserTour(userId: $userId)
}
`;
Loading

0 comments on commit eb3cdf0

Please sign in to comment.