V_VERLETZUNG umbenannt, Multi-select gefixed

This commit is contained in:
PxlLoewe
2025-07-04 20:29:46 -07:00
parent 432c3cbfa4
commit 075d34a01c
6 changed files with 99 additions and 54 deletions

View File

@@ -127,8 +127,10 @@ export function StationsSelect<T extends FieldValues>({
placeholder={
isMulti ? "Wähle ein oder mehrere Rettungsmittel aus" : "Wähle ein Rettungsmittel aus"
}
formatOptionLabel={(option: any) => option.component}
options={stationsOptions.map((s) => ({
label: (
label: s.label,
component: (
<div
className={cn(s.type === "vehicle" && isMulti && "tooltip tooltip-right")}
data-tip={

View File

@@ -15,6 +15,7 @@ const customStyles: StylesConfig<any, false> = {
"&:hover": {
borderColor: "color-mix(in oklab, var(--color-base-content) 20%, #0000);",
},
color: "var(--color-primary-content)",
}),
option: (provided, state) => ({
...provided,
@@ -34,12 +35,24 @@ const customStyles: StylesConfig<any, false> = {
...provided,
backgroundColor: "var(--color-base-300)",
}),
input: (provided) => ({
...provided,
color: "var(--color-primary-content)",
}),
menu: (provided) => ({
...provided,
backgroundColor: "var(--color-base-100)",
borderRadius: "0.5rem",
zIndex: 9999,
}),
menuPortal: (provided) => ({
...provided,
maxHeight: "230px",
}),
menuList: (provided) => ({
...provided,
maxHeight: "230px",
}),
};
interface SelectProps extends Omit<SelectTemplateProps, "form" | "value" | "onChange"> {

View File

@@ -385,6 +385,31 @@ const SDSTab = ({
return () => clearInterval(interval);
});
const sendSds = () => {
sendSdsMutation
.mutateAsync({
missionId: mission?.id,
sdsMessage: {
type: "sds-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
stationId: aircraft.Station.id,
station: aircraft.Station,
message: note,
user: getPublicUser(session.data!.user, {
ignorePrivacy: true,
}),
},
},
})
.then(() => {
toast.success("SDS-Nachricht gesendet");
setIsChatOpen(false);
setNote("");
});
};
return (
<div className="p-4">
{dispatcherConnected && (
@@ -409,32 +434,16 @@ const SDSTab = ({
value={note}
onChange={(e) => setNote(e.target.value)}
ref={textInputRef}
onKeyDown={(e) => {
if (e.key === "Enter" && note.trim()) {
sendSds();
}
}}
/>
<button
className="btn btn-sm btn-primary btn-outline"
onClick={() => {
sendSdsMutation
.mutateAsync({
missionId: mission?.id,
sdsMessage: {
type: "sds-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
stationId: aircraft.Station.id,
station: aircraft.Station,
message: note,
user: getPublicUser(session.data!.user, {
ignorePrivacy: true,
}),
},
},
})
.then(() => {
toast.success("SDS-Nachricht gesendet");
setIsChatOpen(false);
setNote("");
});
sendSds();
}}
>
<Plus size={20} />

View File

@@ -588,7 +588,34 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
return () => clearInterval(interval);
});
if (!session.data?.user) return null;
const addMessage = () => {
if (!session.data?.user) return null;
const newMissionLog = [
...mission.missionLog,
{
type: "message-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
message: note,
user: getPublicUser(session.data?.user, { ignorePrivacy: true }),
},
} as MissionMessageLog,
];
editMissionMutation
.mutateAsync({
id: mission.id,
mission: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
missionLog: newMissionLog as any,
},
})
.then(() => {
setIsAddingNote(false);
setNote("");
});
};
return (
<div className="p-4">
{dispatcherConnected && (
@@ -612,36 +639,13 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
value={note}
onChange={(e) => setNote(e.target.value)}
ref={textInputRef}
/>
<button
className="btn btn-sm btn-primary btn-outline"
onClick={() => {
const newMissionLog = [
...mission.missionLog,
{
type: "message-log",
auto: false,
timeStamp: new Date().toISOString(),
data: {
message: note,
user: getPublicUser(session.data?.user, { ignorePrivacy: true }),
},
} as MissionMessageLog,
];
editMissionMutation
.mutateAsync({
id: mission.id,
mission: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
missionLog: newMissionLog as any,
},
})
.then(() => {
setIsAddingNote(false);
setNote("");
});
onKeyDown={(e) => {
if (e.key === "Enter" && note.trim()) {
addMessage();
}
}}
>
/>
<button className="btn btn-sm btn-primary btn-outline" onClick={() => addMessage()}>
<Plus size={20} />
</button>
<button

View File

@@ -6,7 +6,7 @@ enum KEYWORD_CATEGORY {
K_KIND
M_BERGRETTUNG
P_PSYCHIATRISCH
V_VERLETZUNG
V_VERLEGUNG
W_WASSERRETTUNG
Z_SONSTIGES
}

View File

@@ -0,0 +1,17 @@
/*
Warnings:
- The values [V_VERLETZUNG] on the enum `KEYWORD_CATEGORY` will be removed. If these variants are still used in the database, this will fail.
*/
DELETE FROM "Keyword" WHERE "category" = 'V_VERLETZUNG';
-- AlterEnum
BEGIN;
CREATE TYPE "KEYWORD_CATEGORY_new" AS ENUM ('AB_ATMUNG', 'C_KREISLAUF', 'D_NEUROLOGISCH', 'E_TRAUMA_SONSTIGES', 'K_KIND', 'M_BERGRETTUNG', 'P_PSYCHIATRISCH', 'V_VERLEGUNG', 'W_WASSERRETTUNG', 'Z_SONSTIGES');
ALTER TABLE "Keyword" ALTER COLUMN "category" TYPE "KEYWORD_CATEGORY_new" USING ("category"::text::"KEYWORD_CATEGORY_new");
ALTER TYPE "KEYWORD_CATEGORY" RENAME TO "KEYWORD_CATEGORY_old";
ALTER TYPE "KEYWORD_CATEGORY_new" RENAME TO "KEYWORD_CATEGORY";
DROP TYPE "KEYWORD_CATEGORY_old";
COMMIT;