Made Mission marker DB compatible

This commit is contained in:
PxlLoewe
2025-04-24 22:32:18 -07:00
parent 46cbdf6bb9
commit 5bca37182d
22 changed files with 445 additions and 187 deletions

View File

@@ -1,8 +1,10 @@
import { Station, User } from "../../generated/client";
import { PublicUser } from "./User";
export interface MissionStationLog {
type: "station-log";
auto: true;
timeStamp: string;
data: {
stationId: string;
oldFMSstatus: string;
@@ -15,9 +17,11 @@ export interface MissionStationLog {
export interface MissionMessageLog {
type: "message-log";
auto: false;
timeStamp: string;
data: {
message: string;
user: User;
user: PublicUser;
};
}

View File

@@ -0,0 +1,20 @@
import { User } from "../../generated/client";
export interface PublicUser {
firstname: string;
lastname: string;
publicId: string;
badges: string[];
}
export const getPublicUser = (user: User): PublicUser => {
return {
firstname: user.firstname,
lastname: user.lastname
.split(" ")
.map((part) => `${part[0]}.`)
.join(" "), // Only take the first part of the name
publicId: user.publicId,
badges: user.badges,
};
};

View File

@@ -1 +1,3 @@
export type { ParticipantLog } from "./ParticipantLog";
export * from "./ParticipantLog";
export * from "./MissionVehicleLog";
export * from "./User";

View File

@@ -0,0 +1,47 @@
import React from "react";
import {
FieldValues,
Path,
RegisterOptions,
UseFormReturn,
} from "react-hook-form";
import { cn } from "../helper/cn";
interface InputProps<T extends FieldValues>
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "form"> {
name: Path<T>;
form: UseFormReturn<T>;
formOptions?: RegisterOptions<T>;
label?: string;
placeholder?: string;
}
export const Input = <T extends FieldValues>({
name,
label = name,
placeholder = label,
form,
formOptions,
className,
...inputProps
}: InputProps<T>) => {
return (
<label className="floating-label w-full mt-5">
<span className="text-lg flex items-center gap-2">{label}</span>
<input
{...form.register(name, formOptions)}
className={cn(
"input input-bordered w-full placeholder:text-neutral-600",
className,
)}
placeholder={placeholder}
{...inputProps}
/>
{form.formState.errors[name] && (
<p className="text-error">
{form.formState.errors[name].message as string}
</p>
)}
</label>
);
};

View File

@@ -0,0 +1 @@
export * from "./Input";

View File

@@ -0,0 +1,6 @@
import clsx, { ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export const cn = (...inputs: ClassValue[]) => {
return twMerge(clsx(inputs));
};

View File

@@ -1 +1,2 @@
export * from "./helper/event";
export * from "./components";