Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.local.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=6LeoV2MsAAAAALq93j1sqFN8y1WzNpHZHUC7PXGU
RECAPTCHA_SECRET_KEY=6LeoV2MsAAAAAH6o_YnnDgcW4fWYhd2Bvb6_WYZo

API_BASE_URL=http://localhost:8080/api

# The uri that next js will use to build the redirect uri
Expand Down
7 changes: 5 additions & 2 deletions app/[locale]/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import NextAuth, { AuthOptions } from "next-auth"
import AzureAD from "next-auth/providers/azure-ad"
import Authentik from "next-auth/providers/authentik"
import { JWT } from "next-auth/jwt";

Expand Down Expand Up @@ -78,6 +77,10 @@ async function refreshToken(token: JWT): Promise<JWT>{
console.log("Failed to refresh");
const text = await refreshResponse.text();
console.log(text);
return {
...token,
error: "RefreshTokenError"
}
}
const response = await refreshResponse.json();

Expand Down Expand Up @@ -108,4 +111,4 @@ declare module "next-auth/jwt" {
refresh_token?: string
error?: "RefreshTokenError"
}
};
}
9 changes: 5 additions & 4 deletions app/[locale]/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactElement, use } from 'react';
import DashboardLayout from './components/dashboardLayout';
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { getTranslations, setRequestLocale } from 'next-intl/server';
import { getAuthenticatedUser } from '@/lib/get-authenticated-user';
import { UserTypes } from '@/models/user-types';
import ToastProvider from '@/utils/provider/ToastProvider';
Expand All @@ -9,11 +9,12 @@ import UserProvider from '@/utils/provider/UserProvider';

type Props = {
children: ReactElement;
params: { locale: string };
params: Promise<{ locale: string }>;
};

export default async function Layout({ children, params: { locale } }: Props) {
unstable_setRequestLocale(locale);
export default async function Layout({ children, params }: Props) {
const { locale } = await params;
setRequestLocale(locale);

const t = await getTranslations('Dashboard');
let user;
Expand Down
8 changes: 5 additions & 3 deletions app/[locale]/dashboard/news/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import NewsPage from './components/NewsPage';
import { getActivityAreas } from '@/lib/get-activity-areas';

interface Props {
params: {locale: string};
searchParams: {id: string};
params: Promise<{ locale: string }>;
searchParams: Promise<{id: string}>;
}

export default async function News({ params: {locale}, searchParams: {id} }: Props) {
export default async function News({ params, searchParams }: Props) {
const { id } = await searchParams;
const { locale } = await params;
const events = await getEvents();
const activityAreas = await getActivityAreas();
const eventsCards = events.map((event, i) => ({ ...event, cardId: i + 1 }));
Expand Down
35 changes: 19 additions & 16 deletions app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,53 @@ import './globals.css';
import 'react-loading-skeleton/dist/skeleton.css';
import '@mdxeditor/editor/style.css';
import { ReactNode } from 'react';
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { locales } from '../../config';
import { getTranslations, setRequestLocale } from 'next-intl/server';
import { locales } from '@/config';
import { NextIntlClientProvider, useMessages } from 'next-intl';
import NextTopLoader from 'nextjs-toploader';
import { SettingsProvider } from '@/utils/provider/SettingsProvider';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import React from 'react';

type Props = {
children: ReactNode;
params: { locale: string };
params: Promise<{ locale: string }>;
};

export function generateStaticParams() {
return locales.map((locale) => ({ locale }));
}

export async function generateMetadata({ params: { locale } }: Omit<Props, 'children'>) {
export async function generateMetadata({ params }: Omit<Props, 'children'>) {
const { locale } = await params;
const t = await getTranslations({ locale, namespace: 'LocaleLayout' });

return {
title: t('title'),
};
}

export default function RootLayout({ children, params: { locale } }: Props) {
unstable_setRequestLocale(locale);
export default function RootLayout({ children, params }: Props) {
const { locale } = React.use(params);
setRequestLocale(locale);
const messages = useMessages();
dayjs.extend(utc);
dayjs.extend(timezone);

return (
<html lang={locale} className={GeistSans.className}>
<body className="bg-base-300 text-base-content">
<NextTopLoader showSpinner={false} />
<main className="flex flex-col h-screen">
<SettingsProvider>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</SettingsProvider>
</main>
</body>
<body className="bg-base-300 text-base-content">
<NextTopLoader showSpinner={false} />
<main className="flex flex-col h-screen">
<SettingsProvider>
<NextIntlClientProvider locale={locale} messages={messages}>
{children}
</NextIntlClientProvider>
</SettingsProvider>
</main>
</body>
</html>
);
}
2 changes: 1 addition & 1 deletion components/DropdownSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function DropdownSelect({ title, items, onFilterChange, defaultSe
{items.map((item, index) => (
<li className="flex" key={index}>
<a className="flex items-center justify-start space-x-2" onClick={() => handleItemClick(index)}>
<input type="checkbox" className="checkbox w-5 h-5" checked={selectedItems.includes(index)} />
<input type="checkbox" className="checkbox w-5 h-5" checked={selectedItems.includes(index)} readOnly />
<span>{item}</span>
</a>
</li>
Expand Down
14 changes: 0 additions & 14 deletions i18n.ts

This file was deleted.

19 changes: 19 additions & 0 deletions i18n/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {notFound} from "next/navigation";
import {getRequestConfig} from 'next-intl/server';
import {routing} from './routing';

// Can be imported from a shared config
const locales = ['en', 'fr'];

export default getRequestConfig(async ({requestLocale}) => {
// Validate that the incoming `locale` parameter is valid
let locale = await requestLocale;
console.log("locale", locale);
if (!locale || !routing.locales.includes(locale as any)) {
locale = routing.defaultLocale;
}
return {
locale,
messages: (await import(`../messages/${locale}.json`)).default
};
});
20 changes: 20 additions & 0 deletions i18n/routing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {defineRouting} from 'next-intl/routing';

export const routing = defineRouting({
locales: ['en', 'fr'],
defaultLocale: 'en',
localePrefix: {
mode: 'always',
prefixes: {
'en': '/en',
'fr': '/fr'
}
},
pathnames: {
'/': '/',
'/dashboard': {
'en': '/dashboard',
'fr': '/tableau de bord'
}
}
});
9 changes: 2 additions & 7 deletions middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';
import createMiddleware from 'next-intl/middleware';

import {routing} from './i18n/routing'
import type { NextRequest } from 'next/server';
import { localePrefix, locales, pathnames } from './config';
import { getServerSession } from 'next-auth/next';
Expand All @@ -25,12 +25,7 @@ export async function middleware(req: NextRequest) {
return NextResponse.next();
}

export default createMiddleware({
locales,
pathnames,
localePrefix,
defaultLocale: 'fr',
});
export default createMiddleware(routing);

export const config = {
matcher: ['/((?!api|_next|static|public|favicon.ico).*)'],
Expand Down
2 changes: 0 additions & 2 deletions modification.md

This file was deleted.

Loading