Skip to content

Commit

Permalink
use switch
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieMcVicker committed Aug 3, 2023
1 parent 1b7563f commit 3b3f623
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions website/src/edit-word-audio.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { ReactElement } from "react"
import { UserRole, useUserRole } from "./auth"
import { UserRole, useCognitoUserGroups, useUserRole } from "./auth"
import { ContributorEditWordAudio } from "./edit-word-audio-contributor"
import { EditorEditWordAudio } from "./edit-word-audio-editor"
import * as Dailp from "./graphql/dailp"

export const EditWordAudio = (p: {
word: Dailp.FormFieldsFragment
}): ReactElement => {
// const userRole = useUserRole()
const userRole = UserRole.CONTRIBUTOR
const userRole = useUserRole()
// const userRole = UserRole.CONTRIBUTOR

if (userRole === UserRole.CONTRIBUTOR)
return <ContributorEditWordAudio word={p.word} />
else if (userRole === UserRole.EDITOR)
return <EditorEditWordAudio word={p.word} />
else return <div>You do not have permission to edit word audio.</div>
switch (userRole) {
case UserRole.CONTRIBUTOR:
return <ContributorEditWordAudio word={p.word} />
case UserRole.EDITOR:
return <EditorEditWordAudio word={p.word} />
case UserRole.READER:
return <div>You do not have permission to edit word audio.</div>
}
}

0 comments on commit 3b3f623

Please sign in to comment.