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

chore: update schema #3347

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/graphql/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export type AccountEnableNotificationChannelInput = {

export const AccountLevel = {
One: 'ONE',
Three: 'THREE',
Two: 'TWO',
Zero: 'ZERO'
} as const;
Expand Down
13 changes: 10 additions & 3 deletions app/graphql/level-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,21 @@ export const LevelContainer: React.FC<PropsWithChildren> = ({ children }) => {

const { data } = useLevelQuery({ fetchPolicy: "cache-only" })
const level = data?.me?.defaultAccount?.level
const isAtLeastLevelOne = level === "ONE" || level === "TWO"
const isAtLeastLevelTwo = level === "TWO"
const isAtLeastLevelOne = level === "ONE" || level === "TWO" || level === "THREE"
const isAtLeastLevelTwo = level === "TWO" || level === "THREE"
const isAtLeastLevelThree = level === "THREE"

const currentLevel = isAuthed && level ? level : "NonAuth"

return (
<LevelContextProvider
value={{ isAtLeastLevelZero, isAtLeastLevelOne, isAtLeastLevelTwo, currentLevel }}
value={{
isAtLeastLevelZero,
isAtLeastLevelOne,
isAtLeastLevelTwo,
isAtLeastLevelThree,
currentLevel,
}}
>
{children}
</LevelContextProvider>
Expand Down
3 changes: 3 additions & 0 deletions app/graphql/level-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const AccountLevel = {
Zero: "ZERO",
One: "ONE",
Two: "TWO",
Three: "THREE",
} as const

export type AccountLevel = (typeof AccountLevel)[keyof typeof AccountLevel]
Expand All @@ -13,11 +14,13 @@ const Level = createContext<{
isAtLeastLevelZero: boolean
isAtLeastLevelOne: boolean
isAtLeastLevelTwo: boolean
isAtLeastLevelThree: boolean
currentLevel: AccountLevel
}>({
isAtLeastLevelZero: false,
isAtLeastLevelOne: false,
isAtLeastLevelTwo: false,
isAtLeastLevelThree: false,
currentLevel: AccountLevel.NonAuth,
})

Expand Down
3 changes: 3 additions & 0 deletions app/screens/settings-screen/account-screen.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export const Unauthed = () => (
isAtLeastLevelZero: false,
isAtLeastLevelOne: false,
isAtLeastLevelTwo: true,
isAtLeastLevelThree: false,
currentLevel: AccountLevel.NonAuth,
}}
>
Expand All @@ -119,6 +120,7 @@ export const AuthedEmailNotSet = () => (
isAtLeastLevelZero: true,
isAtLeastLevelOne: true,
isAtLeastLevelTwo: true,
isAtLeastLevelThree: false,
currentLevel: AccountLevel.One,
}}
>
Expand All @@ -134,6 +136,7 @@ export const AuthedEmailSet = () => (
isAtLeastLevelZero: true,
isAtLeastLevelOne: true,
isAtLeastLevelTwo: true,
isAtLeastLevelThree: false,
currentLevel: AccountLevel.One,
}}
>
Expand Down
Loading