Initial BizOne portal setup

This commit is contained in:
2026-05-11 11:36:33 +07:00
commit 57017dd397
249 changed files with 41305 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import { NextResponse } from 'next/server';
import { cookies } from 'next/headers';
import { authCookieName } from '../../../lib/auth';
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001/api';
async function getToken() {
return (await cookies()).get(authCookieName)?.value;
}
export async function GET(request: Request) {
const token = await getToken();
if (!token) {
return NextResponse.json({ message: 'Unauthorized' }, { status: 401 });
}
const url = new URL(request.url);
const response = await fetch(`${API_URL}/templates${url.search}`, {
headers: {
Authorization: `Bearer ${token}`,
},
cache: 'no-store',
});
const payload = await response.json();
return NextResponse.json(payload, { status: response.status });
}
export async function POST(request: Request) {
const token = await getToken();
if (!token) {
return NextResponse.json({ message: 'Unauthorized' }, { status: 401 });
}
const body = await request.json();
const response = await fetch(`${API_URL}/templates`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
body: JSON.stringify(body),
cache: 'no-store',
});
const payload = await response.json();
return NextResponse.json(payload, { status: response.status });
}