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