new version
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import Header from "@/components/header";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { useLocale, useTranslations } from "next-intl";
|
||||
import type { AdminUser, Consent, Document, Permission, Position, User } from "@/types";
|
||||
import type { AdminUser, Citizen, Consent, Permission, Position, User } from "@/types";
|
||||
import { AppWindowMacIcon, BriefcaseBusinessIcon, FileUserIcon, LogOutIcon, ShieldIcon, UserIcon } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
@@ -13,11 +13,9 @@ import Profile from "./items/profile";
|
||||
import Applications from "./items/applications";
|
||||
import Positions from "./items/positions";
|
||||
import Admin from "./items/admin";
|
||||
import Documents from "./items/documents";
|
||||
|
||||
interface Props {
|
||||
userData: User | null;
|
||||
documentsData: Document[] | null;
|
||||
consentsData: Consent[] | null;
|
||||
permissionsData: Permission[] | null;
|
||||
positionsData: Position[] | null;
|
||||
@@ -30,7 +28,6 @@ interface Props {
|
||||
|
||||
export default function MeClient({
|
||||
userData,
|
||||
documentsData,
|
||||
consentsData,
|
||||
permissionsData,
|
||||
positionsData,
|
||||
@@ -45,7 +42,6 @@ export default function MeClient({
|
||||
const hydratedRef = useRef(false)
|
||||
|
||||
const [user, setUser] = useState(userData);
|
||||
const [documents, setDocuments] = useState(documentsData);
|
||||
const [consents, setConsents] = useState(consentsData);
|
||||
const [permissions, setPermissions] = useState(permissionsData);
|
||||
const [positions, setPositions] = useState(positionsData);
|
||||
@@ -55,7 +51,6 @@ export default function MeClient({
|
||||
|
||||
const baseItems = useMemo(() => [
|
||||
{ name: t("items.profile.title"), icon: <UserIcon />, component: <Profile user={user} setUser={setUser} /> },
|
||||
{ name: "Documents", icon: <FileUserIcon/>, component: <Documents documents={documents} /> },
|
||||
{ name: t("items.applications.title"), icon: <AppWindowMacIcon />, component: <Applications consents={consents} setConsents={setConsents} /> },
|
||||
{ name: t("items.positions.title"), icon: <BriefcaseBusinessIcon />, component: <Positions /> },
|
||||
], [t, user, consents])
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { useLocale, useTranslations } from "next-intl";
|
||||
import type { Document } from "@/types";
|
||||
import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from "@/components/ui/item";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { localeMap } from "@/types";
|
||||
import { enUS } from "date-fns/locale";
|
||||
import { format } from "date-fns";
|
||||
import { revokeConsent } from "@/actions/consents";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Check, X } from "lucide-react";
|
||||
|
||||
interface Props {
|
||||
documents: Document[] | null;
|
||||
}
|
||||
|
||||
export default function Documents({ documents }: Props) {
|
||||
const t = useTranslations("MePage.items.applications");
|
||||
|
||||
const locale = useLocale();
|
||||
|
||||
return (
|
||||
<div className="w-full lg:max-w-sm flex flex-col gap-4">
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-xl">Documents</h1>
|
||||
<p className="text-sm text-muted-foreground">There you can find all of your documents issued by the European Federation</p>
|
||||
</div>
|
||||
<div className="space-y-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import MeComponent from "./component";
|
||||
import { fetchConsents } from "@/actions/consents";
|
||||
import { fetchAllPositions, fetchAllPermissions, fetchAdminUsers, fetchMyPositions } from "@/actions/positions";
|
||||
import { getLocale } from "next-intl/server";
|
||||
import { Document } from "@/types";
|
||||
|
||||
export default async function Me() {
|
||||
const locale = await getLocale();
|
||||
@@ -14,8 +13,6 @@ export default async function Me() {
|
||||
redirect("/api/auth/initiate");
|
||||
}
|
||||
|
||||
const documents: Document[] = [];
|
||||
|
||||
const [consents, myPositions] = await Promise.all([
|
||||
fetchConsents(),
|
||||
fetchMyPositions(locale),
|
||||
@@ -35,7 +32,6 @@ export default async function Me() {
|
||||
return (
|
||||
<MeComponent
|
||||
userData={user}
|
||||
documentsData={documents}
|
||||
consentsData={consents}
|
||||
permissionsData={permissions}
|
||||
positionsData={positions}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import { getRequestConfig } from "next-intl/server";
|
||||
import { cookies } from "next/headers";
|
||||
|
||||
|
||||
const VALID_LOCALES = ["en", "ru", "it"];
|
||||
const DEFAULT_LOCALE = "en";
|
||||
|
||||
export default getRequestConfig(async () => {
|
||||
const store = await cookies();
|
||||
const locale = store.get("locale")?.value || 'en';
|
||||
|
||||
const raw = store.get("locale")?.value;
|
||||
const locale = VALID_LOCALES.includes(raw || "") ? raw! : DEFAULT_LOCALE;
|
||||
|
||||
return {
|
||||
locale,
|
||||
messages: (await import(`../messages/${locale}.json`)).default
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
import type { NextConfig } from "next";
|
||||
import createNextIntlPlugin from "next-intl/plugin";
|
||||
|
||||
const nextConfig: NextConfig = {};
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
headers: async () => [
|
||||
{
|
||||
source: "/(.*)",
|
||||
headers: [
|
||||
{ key: "X-Frame-Options", value: "DENY" },
|
||||
{ key: "X-Content-Type-Options", value: "nosniff" },
|
||||
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
||||
{ key: "X-XSS-Protection", value: "1; mode=block" },
|
||||
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
|
||||
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const withNextIntl = createNextIntlPlugin();
|
||||
export default withNextIntl(nextConfig);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -86,43 +86,24 @@ export interface FieldTemplate {
|
||||
generated?: boolean;
|
||||
}
|
||||
|
||||
export interface DocumentType {
|
||||
type CitizenshipApplicationStatus = "pending" | "rejected" | "approved"
|
||||
|
||||
export interface CitizenshipApplication {
|
||||
id: string;
|
||||
code: string;
|
||||
color: string;
|
||||
fields: FieldTemplate[];
|
||||
user_id: string;
|
||||
status: CitizenshipApplicationStatus;
|
||||
region_id: string;
|
||||
reviewed_by?: string;
|
||||
reviewed_at?: string;
|
||||
reject_reason?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export type DocumentApplicationStatus = "pending" | "approved" | "rejected"
|
||||
|
||||
export interface DocumentApplication {
|
||||
export interface Citizen {
|
||||
id: string;
|
||||
userId: string;
|
||||
documentTypeId: string;
|
||||
documentType: DocumentType;
|
||||
status: DocumentApplicationStatus;
|
||||
reviewedBy?: string;
|
||||
reviewedAt?: string;
|
||||
rejectReason?: string;
|
||||
data: Record<string, string>;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export type DocumentStatus = "active" | "revoked"
|
||||
|
||||
export interface Document {
|
||||
id: string;
|
||||
userId: string;
|
||||
documentTypeId: string;
|
||||
documentType: DocumentType;
|
||||
applicationId: string;
|
||||
user_id: string;
|
||||
application_id: string;
|
||||
number: string;
|
||||
issuedAt: string;
|
||||
revokedAt?: string | null;
|
||||
revokedBy?: string | null;
|
||||
photo_url?: string | null;
|
||||
data: Record<string, string>;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
issued_at: string;
|
||||
region_id: string;
|
||||
}
|
||||
Reference in New Issue
Block a user