Fix AircraftMarker SDS Form avail for Everyone
This commit is contained in:
@@ -290,6 +290,8 @@ const SDSTab = ({
|
|||||||
const [note, setNote] = useState("");
|
const [note, setNote] = useState("");
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const dispatcherConnected = useDispatchConnectionStore((s) => s.status) === "connected";
|
||||||
|
|
||||||
const sendSdsMutation = useMutation({
|
const sendSdsMutation = useMutation({
|
||||||
mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => {
|
mutationFn: async ({ id, message }: { id: number; message: MissionSdsLog }) => {
|
||||||
await sendSdsMessageAPI(id, message);
|
await sendSdsMessageAPI(id, message);
|
||||||
@@ -309,65 +311,69 @@ const SDSTab = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4">
|
<div className="p-4">
|
||||||
<div className="flex items-center gap-2">
|
{dispatcherConnected && (
|
||||||
{!isChatOpen ? (
|
<div>
|
||||||
<button
|
<div className="flex items-center gap-2">
|
||||||
className="text-base-content text-base cursor-pointer"
|
{!isChatOpen ? (
|
||||||
onClick={() => setIsChatOpen(true)}
|
<button
|
||||||
>
|
className="text-base-content text-base cursor-pointer"
|
||||||
<span className="flex items-center gap-2">
|
onClick={() => setIsChatOpen(true)}
|
||||||
<Plus size={18} /> Notiz hinzufügen
|
>
|
||||||
</span>
|
<span className="flex items-center gap-2">
|
||||||
</button>
|
<Plus size={18} /> Notiz hinzufügen
|
||||||
) : (
|
</span>
|
||||||
<div className="flex items-center gap-2 w-full">
|
</button>
|
||||||
<input
|
) : (
|
||||||
type="text"
|
<div className="flex items-center gap-2 w-full">
|
||||||
placeholder=""
|
<input
|
||||||
className="input input-sm text-base-content flex-1"
|
type="text"
|
||||||
value={note}
|
placeholder=""
|
||||||
onChange={(e) => setNote(e.target.value)}
|
className="input input-sm text-base-content flex-1"
|
||||||
/>
|
value={note}
|
||||||
<button
|
onChange={(e) => setNote(e.target.value)}
|
||||||
className="btn btn-sm btn-primary btn-outline"
|
/>
|
||||||
onClick={() => {
|
<button
|
||||||
if (!mission) return;
|
className="btn btn-sm btn-primary btn-outline"
|
||||||
sendSdsMutation
|
onClick={() => {
|
||||||
.mutateAsync({
|
if (!mission) return;
|
||||||
id: mission.id,
|
sendSdsMutation
|
||||||
message: {
|
.mutateAsync({
|
||||||
type: "sds-log",
|
id: mission.id,
|
||||||
auto: false,
|
message: {
|
||||||
timeStamp: new Date().toISOString(),
|
type: "sds-log",
|
||||||
data: {
|
auto: false,
|
||||||
stationId: aircraft.Station.id,
|
timeStamp: new Date().toISOString(),
|
||||||
station: aircraft.Station,
|
data: {
|
||||||
message: note,
|
stationId: aircraft.Station.id,
|
||||||
user: getPublicUser(session.data!.user),
|
station: aircraft.Station,
|
||||||
},
|
message: note,
|
||||||
},
|
user: getPublicUser(session.data!.user),
|
||||||
})
|
},
|
||||||
.then(() => {
|
},
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
setIsChatOpen(false);
|
||||||
|
setNote("");
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Plus size={20} />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-outline"
|
||||||
|
onClick={() => {
|
||||||
setIsChatOpen(false);
|
setIsChatOpen(false);
|
||||||
setNote("");
|
setNote("");
|
||||||
});
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<Ban size={20} />
|
||||||
<Plus size={20} />
|
</button>
|
||||||
</button>
|
</div>
|
||||||
<button
|
)}
|
||||||
className="btn btn-sm btn-outline"
|
|
||||||
onClick={() => {
|
|
||||||
setIsChatOpen(false);
|
|
||||||
setNote("");
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Ban size={20} />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="divider m-0" />
|
||||||
</div>
|
</div>
|
||||||
<div className="divider m-0" />
|
)}
|
||||||
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
<ul className="space-y-2 max-h-[300px] overflow-y-auto overflow-x-auto">
|
||||||
{log.map((entry, index) => {
|
{log.map((entry, index) => {
|
||||||
const sdsEntry = entry as MissionSdsLog;
|
const sdsEntry = entry as MissionSdsLog;
|
||||||
|
|||||||
Reference in New Issue
Block a user