diff --git a/src/lib/components/dashboardNav.tsx b/src/lib/components/dashboardNav.tsx index 07c63d9..f88de34 100644 --- a/src/lib/components/dashboardNav.tsx +++ b/src/lib/components/dashboardNav.tsx @@ -16,7 +16,7 @@ export const DashboardNav = ({ items }: DashboardNavProps) => { return ( {items.map((item: SideNavItem, index: number) => { - const Icon = Icons[item.icon] + const Icon = Icons[item.icon.toString()] return ( = ({ children }) => { +export const FormSubmitButton: FC = ({ children }) => { const status = useFormStatus() return ( diff --git a/src/lib/components/header.tsx b/src/lib/components/header.tsx index 590602c..cbb49a0 100644 --- a/src/lib/components/header.tsx +++ b/src/lib/components/header.tsx @@ -19,7 +19,7 @@ export async function Header({ user, className }: HeaderProps) { {!user ? ( - + ) : ( & { - className?: string - items?: Item[] + items?: NavigationItem[] } export function MainNavigation(props: MainNavigationProps) { diff --git a/src/lib/components/newArticleButton.tsx b/src/lib/components/newArticleButton.tsx index ee1818f..93cfa85 100644 --- a/src/lib/components/newArticleButton.tsx +++ b/src/lib/components/newArticleButton.tsx @@ -12,12 +12,7 @@ import { useFormState, useFormStatus } from 'react-dom' interface NewArticleButtonProps extends ButtonProps {} export function NewArticleButton({ ...props }: NewArticleButtonProps) { - // const initialState = { - // temporaryArticleId: '' - // } - const initialState = useMemo(() => { - return { temporaryArticleId: '' } - }, []) + const initialState = { temporaryArticleId: '' } const [state, action] = useFormState(articleCreateAction, initialState) const status = useFormStatus() @@ -25,8 +20,6 @@ export function NewArticleButton({ ...props }: NewArticleButtonProps) { useEffect(() => { if (state == initialState) return redirect(`/editor/${state.temporaryArticleId}`) - // router.refresh() - // router.push(`/editor/${state.temporaryArticleId}`) }, [initialState, state]) return ( diff --git a/src/lib/components/signInButton.tsx b/src/lib/components/signInButton.tsx index f2f66fa..9232354 100644 --- a/src/lib/components/signInButton.tsx +++ b/src/lib/components/signInButton.tsx @@ -1,9 +1,9 @@ import { Button } from '@/lib/components/ui/button' import Link from 'next/link' -export function SignInButton() { +export function SignInButton({ href }: { href: string }) { return ( - + Sign In ) diff --git a/src/lib/components/signinCard.tsx b/src/lib/components/signinCard.tsx index 61cb15b..f0c95f3 100644 --- a/src/lib/components/signinCard.tsx +++ b/src/lib/components/signinCard.tsx @@ -9,8 +9,13 @@ import { } from '@/lib/components/ui/card' import { Icons } from '@/lib/components/ui/icons' import { signIn } from 'next-auth/react' +import { useCallback } from 'react' export function SignInCard() { + const signInCallback = useCallback(() => { + signIn('google') + }, []) + return ( @@ -21,7 +26,7 @@ export function SignInCard() { - signIn('google')}> + Google diff --git a/src/lib/components/userAccountNav.tsx b/src/lib/components/userAccountNav.tsx index e6ed9e1..04edf0f 100644 --- a/src/lib/components/userAccountNav.tsx +++ b/src/lib/components/userAccountNav.tsx @@ -58,8 +58,8 @@ export function UserAccountNav({ user }: UserAccountNavProps) { { - event.preventDefault() + onSelect={(e) => { + e.preventDefault() signOut({ callbackUrl: `${window.location.origin}/login` }) diff --git a/src/lib/config/siteConfig.ts b/src/lib/config/siteConfig.ts index 77a6207..2f8b80f 100644 --- a/src/lib/config/siteConfig.ts +++ b/src/lib/config/siteConfig.ts @@ -1,6 +1,10 @@ import { MainNaviItems, SideNavItems, SiteConfig } from '@/lib/types' export const siteConfig: SiteConfig = { + urls: { + login: '/login', + dashboard: '/dashboard' + }, mainNaviItems: [ { title: 'Libraries', @@ -10,7 +14,7 @@ export const siteConfig: SiteConfig = { title: 'Marketplace', href: '/marketplace' } - ] as MainNaviItems, + ], dashboardNavItems: [ { title: 'Overview', diff --git a/src/lib/types/index.d.ts b/src/lib/types/index.d.ts index 6c787eb..d99a910 100644 --- a/src/lib/types/index.d.ts +++ b/src/lib/types/index.d.ts @@ -1,25 +1,26 @@ -import { Icons } from './icons' +import { Icons } from '@/lib/components/ui/icons' export type SiteConfig = { + urls: { + login: string + dashboard: string + } mainNaviItems: MainNaviItems sideNavItems: (userName: string) => SideNavItems - dashboardNavItems: SideNavItems - footerNaviAboutItems: FooterNaviItems - footerNaviLegalItems: FooterNaviItems + dashboardNavItems: (NaviItem & NaviIcon)[] + footerNaviAboutItems: NaviItem[] + footerNaviLegalItems: NaviItem[] } -export type MainNaviItems = MainNaviItem[] -export type MainNaviItem = { + +interface NaviItem { title: string href: string } -export type SideNavItems = SideNavItem[] -export type SideNavItem = { - title: string - href: string - icon: string -} -export type FooterNaviItems = FooterNaviItem[] -export type FooterNaviItem = { - title: string - href: string +interface NaviIcon { + icon: keyof Icons } + +export type MainNaviItems = MainNaviItem[] +export type MainNaviItem = NaviItem +export type SideNavItems = SideNavItem[] +export type SideNavItem = NaviItem & NaviIcon