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 { getConnectedDispatcherAPI } from "_querys/dispatcher";
|
||||
import { getConnectedAircraftsAPI } from "_querys/aircrafts";
|
||||
import { useDispatchConnectionStore } from "_store/dispatch/connectionStore";
|
||||
|
||||
export const Chat = () => {
|
||||
const {
|
||||
@@ -26,6 +27,7 @@ export const Chat = () => {
|
||||
const session = useSession();
|
||||
const [addTabValue, setAddTabValue] = useState<string>("default");
|
||||
const [message, setMessage] = useState<string>("");
|
||||
const dispatcherConnected = useDispatchConnectionStore((state) => state.status === "connected");
|
||||
|
||||
const { data: dispatcher } = useQuery({
|
||||
queryKey: ["dispatcher"],
|
||||
@@ -36,6 +38,7 @@ export const Chat = () => {
|
||||
queryKey: ["aircrafts"],
|
||||
queryFn: () => getConnectedAircraftsAPI(),
|
||||
refetchInterval: 10000,
|
||||
enabled: dispatcherConnected,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
@@ -44,7 +47,9 @@ export const Chat = () => {
|
||||
}, [session.data?.user.id, setOwnId]);
|
||||
|
||||
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 (
|
||||
<div className={cn("dropdown dropdown-right dropdown-center", chatOpen && "dropdown-open")}>
|
||||
|
||||
@@ -33,7 +33,7 @@ const page = () => {
|
||||
header: "Aktionen",
|
||||
cell: ({ row }) => (
|
||||
<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>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -51,11 +51,11 @@ import Link from "next/link";
|
||||
import { ColumnDef } from "@tanstack/react-table";
|
||||
import { Error } from "_components/Error";
|
||||
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 { addPenalty, editPenaltys } from "(app)/admin/penalty/actions";
|
||||
import { reportColumns } from "(app)/admin/report/columns";
|
||||
import { sendMailByTemplate } from "(app)/../../helper/mail";
|
||||
import { sendMailByTemplate } from "../../../../../../helper/mail";
|
||||
|
||||
interface ProfileFormProps {
|
||||
user: User;
|
||||
|
||||
@@ -45,7 +45,7 @@ const AdminUserPage = () => {
|
||||
header: "Aktionen",
|
||||
cell: ({ row }) => (
|
||||
<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>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
@@ -223,7 +223,7 @@ export const SocialForm = ({
|
||||
const router = useRouter();
|
||||
|
||||
const schema = z.object({
|
||||
vatsimCid: z.number().min(1000).max(9999999),
|
||||
vatsimCid: z.string(),
|
||||
});
|
||||
|
||||
type IFormInput = z.infer<typeof schema>;
|
||||
@@ -293,12 +293,10 @@ export const SocialForm = ({
|
||||
<PaperPlaneIcon /> VATSIM-CID
|
||||
</span>
|
||||
<input
|
||||
type="number"
|
||||
type="text"
|
||||
className="input input-bordered w-full"
|
||||
defaultValue={user.vatsimCid as number | undefined}
|
||||
{...form.register("vatsimCid", {
|
||||
valueAsNumber: true,
|
||||
})}
|
||||
defaultValue={user.vatsimCid || undefined}
|
||||
{...form.register("vatsimCid")}
|
||||
/>
|
||||
</label>
|
||||
<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 {
|
||||
id String @id @default(uuid())
|
||||
publicId String @unique
|
||||
id String @id @default(uuid())
|
||||
publicId String @unique
|
||||
firstname String
|
||||
lastname String
|
||||
email String @unique
|
||||
email String @unique
|
||||
password String
|
||||
vatsimCid Int? @map(name: "vatsim_cid")
|
||||
moodleId Int? @map(name: "moodle_id")
|
||||
vatsimCid String? @map(name: "vatsim_cid")
|
||||
moodleId Int? @map(name: "moodle_id")
|
||||
|
||||
// Settings:
|
||||
pathSelected Boolean @default(false)
|
||||
|
||||
Reference in New Issue
Block a user