MED-137: add doctor other jobs view (#55)

* add doctor jobs view

* change translation

* another translation change

* clean up

* add analaysis detail view to paths config

* translation

* merge fix

* fix path

* move components to shared

* refactor

* imports

* clean up
This commit is contained in:
Helena
2025-08-25 11:12:57 +03:00
committed by GitHub
parent ee86bb8829
commit 195af1db3d
156 changed files with 2823 additions and 364 deletions

View File

@@ -4,12 +4,12 @@ import { NextResponse, URLPattern } from 'next/server';
import { CsrfError, createCsrfProtect } from '@edge-csrf/nextjs';
import { isSuperAdmin } from '@kit/admin';
import { isDoctor } from '@kit/doctor';
import { appConfig, pathsConfig } from '@kit/shared/config';
import { checkRequiresMultiFactorAuthentication } from '@kit/supabase/check-requires-mfa';
import { createMiddlewareClient } from '@kit/supabase/middleware-client';
import { middleware as medusaMiddleware } from "~/medusa/middleware";
import appConfig from '~/config/app.config';
import pathsConfig from '~/config/paths.config';
import { middleware as medusaMiddleware } from '~/medusa/middleware';
const CSRF_SECRET_COOKIE = 'csrfSecret';
const NEXT_ACTION_HEADER = 'next-action';
@@ -132,6 +132,34 @@ async function adminMiddleware(request: NextRequest, response: NextResponse) {
return response;
}
async function doctorMiddleware(request: NextRequest, response: NextResponse) {
const isDoctorPath = request.nextUrl.pathname.startsWith('/doctor');
if (!isDoctorPath) {
return;
}
const {
data: { user },
error,
} = await getUser(request, response);
if (!user || error) {
return NextResponse.redirect(
new URL(pathsConfig.auth.signIn, request.nextUrl.origin).href,
);
}
const client = createMiddlewareClient(request, response);
const userIsDoctor = await isDoctor(client);
if (!userIsDoctor) {
return NextResponse.redirect(new URL('/404', request.nextUrl.origin).href);
}
return response;
}
/**
* Define URL patterns and their corresponding handlers.
*/
@@ -141,6 +169,10 @@ function getPatterns() {
pattern: new URLPattern({ pathname: '/admin/*?' }),
handler: adminMiddleware,
},
{
pattern: new URLPattern({ pathname: '/doctor/*?' }),
handler: doctorMiddleware,
},
{
pattern: new URLPattern({ pathname: '/auth/update-account' }),
handler: async (req: NextRequest, res: NextResponse) => {