-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up some components, add button row
- Loading branch information
Showing
20 changed files
with
434 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
export class ForbiddenException extends Error { | ||
public readonly error_: string; | ||
public readonly pageStay_: boolean; | ||
|
||
constructor(error: string) { | ||
constructor(error: string, pageStay: boolean = false) { | ||
super(); | ||
this.error_ = error; | ||
this.pageStay_ = pageStay; | ||
} | ||
|
||
public getPageStayAttribute(): boolean { | ||
return this.pageStay_; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { ReactElement } from "react"; | ||
|
||
type MapArrayProps<T> = { | ||
data: T[]; | ||
mapFunction: (value: T, index: number) => ReactElement | ReactElement[]; | ||
mapFunction: (value: T, index: number) => any; | ||
}; | ||
|
||
export function MapArray(props: MapArrayProps<any>) { | ||
return <>{props.data.map(props.mapFunction)}</>; | ||
export function MapArray<T>(props: MapArrayProps<T>) { | ||
return <>{props.data.map<T>(props.mapFunction)}</>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ReactElement } from "react"; | ||
|
||
/** | ||
* Utility component which wraps an arbitrary number of buttons | ||
* and causes them to equally wrap on all pages! | ||
* @param children | ||
* @constructor | ||
*/ | ||
export function ButtonRow({ children }: { children: ReactElement | ReactElement[] }) { | ||
return <div className={"flex flex-wrap flex-col md:flex-row gap-2"}>{children}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
.../pages/administration/mentor/training-session/_components/TrainingSessionParticipants.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Badge } from "@/components/ui/Badge/Badge"; | ||
import { COLOR_OPTS } from "@/assets/theme.config"; | ||
import { Separator } from "@/components/ui/Separator/Separator"; | ||
import { Table } from "@/components/ui/Table/Table"; | ||
import TSCParticipantListTypes from "@/pages/administration/mentor/training-session/session-create/_types/TSCParticipantList.types"; | ||
import { Card } from "@/components/ui/Card/Card"; | ||
import React, { Dispatch, useState } from "react"; | ||
import { UserFilter } from "@/components/ui/UserFilter/UserFilter"; | ||
import { IMinimalUser } from "@models/User"; | ||
|
||
interface ITrainingSessionParticipants { | ||
participants: IMinimalUser[]; | ||
setParticipants: Dispatch<IMinimalUser[]>; | ||
submitting: boolean; | ||
} | ||
|
||
export function TrainingSessionParticipants({ participants, setParticipants, submitting }: ITrainingSessionParticipants) { | ||
function addUser(user: IMinimalUser) { | ||
setParticipants([...participants, user]); | ||
} | ||
|
||
return ( | ||
<Card | ||
header={"Teilnehmer"} | ||
headerBorder | ||
className={"mt-5"} | ||
headerExtra={participants.length == 0 ? <Badge color={COLOR_OPTS.DANGER}>Mindestens ein Teilnehmer erforderlich</Badge> : undefined}> | ||
<UserFilter | ||
onUserSelect={addUser} | ||
removeIDs={participants.map(p => p.id)} | ||
description={ | ||
"Benutzer, die nicht in dem ausgewählten Kurs eingeschrieben sind werden nicht berücksichtigt und der Session entsprechend nicht hinzugefügt." | ||
} | ||
/> | ||
|
||
<Separator /> | ||
|
||
<Table paginate columns={TSCParticipantListTypes.getColumns(participants, setParticipants)} data={participants} /> | ||
</Card> | ||
); | ||
} |
Oops, something went wrong.