diff --git a/app/components/popup/modal.tsx b/app/components/popup/modal.tsx index d7a1c79..c34b9b9 100644 --- a/app/components/popup/modal.tsx +++ b/app/components/popup/modal.tsx @@ -42,7 +42,7 @@ export const PopupModal = ({ - + {loaderData?.userToken ? ( + + + + ) : ( + + )} diff --git a/app/pages/news/index.tsx b/app/pages/news/index.tsx index 1cf8ddc..730ddb0 100644 --- a/app/pages/news/index.tsx +++ b/app/pages/news/index.tsx @@ -11,7 +11,7 @@ export const NewsPage = () => {
- +
diff --git a/app/root.tsx b/app/root.tsx index 4812665..8f5a320 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -6,6 +6,7 @@ import { Outlet, Scripts, ScrollRestoration, + type ShouldRevalidateFunctionArgs, } from 'react-router' import type { Route } from './+types/root' @@ -36,7 +37,17 @@ export const meta = ({ location }: Route.MetaArgs) => { ] } -export function Layout({ children }: { children: ReactNode }) { +export const shouldRevalidate = ({ + actionResult, + defaultShouldRevalidate, +}: ShouldRevalidateFunctionArgs) => { + if (actionResult?.success) { + return true + } + return defaultShouldRevalidate +} + +export const Layout = ({ children }: { children: ReactNode }) => { return ( @@ -57,11 +68,7 @@ export function Layout({ children }: { children: ReactNode }) { ) } -export default function App() { - return -} - -export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { +export const ErrorBoundary = ({ error }: Route.ErrorBoundaryProps) => { let message = 'Oops!' let details = 'An unexpected error occurred.' let stack: string | undefined @@ -89,3 +96,9 @@ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) { ) } + +const App = () => { + return +} + +export default App diff --git a/app/routes/actions.news.logout.ts b/app/routes/actions.news.logout.ts new file mode 100644 index 0000000..711843a --- /dev/null +++ b/app/routes/actions.news.logout.ts @@ -0,0 +1,22 @@ +import { data } from 'react-router' + +import { setUserLogoutHeaders } from '~/libs/logout-header.server' + +export const action = async () => { + try { + const responseHeaders = setUserLogoutHeaders() + + return data( + { success: true }, + { headers: responseHeaders, status: 200, statusText: 'OK' }, + ) + } catch { + return data( + { + message: 'Something went wrong', + success: false, + }, + { status: 500 }, + ) + } +}