Skip to content

Commit

Permalink
Use proper type
Browse files Browse the repository at this point in the history
  • Loading branch information
JiashuHarryHuang committed Nov 15, 2023
1 parent 71861ac commit 93870e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/DesktopSidebar/UserIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
UserIconContainer,
} from '@/styles/components/Sidebar/userIcon.styles';
import { Media } from '@/lib/media';
import { QueriedUserData } from 'bookem-shared/src/types/database';

export const UserIcon = () => {
const [userData, setUserData] = useState(null);
const [userData, setUserData] = useState<QueriedUserData | null>(null);
const [error, setError] = useState<Error>();

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions pages/api/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dbConnect from '@/lib/dbConnect';

import { getSession } from 'next-auth/react';
import Users from 'bookem-shared/src/models/Users';
import { UserData } from 'bookem-shared/src/types/database';
import { QueriedUserData } from 'bookem-shared/src/types/database';

export default async function handler(
req: NextApiRequest,
Expand All @@ -27,7 +27,7 @@ export default async function handler(
await dbConnect();

try {
const user = (await Users.findOne({ email: email })) as UserData;
const user = (await Users.findOne({ email: email })) as QueriedUserData;
res.status(200).json(user);
} catch (e) {
console.error('An error has occurred in index.ts', e);
Expand Down

0 comments on commit 93870e6

Please sign in to comment.