Skip to content

Commit

Permalink
chore: fix user mgmt code due to auth0 lib upgrade
Browse files Browse the repository at this point in the history
chore: remove dead code
  • Loading branch information
vnugent committed Nov 10, 2024
1 parent e46f1cc commit d032de1
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 940 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AUTH0_CLIENT_SECRET=send request to hello at openbeta.io
NEXTAUTH_SECRET=vQyFR7gskaqxehN0cI/53r+duWc5Et0ktdoz6KozTCo=

# Auth0 Management API
AUTH0_MGMT_CLIENT_ID=seD3dNxnZ4jXik1dzdQEgPSNSvXGBsqA
AUTH0_MGMT_CLIENT_ID=Ecyj4oke3Cpk1khRsdKr8njen6ZZKePF
AUTH0_MGMT_CLIENT_SECRET=send request to hello at openbeta.io

######### Client-side vars ############
Expand Down
2 changes: 2 additions & 0 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface AUTH_CONFIG_SERVER_TYPE {
clientSecret: string
mgmtClientId: string
mgmtClientSecret: string
mgmtClientAudience: string
nextauthSecret: string
}

Expand All @@ -26,6 +27,7 @@ if (typeof window === 'undefined') {
clientSecret: checkAndPrintWarning('AUTH0_CLIENT_SECRET', process.env.AUTH0_CLIENT_SECRET),
mgmtClientId: checkAndPrintWarning('AUTH0_MGMT_CLIENT_ID', process.env.AUTH0_MGMT_CLIENT_ID),
mgmtClientSecret: checkAndPrintWarning('AUTH0_MGMT_CLIENT_SECRET', process.env.AUTH0_MGMT_CLIENT_SECRET),
mgmtClientAudience: checkAndPrintWarning('AUTH0_MGMT_CLIENT_SECRET', process.env.AUTH0_MGMT_CLIENT_AUDIENCE),
nextauthSecret: checkAndPrintWarning('NEXTAUTH_SECRET', process.env.NEXTAUTH_SECRET)
}
} else {
Expand Down
79 changes: 0 additions & 79 deletions src/components/area/panel/panelList.tsx

This file was deleted.

86 changes: 0 additions & 86 deletions src/components/area/panel/sidePanel.tsx

This file was deleted.

10 changes: 5 additions & 5 deletions src/components/basecamp/UserForm.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { User } from 'auth0'
import type { UserProfile } from 'auth0'
import clx from 'classnames'
import { TextArea } from '../ui/form'
import { useForm, FormProvider } from 'react-hook-form'
import { MUUID_VALIDATION, conjoinedStringToArray } from './utils'
import axios from 'axios'
import useSWR from 'swr'
import { Role } from 'auth0'
import { UserInfoResponse } from 'auth0'
import { UserRole } from '../../js/types'
import MultiSelect from '../ui/form/MultiSelect'
import { useEffect } from 'react'

interface UserFormProps {
user: User
user: UserProfile
onClose: () => void
}

Expand All @@ -26,11 +26,11 @@ const fetcher = async (url: string): Promise<any> => (await axios.get(url)).data
* Form for updating users.
*/
export default function UserForm ({ user, onClose }: UserFormProps): JSX.Element {
const userId = user.user_id
const userId = user.user_id as string
if (userId == null) {
return <div>Can't load user. Missing user_id.</div>
}
const { data: roles, error, mutate } = useSWR<Role[]>(`/api/basecamp/userRoles?userId=${userId}`, fetcher)
const { data: roles, error, mutate } = useSWR<UserInfoResponse[]>(`/api/basecamp/userRoles?userId=${userId}`, fetcher)
if (error != null) {
return <div>{error}</div>
}
Expand Down
12 changes: 6 additions & 6 deletions src/components/basecamp/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { formatDistanceToNow, parseISO } from 'date-fns'
import { useSession, signIn } from 'next-auth/react'
import useSWR from 'swr'
import axios from 'axios'
import { UserPage } from 'auth0'
import { GetUsers200ResponseOneOf, GetUsers200ResponseOneOfInner } from 'auth0'

import { MagnifyingGlassIcon, PencilSquareIcon } from '@heroicons/react/20/solid'
import { IUserMetadata, UserRole } from '../../js/types/User'
import { usersToCsv, saveAsCSVFile } from '../../js/utils/csv'
import { CLIENT_CONFIG } from '../../js/configs/clientConfig'
import { Input } from '../ui/form'
import { useForm, FormProvider } from 'react-hook-form'
import type { User } from 'auth0'
import type { UserProfile } from 'auth0'
import CreateUpdateModal from './CreateUpdateModal'
import UserForm from './UserForm'
import { RulesType } from '../../js/types'
Expand Down Expand Up @@ -55,7 +55,7 @@ const UserTable = (): JSX.Element => {
const [currentPage, setPage] = useState(0)
const [emailFilter, setEmailFilter] = useState('')
const [modalOpen, setModalOpen] = useState(false)
const [focussedUser, setFocussedUser] = useState<User | null>(null)
const [focussedUser, setFocussedUser] = useState<UserProfile | null>(null)

// React-hook-form declaration
const form = useForm<HtmlFormProps>({
Expand All @@ -67,7 +67,7 @@ const UserTable = (): JSX.Element => {
const { handleSubmit } = form
const submitHandler = ({ email }: HtmlFormProps): void => { setEmailFilter(email) }

const { isLoading, data: userPage, error, mutate } = useSWR<UserPage>(`/api/basecamp/users?page=${currentPage}&email=${emailFilter}&type=auth0`, fetcher)
const { isLoading, data: userPage, error, mutate } = useSWR<GetUsers200ResponseOneOf>(`/api/basecamp/users?page=${currentPage}&email=${emailFilter}&type=auth0`, fetcher)
if (isLoading) return <div className='my-8>'>Loading...</div>

const totalPages = Math.ceil((userPage?.total ?? 0) / (userPage?.limit ?? 0))
Expand Down Expand Up @@ -144,7 +144,7 @@ const UserTable = (): JSX.Element => {
interface UserRowProps {
index: number
user: any
setFocussedUser: (arg0: User) => void
setFocussedUser: (arg0: GetUsers200ResponseOneOfInner) => void
setModalOpen: (arg0: boolean) => void
}

Expand Down Expand Up @@ -182,7 +182,7 @@ const UserRow = ({ index, user, setFocussedUser, setModalOpen }: UserRowProps):

const PasswordlessUsers = (): JSX.Element => {
const [currentPage, setPage] = useState(0)
const { data: userPage } = useSWR<UserPage>(`/api/basecamp/users?page=${currentPage}&type=email`, fetcher)
const { data: userPage } = useSWR<GetUsers200ResponseOneOf>(`/api/basecamp/users?page=${currentPage}&type=email`, fetcher)

const onClickHandler = (userId: string): void => {
void axios.get(`/api/basecamp/migrate?id=${userId}`)
Expand Down
110 changes: 0 additions & 110 deletions src/components/users/FavouriteButton.tsx

This file was deleted.

Loading

0 comments on commit d032de1

Please sign in to comment.