fixed moodle logic
This commit is contained in:
@@ -62,15 +62,6 @@ export const AppointmentModal = ({
|
||||
timeCaption="Uhrzeit"
|
||||
showTimeCaption
|
||||
/>
|
||||
{/* <Input
|
||||
form={appointmentForm}
|
||||
type="datetime-local"
|
||||
label="Datum"
|
||||
name="appointmentDate"
|
||||
formOptions={{
|
||||
valueAsDate: true,
|
||||
}}
|
||||
/> */}
|
||||
<div>
|
||||
<PaginatedTable
|
||||
hide={appointmentForm.watch("id") === undefined}
|
||||
|
||||
@@ -55,23 +55,28 @@ export const ParticipantModal = ({ participantForm, ref }: ParticipantModalProps
|
||||
<Button
|
||||
className="btn-sm"
|
||||
onClick={async () => {
|
||||
if (!participantForm.watch("id")) return;
|
||||
try {
|
||||
if (!participantForm.watch("id")) return;
|
||||
|
||||
const participant = participantForm.getValues();
|
||||
await handleParticipantFinished(participant.id.toString()).catch((e) => {
|
||||
const error = e as AxiosError;
|
||||
const participant = participantForm.getValues();
|
||||
await handleParticipantFinished(participant.id.toString()).catch((e) => {
|
||||
const error = e as AxiosError;
|
||||
});
|
||||
|
||||
toast.success("Workflow erfolgreich ausgeführt");
|
||||
router.refresh();
|
||||
} catch (error) {
|
||||
const e = error as AxiosError;
|
||||
if (
|
||||
error.response?.data &&
|
||||
typeof error.response.data === "object" &&
|
||||
"error" in error.response.data
|
||||
e.response?.data &&
|
||||
typeof e.response.data === "object" &&
|
||||
"error" in e.response.data
|
||||
) {
|
||||
toast.error(`Fehler: ${error.response.data.error}`);
|
||||
toast.error(`Fehler: ${e.response.data.error}`);
|
||||
} else {
|
||||
toast.error("Unbekannter Fehler beim ausführen des Workflows");
|
||||
}
|
||||
});
|
||||
toast.success("Workflow erfolgreich ausgeführt");
|
||||
router.refresh();
|
||||
}
|
||||
}}
|
||||
>
|
||||
Event-abgeschlossen Workflow ausführen
|
||||
|
||||
@@ -158,7 +158,7 @@ export const ProfileForm: React.FC<ProfileFormProps> = ({ user }: ProfileFormPro
|
||||
form={form}
|
||||
name="permissions"
|
||||
label="Permissions"
|
||||
isDisabled={user.permissions.length > (session.data?.user?.permissions?.length ?? 0)}
|
||||
isDisabled={!session.data?.user.permissions.includes("ADMIN_USER_ADVANCED")}
|
||||
options={Object.entries(PERMISSION).map(([key, value]) => ({
|
||||
label: value,
|
||||
value: key,
|
||||
@@ -325,6 +325,7 @@ export const ConnectionHistory: React.FC<{ user: User }> = ({ user }: { user: Us
|
||||
export const UserPenalties = ({ user }: { user: User }) => {
|
||||
const createdUser = useSession().data?.user;
|
||||
const penaltyTable = useRef<PaginatedTableRef>(null);
|
||||
const session = useSession();
|
||||
return (
|
||||
<div className="card-body">
|
||||
<h2 className="card-title flex justify-between">
|
||||
@@ -353,25 +354,27 @@ export const UserPenalties = ({ user }: { user: User }) => {
|
||||
btnTip="Timeban hinzufügen"
|
||||
showDatePicker={true}
|
||||
/>
|
||||
<PenaltyDropdown
|
||||
Icon={<LockKeyhole size={15} />}
|
||||
onClick={async ({ reason }) => {
|
||||
if (!reason) return toast.error("Bitte gib einen Grund für die Strafe an.");
|
||||
if (!createdUser)
|
||||
return toast.error("Du musst eingeloggt sein, um eine Strafe zu erstellen.");
|
||||
await addPenalty({
|
||||
reason,
|
||||
type: "BAN",
|
||||
userId: user.id,
|
||||
createdUserId: createdUser.id,
|
||||
});
|
||||
await editUser(user.id, { isBanned: true });
|
||||
penaltyTable.current?.refresh();
|
||||
toast.success("Ban wurde hinzugefügt!");
|
||||
}}
|
||||
btnClassName="btn btn-outline btn-error tooltip-error"
|
||||
btnTip="Rechte-entzug hinzufügen"
|
||||
/>
|
||||
{session.data?.user.permissions.includes("ADMIN_USER_ADVANCED") && (
|
||||
<PenaltyDropdown
|
||||
Icon={<LockKeyhole size={15} />}
|
||||
onClick={async ({ reason }) => {
|
||||
if (!reason) return toast.error("Bitte gib einen Grund für die Strafe an.");
|
||||
if (!createdUser)
|
||||
return toast.error("Du musst eingeloggt sein, um eine Strafe zu erstellen.");
|
||||
await addPenalty({
|
||||
reason,
|
||||
type: "BAN",
|
||||
userId: user.id,
|
||||
createdUserId: createdUser.id,
|
||||
});
|
||||
await editUser(user.id, { isBanned: true });
|
||||
penaltyTable.current?.refresh();
|
||||
toast.success("Ban wurde hinzugefügt!");
|
||||
}}
|
||||
btnClassName="btn btn-outline btn-error tooltip-error"
|
||||
btnTip="Nutzerkonto sperren"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</h2>
|
||||
<PaginatedTable
|
||||
@@ -484,7 +487,7 @@ export const AdminForm = ({
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{user.isBanned && (
|
||||
{user.isBanned && session?.user.permissions.includes("ADMIN_USER_ADVANCED") && (
|
||||
<Button
|
||||
onClick={async () => {
|
||||
await editUser(user.id, { isBanned: false });
|
||||
|
||||
Reference in New Issue
Block a user