Skip to content

Commit

Permalink
Feat: User settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
Vija02 committed Nov 1, 2024
1 parent 9f23641 commit babec4f
Show file tree
Hide file tree
Showing 17 changed files with 784 additions and 7 deletions.
7 changes: 6 additions & 1 deletion apps/homepage/src/components/SharedLayoutLoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export function SharedLayoutLoggedIn(
<SidebarItem href="/org/create-organization" name="Create new" />
<SidebarItem href="/org/join-organization" name="Join existing" />
</SidebarItem>
<SidebarItem href="/settings" icon={<IoMdSettings />} name="Settings">
<SidebarItem
baseUrl="/settings"
href="/settings/profile"
icon={<IoMdSettings />}
name="Settings"
>
<SidebarItem href="/settings/profile" name="Profile" />
<SidebarItem href="/settings/security" name="Password" />
<SidebarItem href="/settings/emails" name="Emails" />
Expand Down
7 changes: 7 additions & 0 deletions apps/homepage/src/graphql/Model/User/ChangePassword.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation ChangePassword($oldPassword: String!, $newPassword: String!) {
changePassword(
input: { oldPassword: $oldPassword, newPassword: $newPassword }
) {
success
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fragment ProfileSettingsForm_User on User {
id
name
username
avatarUrl
}
10 changes: 10 additions & 0 deletions apps/homepage/src/graphql/Model/User/UpdateUser.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mutation UpdateUser($id: UUID!, $patch: UserPatch!) {
updateUser(input: { id: $id, patch: $patch }) {
clientMutationId
user {
id
name
username
}
}
}
15 changes: 15 additions & 0 deletions apps/homepage/src/graphql/Model/UserEmail/AddEmail.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#import "./EmailsForm_UserEmail.graphql"

mutation AddEmail($email: String!) {
createUserEmail(input: { userEmail: { email: $email } }) {
user {
id
userEmails(first: 50) {
nodes {
id
...EmailsForm_UserEmail
}
}
}
}
}
15 changes: 15 additions & 0 deletions apps/homepage/src/graphql/Model/UserEmail/DeleteEmail.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#import "./EmailsForm_UserEmail.graphql"

mutation DeleteEmail($emailId: UUID!) {
deleteUserEmail(input: { id: $emailId }) {
user {
id
userEmails(first: 50) {
nodes {
id
...EmailsForm_UserEmail
}
}
}
}
}
13 changes: 13 additions & 0 deletions apps/homepage/src/graphql/Model/UserEmail/EmailsForm_User.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#import "./EmailsForm_UserEmail.graphql"

fragment EmailsForm_User on User {
id
userEmails(first: 50) {
nodes {
...EmailsForm_UserEmail
id
email
isVerified
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fragment EmailsForm_UserEmail on UserEmail {
id
email
isVerified
isPrimary
createdAt
}
13 changes: 13 additions & 0 deletions apps/homepage/src/graphql/Model/UserEmail/MakeEmailPrimary.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mutation MakeEmailPrimary($emailId: UUID!) {
makeEmailPrimary(input: { emailId: $emailId }) {
user {
id
userEmails(first: 50) {
nodes {
id
isPrimary
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import "./EmailsForm_User.graphql"

query SettingsEmailsPage {
...SharedLayout_Query
currentUser {
id
isVerified
...EmailsForm_User
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
query SettingsPasswordPage {
currentUser {
id
hasPassword
userEmails(first: 1, condition: { isPrimary: true }) {
nodes {
id
email
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import "./ProfileSettingsForm_User.graphql"

query SettingsProfilePage {
...SharedLayout_Query
currentUser {
id
...ProfileSettingsForm_User
}
}
22 changes: 22 additions & 0 deletions apps/homepage/src/pages/settings/delete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { SharedLayoutLoggedIn } from "@/components/SharedLayoutLoggedIn";
import { Link, Text } from "@chakra-ui/react";
import { supportEmail } from "@repo/config";
import { useSharedQuery } from "@repo/graphql";
import { NextPage } from "next";
import React from "react";

const Settings_Accounts: NextPage = () => {
const query = useSharedQuery();
return (
<SharedLayoutLoggedIn title="Delete Account" query={query} noHandleErrors>
<Text>
Automatic deletion is not supported yet. If you want to proceed, please
send an email to{" "}
<Link href={`mailto:${supportEmail}`}>{supportEmail}</Link>. Sorry for
the inconvenience.
</Text>
</SharedLayoutLoggedIn>
);
};

export default Settings_Accounts;
Loading

0 comments on commit babec4f

Please sign in to comment.