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={ placeholder={
isMulti ? "Wähle ein oder mehrere Rettungsmittel aus" : "Wähle ein Rettungsmittel aus" isMulti ? "Wähle ein oder mehrere Rettungsmittel aus" : "Wähle ein Rettungsmittel aus"
} }
formatOptionLabel={(option: any) => option.component}
options={stationsOptions.map((s) => ({ options={stationsOptions.map((s) => ({
label: ( label: s.label,
component: (
<div <div
className={cn(s.type === "vehicle" && isMulti && "tooltip tooltip-right")} className={cn(s.type === "vehicle" && isMulti && "tooltip tooltip-right")}
data-tip={ data-tip={

View File

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

View File

@@ -385,6 +385,31 @@ const SDSTab = ({
return () => clearInterval(interval); 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 ( return (
<div className="p-4"> <div className="p-4">
{dispatcherConnected && ( {dispatcherConnected && (
@@ -409,32 +434,16 @@ const SDSTab = ({
value={note} value={note}
onChange={(e) => setNote(e.target.value)} onChange={(e) => setNote(e.target.value)}
ref={textInputRef} ref={textInputRef}
onKeyDown={(e) => {
if (e.key === "Enter" && note.trim()) {
sendSds();
}
}}
/> />
<button <button
className="btn btn-sm btn-primary btn-outline" className="btn btn-sm btn-primary btn-outline"
onClick={() => { onClick={() => {
sendSdsMutation sendSds();
.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("");
});
}} }}
> >
<Plus size={20} /> <Plus size={20} />

View File

@@ -588,7 +588,34 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
return () => clearInterval(interval); 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 ( return (
<div className="p-4"> <div className="p-4">
{dispatcherConnected && ( {dispatcherConnected && (
@@ -612,36 +639,13 @@ const FMSStatusHistory = ({ mission }: { mission: Mission }) => {
value={note} value={note}
onChange={(e) => setNote(e.target.value)} onChange={(e) => setNote(e.target.value)}
ref={textInputRef} ref={textInputRef}
/> onKeyDown={(e) => {
<button if (e.key === "Enter" && note.trim()) {
className="btn btn-sm btn-primary btn-outline" addMessage();
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("");
});
}} }}
> />
<button className="btn btn-sm btn-primary btn-outline" onClick={() => addMessage()}>
<Plus size={20} /> <Plus size={20} />
</button> </button>
<button <button

View File

@@ -6,7 +6,7 @@ enum KEYWORD_CATEGORY {
K_KIND K_KIND
M_BERGRETTUNG M_BERGRETTUNG
P_PSYCHIATRISCH P_PSYCHIATRISCH
V_VERLETZUNG V_VERLEGUNG
W_WASSERRETTUNG W_WASSERRETTUNG
Z_SONSTIGES 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;