Changed error boundary to cover both full hub and disaptch app

This commit is contained in:
PxlLoewe
2025-05-29 22:25:30 -07:00
parent d968507484
commit 0cebe2b97e
24 changed files with 226 additions and 194 deletions

View File

@@ -11,12 +11,7 @@ import {
} from "@repo/db";
import { useRef, useState } from "react";
import { useForm } from "react-hook-form";
import {
deleteDispoHistory,
deletePilotHistory,
editUser,
resetPassword,
} from "../../action";
import { deleteDispoHistory, deletePilotHistory, editUser, resetPassword } from "../../action";
import { toast } from "react-hot-toast";
import {
PersonIcon,
@@ -42,9 +37,7 @@ interface ProfileFormProps {
user: User;
}
export const ProfileForm: React.FC<ProfileFormProps> = ({
user,
}: ProfileFormProps) => {
export const ProfileForm: React.FC<ProfileFormProps> = ({ user }: ProfileFormProps) => {
const [isLoading, setIsLoading] = useState(false);
const form = useForm<User>({
defaultValues: user,
@@ -83,9 +76,7 @@ export const ProfileForm: React.FC<ProfileFormProps> = ({
/>
</label>
{form.formState.errors.firstname && (
<p className="text-error">
{form.formState.errors.firstname.message}
</p>
<p className="text-error">{form.formState.errors.firstname.message}</p>
)}
<label className="floating-label w-full mb-5">
<span className="text-lg flex items-center gap-2">
@@ -100,9 +91,7 @@ export const ProfileForm: React.FC<ProfileFormProps> = ({
/>
</label>
{form.formState.errors.lastname && (
<p className="text-error">
{form.formState.errors.lastname?.message}
</p>
<p className="text-error">{form.formState.errors.lastname?.message}</p>
)}
<label className="floating-label w-full">
<span className="text-lg flex items-center gap-2">
@@ -154,11 +143,7 @@ export const ProfileForm: React.FC<ProfileFormProps> = ({
);
};
export const ConnectionHistory: React.FC<{ user: User }> = ({
user,
}: {
user: User;
}) => {
export const ConnectionHistory: React.FC<{ user: User }> = ({ user }: { user: User }) => {
const dispoTableRef = useRef<PaginatedTableRef>(null);
return (
<div className="card-body flex-row flex-wrap">
@@ -185,9 +170,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({
accessorKey: "loginTime",
header: "Login",
cell: ({ row }) => {
return new Date(row.getValue("loginTime")).toLocaleString(
"de-DE",
);
return new Date(row.getValue("loginTime")).toLocaleString("de-DE");
},
},
{
@@ -197,9 +180,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({
return <span className="text-success">Online</span>;
}
const loginTime = new Date(row.original.loginTime).getTime();
const logoutTime = new Date(
row.original.logoutTime,
).getTime();
const logoutTime = new Date(row.original.logoutTime).getTime();
const timeOnline = logoutTime - loginTime;
@@ -253,10 +234,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({
header: "Station",
cell: ({ row }) => {
return (
<Link
className="link link-hover"
href={`/admin/station/${row.original.id}`}
>
<Link className="link link-hover" href={`/admin/station/${row.original.id}`}>
{row.original.Station.bosCallsign}
</Link>
);
@@ -266,9 +244,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({
accessorKey: "loginTime",
header: "Login",
cell: ({ row }) => {
return new Date(row.getValue("loginTime")).toLocaleString(
"de-DE",
);
return new Date(row.getValue("loginTime")).toLocaleString("de-DE");
},
},
{
@@ -278,9 +254,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({
return <span className="text-success">Online</span>;
}
const loginTime = new Date(row.original.loginTime).getTime();
const logoutTime = new Date(
row.original.logoutTime,
).getTime();
const logoutTime = new Date(row.original.logoutTime).getTime();
const timeOnline = logoutTime - loginTime;
const hours = Math.floor(timeOnline / 1000 / 60 / 60);
@@ -360,19 +334,10 @@ export const UserReports = ({ user }: { user: User }) => {
return `${user.firstname} ${user.lastname} (${user.publicId})`;
},
},
{
accessorKey: "Reported",
header: "Reported",
cell: ({ row }) => {
const user = row.getValue("Reported") as User;
return `${user.firstname} ${user.lastname} (${user.publicId})`;
},
},
{
accessorKey: "timestamp",
header: "Time",
cell: ({ row }) =>
new Date(row.getValue("timestamp")).toLocaleString(),
cell: ({ row }) => new Date(row.getValue("timestamp")).toLocaleString(),
},
{
accessorKey: "actions",
@@ -411,12 +376,7 @@ interface AdminFormProps {
};
}
export const AdminForm = ({
user,
dispoTime,
pilotTime,
reports,
}: AdminFormProps) => {
export const AdminForm = ({ user, dispoTime, pilotTime, reports }: AdminFormProps) => {
const router = useRouter();
return (
@@ -495,8 +455,7 @@ export const AdminForm = ({
</div>
<div className="stat-title">Dispo Zeit</div>
<div className="stat-desc text-secondary">
{dispoTime.lastLogin &&
new Date(dispoTime.lastLogin).toLocaleString("de-DE")}
{dispoTime.lastLogin && new Date(dispoTime.lastLogin).toLocaleString("de-DE")}
</div>
</div>
<div className="stat">
@@ -508,8 +467,7 @@ export const AdminForm = ({
</div>
<div className="stat-title">Pilot Zeit</div>
<div className="stat-desc text-secondary">
{pilotTime.lastLogin &&
new Date(pilotTime.lastLogin).toLocaleString("de-DE")}
{pilotTime.lastLogin && new Date(pilotTime.lastLogin).toLocaleString("de-DE")}
</div>
</div>
</div>
@@ -523,12 +481,7 @@ export const AdminForm = ({
<div className="stat-figure text-primary">
<ExclamationTriangleIcon className="w-8 h-8" />
</div>
<div
className={cn(
"stat-value text-primary",
reports.open && "text-warning",
)}
>
<div className={cn("stat-value text-primary", reports.open && "text-warning")}>
{reports.open}
</div>
<div className="stat-title">Offen</div>
@@ -539,9 +492,7 @@ export const AdminForm = ({
</div>
<div className="stat-value text-primary">{reports.total60Days}</div>
<div className="stat-title">in den letzten 60 Tagen</div>
<div className="stat-desc text-secondary">
{reports.total} insgesammt
</div>
<div className="stat-desc text-secondary">{reports.total} insgesammt</div>
</div>
</div>
</div>