Fix Admin Links, Piloten können nur mit Dispos schreiben
This commit is contained in:
@@ -8,6 +8,7 @@ import { asPublicUser } from "@repo/db";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { getConnectedDispatcherAPI } from "_querys/dispatcher";
|
import { getConnectedDispatcherAPI } from "_querys/dispatcher";
|
||||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||||
|
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||||
|
|
||||||
export const Chat = () => {
|
export const Chat = () => {
|
||||||
const {
|
const {
|
||||||
@@ -26,6 +27,7 @@ export const Chat = () => {
|
|||||||
const session = useSession();
|
const session = useSession();
|
||||||
const [addTabValue, setAddTabValue] = useState<string>("default");
|
const [addTabValue, setAddTabValue] = useState<string>("default");
|
||||||
const [message, setMessage] = useState<string>("");
|
const [message, setMessage] = useState<string>("");
|
||||||
|
const dispatcherConnected = useDispatchConnectionStore((state) => state.status === "connected");
|
||||||
|
|
||||||
const { data: dispatcher } = useQuery({
|
const { data: dispatcher } = useQuery({
|
||||||
queryKey: ["dispatcher"],
|
queryKey: ["dispatcher"],
|
||||||
@@ -36,6 +38,7 @@ export const Chat = () => {
|
|||||||
queryKey: ["aircrafts"],
|
queryKey: ["aircrafts"],
|
||||||
queryFn: () => getConnectedAircraftsAPI(),
|
queryFn: () => getConnectedAircraftsAPI(),
|
||||||
refetchInterval: 10000,
|
refetchInterval: 10000,
|
||||||
|
enabled: dispatcherConnected,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -44,7 +47,9 @@ export const Chat = () => {
|
|||||||
}, [session.data?.user.id, setOwnId]);
|
}, [session.data?.user.id, setOwnId]);
|
||||||
|
|
||||||
const filteredDispatcher = dispatcher?.filter((d) => d.userId !== session.data?.user.id);
|
const filteredDispatcher = dispatcher?.filter((d) => d.userId !== session.data?.user.id);
|
||||||
const filteredAircrafts = aircrafts?.filter((a) => a.userId !== session.data?.user.id);
|
const filteredAircrafts = aircrafts?.filter(
|
||||||
|
(a) => a.userId !== session.data?.user.id && dispatcherConnected,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("dropdown dropdown-right dropdown-center", chatOpen && "dropdown-open")}>
|
<div className={cn("dropdown dropdown-right dropdown-center", chatOpen && "dropdown-open")}>
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const page = () => {
|
|||||||
header: "Aktionen",
|
header: "Aktionen",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Link href={`/admin/event/${row.original.id}`}>
|
<Link href={`/admin/station/${row.original.id}`}>
|
||||||
<button className="btn btn-sm">Edit</button>
|
<button className="btn btn-sm">Edit</button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ import Link from "next/link";
|
|||||||
import { ColumnDef } from "@tanstack/react-table";
|
import { ColumnDef } from "@tanstack/react-table";
|
||||||
import { Error } from "_components/Error";
|
import { Error } from "_components/Error";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { setStandardName } from "(app)/../../helper/discord";
|
import { setStandardName } from "../../../../../../helper/discord";
|
||||||
import { penaltyColumns } from "(app)/admin/penalty/columns";
|
import { penaltyColumns } from "(app)/admin/penalty/columns";
|
||||||
import { addPenalty, editPenaltys } from "(app)/admin/penalty/actions";
|
import { addPenalty, editPenaltys } from "(app)/admin/penalty/actions";
|
||||||
import { reportColumns } from "(app)/admin/report/columns";
|
import { reportColumns } from "(app)/admin/report/columns";
|
||||||
import { sendMailByTemplate } from "(app)/../../helper/mail";
|
import { sendMailByTemplate } from "../../../../../../helper/mail";
|
||||||
|
|
||||||
interface ProfileFormProps {
|
interface ProfileFormProps {
|
||||||
user: User;
|
user: User;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const AdminUserPage = () => {
|
|||||||
header: "Aktionen",
|
header: "Aktionen",
|
||||||
cell: ({ row }) => (
|
cell: ({ row }) => (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Link href={`/admin/event/${row.original.id}`}>
|
<Link href={`/admin/user/${row.original.id}`}>
|
||||||
<button className="btn btn-sm">Anzeigen</button>
|
<button className="btn btn-sm">Anzeigen</button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ export const SocialForm = ({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
vatsimCid: z.number().min(1000).max(9999999),
|
vatsimCid: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
type IFormInput = z.infer<typeof schema>;
|
type IFormInput = z.infer<typeof schema>;
|
||||||
@@ -293,12 +293,10 @@ export const SocialForm = ({
|
|||||||
<PaperPlaneIcon /> VATSIM-CID
|
<PaperPlaneIcon /> VATSIM-CID
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type="number"
|
type="text"
|
||||||
className="input input-bordered w-full"
|
className="input input-bordered w-full"
|
||||||
defaultValue={user.vatsimCid as number | undefined}
|
defaultValue={user.vatsimCid || undefined}
|
||||||
{...form.register("vatsimCid", {
|
{...form.register("vatsimCid")}
|
||||||
valueAsNumber: true,
|
|
||||||
})}
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<p
|
<p
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "users" ALTER COLUMN "vatsim_cid" SET DATA TYPE TEXT;
|
||||||
@@ -24,14 +24,14 @@ enum PERMISSION {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
publicId String @unique
|
publicId String @unique
|
||||||
firstname String
|
firstname String
|
||||||
lastname String
|
lastname String
|
||||||
email String @unique
|
email String @unique
|
||||||
password String
|
password String
|
||||||
vatsimCid Int? @map(name: "vatsim_cid")
|
vatsimCid String? @map(name: "vatsim_cid")
|
||||||
moodleId Int? @map(name: "moodle_id")
|
moodleId Int? @map(name: "moodle_id")
|
||||||
|
|
||||||
// Settings:
|
// Settings:
|
||||||
pathSelected Boolean @default(false)
|
pathSelected Boolean @default(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user