Add settings menu

This commit is contained in:
Jackson Harper
2023-09-30 12:51:15 +08:00
parent 16c000bad4
commit 34e9ed16b5
4 changed files with 578 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
import { State } from '../fragments/articleFragment'
export type UpdateUserInput = {
name: string
bio: string
}
export async function updateUserMutation(
input: UpdateUserInput
): Promise<string | undefined> {
const mutation = gql`
mutation UpdateUser($input: UpdateUserInput!) {
updateUser(input: $input) {
... on UpdateUserSuccess {
user {
name
}
}
... on UpdateUserError {
errorCodes
}
}
}
`
try {
const data = await gqlFetcher(mutation, {
input,
})
const output = data as any
return output.updateUser.user.name
} catch (err) {
return undefined
}
}

View File

@ -0,0 +1,40 @@
import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
import { State } from '../fragments/articleFragment'
export type UpdateUserProfileInput = {
userId: string
username: string
}
export async function updateUserProfileMutation(
input: UpdateUserProfileInput
): Promise<string | undefined> {
const mutation = gql`
mutation UpdateUserProfile($input: UpdateUserProfileInput!) {
updateUserProfile(input: $input) {
... on UpdateUserProfileSuccess {
user {
profile {
username
}
}
}
... on UpdateUserProfileError {
errorCodes
}
}
}
`
try {
const data = await gqlFetcher(mutation, {
input,
})
const output = data as any
console.log('output: ', output)
return output.updateUserProfile.user.profile.username
} catch (err) {
return undefined
}
}