30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { getCurrentUser } from "@/lib/user";
|
|
import { redirect } from "next/navigation";
|
|
import CreateActClient from "./client";
|
|
import { Metadata } from "next";
|
|
import { getActTypes, getInstitutions, getRegions } from "@/lib/acts/repository";
|
|
import { getPositions, getUserPositions } from "@/lib/positions/repository";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Create act",
|
|
robots: { index: false, follow: false },
|
|
};
|
|
|
|
export default async function CreateAct() {
|
|
const user = await getCurrentUser();
|
|
if (!user) redirect("/");
|
|
|
|
const [actTypes, institutions, regions, positions, userPositions] = await Promise.all([
|
|
getActTypes(),
|
|
getInstitutions(),
|
|
getRegions(),
|
|
getPositions(),
|
|
getUserPositions(user.id),
|
|
]);
|
|
|
|
if (userPositions.length === 0) {
|
|
redirect("/");
|
|
}
|
|
|
|
return <CreateActClient actTypes={actTypes} institutions={institutions.filter((institution) => userPositions.some((position) => position.position.institutionId === institution.id))} regions={regions} positions={positions} />;
|
|
} |