-
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.
create lesson by directly selecting a set of users within the request…
… list
- Loading branch information
Showing
12 changed files
with
260 additions
and
162 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
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
69 changes: 69 additions & 0 deletions
69
.../src/pages/administration/mentor/request/open-request-list/_types/OTRLessonList.types.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,69 @@ | ||
import { TableColumn } from "react-data-table-component"; | ||
import { Button } from "@/components/ui/Button/Button"; | ||
import { COLOR_OPTS, SIZE_OPTS } from "@/assets/theme.config"; | ||
import { TbEye } from "react-icons/tb"; | ||
import { Link, NavigateFunction } from "react-router-dom"; | ||
import { TrainingRequestModel } from "@/models/TrainingRequestModel"; | ||
import dayjs from "dayjs"; | ||
import { Config } from "@/core/Config"; | ||
import { Checkbox } from "@/components/ui/Checkbox/Checkbox"; | ||
|
||
function getColumns(navigate: NavigateFunction, toggleSelectedUser: (cid: number) => any): TableColumn<TrainingRequestModel>[] { | ||
return [ | ||
{ | ||
name: "Auswahl", | ||
cell: row => { | ||
return <Checkbox onChange={() => toggleSelectedUser(row.user?.id ?? -1)}></Checkbox>; | ||
}, | ||
}, | ||
{ | ||
name: "Trainee", | ||
cell: row => | ||
row.user == null ? ( | ||
"N/A" | ||
) : ( | ||
<Link to={"/administration/users/" + row.user?.id + "?r"} target={"_blank"}> | ||
<span className={"text-primary hover:cursor-pointer hover:underline"}> | ||
{row.user.first_name} {row.user.last_name} ({row.user.id}) | ||
</span> | ||
</Link> | ||
), | ||
}, | ||
{ | ||
name: "Training", | ||
selector: row => row.training_type?.name ?? "N/A", | ||
}, | ||
{ | ||
name: "Station", | ||
selector: row => row.training_station?.callsign ?? "N/A", | ||
}, | ||
{ | ||
name: "Solo Ende", | ||
selector: row => "xx.xx.xxxx", | ||
}, | ||
{ | ||
name: "Angefragt", | ||
selector: row => dayjs.utc(row.createdAt).format(Config.DATE_FORMAT), | ||
}, | ||
{ | ||
name: "Aktion", | ||
cell: row => { | ||
return ( | ||
<Button | ||
className={"my-3"} | ||
onClick={() => navigate(`${row.uuid}`)} | ||
size={SIZE_OPTS.SM} | ||
variant={"twoTone"} | ||
color={COLOR_OPTS.PRIMARY} | ||
icon={<TbEye size={20} />}> | ||
Ansehen | ||
</Button> | ||
); | ||
}, | ||
}, | ||
]; | ||
} | ||
|
||
export default { | ||
getColumns, | ||
}; |
68 changes: 68 additions & 0 deletions
68
.../src/pages/administration/mentor/request/open-request-list/subpages/ORLLesson.subpage.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,68 @@ | ||
import { Table } from "@/components/ui/Table/Table"; | ||
import OTRLessonListTypes from "@/pages/administration/mentor/request/open-request-list/_types/OTRLessonList.types"; | ||
import { TrainingRequestModel } from "@/models/TrainingRequestModel"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { Button } from "@/components/ui/Button/Button"; | ||
import { COLOR_OPTS, TYPE_OPTS } from "@/assets/theme.config"; | ||
import { useState } from "react"; | ||
import { ButtonRow } from "@/components/ui/Button/ButtonRow"; | ||
import { ConversionUtils } from "turbocommons-ts"; | ||
import { Alert } from "@/components/ui/Alert/Alert"; | ||
|
||
export function ORLLessonSubpage({ filteredTrainingRequests, loading }: { filteredTrainingRequests: TrainingRequestModel[]; loading: boolean }) { | ||
const navigate = useNavigate(); | ||
const [selectedUsers, setSelectedUsers] = useState<number[]>([]); | ||
|
||
function toggleSelectedUser(cid: number) { | ||
if (selectedUsers.includes(cid)) { | ||
setSelectedUsers(selectedUsers.filter(u => u !== cid)); | ||
return; | ||
} | ||
|
||
setSelectedUsers([...selectedUsers, cid]); | ||
} | ||
|
||
return ( | ||
<> | ||
<Alert type={TYPE_OPTS.INFO} showIcon> | ||
Eine Lesson kann über mehrere Arten erstellt werden. Zum Einen können auf der linken Seite die Teilnehmer der Lesson ausgewählt und mit dem | ||
unteren Button "Lesson Erstellen" an die Session-Erstellen Seite übertragen werden. Zum Anderen kann über die Funktion "Ansehen" eine normale | ||
Session mit einem Benutzer erstellt werden. | ||
</Alert> | ||
|
||
<Table | ||
paginate | ||
paginationPerPage={15} | ||
className={"mt-5"} | ||
columns={OTRLessonListTypes.getColumns(navigate, toggleSelectedUser)} | ||
data={filteredTrainingRequests.filter((f: TrainingRequestModel) => f.training_type?.type == "lesson")} | ||
loading={loading} | ||
/> | ||
|
||
<ButtonRow> | ||
<Button | ||
className={"mt-5"} | ||
type="button" | ||
variant="twoTone" | ||
color={COLOR_OPTS.PRIMARY} | ||
disabled={selectedUsers.length === 0} | ||
onClick={() => { | ||
const selectedUsersBase64 = ConversionUtils.stringToBase64(JSON.stringify(selectedUsers)); | ||
|
||
const firstRequestUUID = filteredTrainingRequests.find(f => f.user?.id == selectedUsers[0] && f.training_type?.type == "lesson")?.uuid; | ||
const requestsByCIDs = filteredTrainingRequests.filter(f => selectedUsers.includes(f.user?.id ?? -1)); | ||
|
||
// Check if every request is requesting the same training type. If this isn't the case, we don't want to pre-populate the create session page | ||
if (!requestsByCIDs.every(r => r.training_type_id == requestsByCIDs[0].training_type_id)) { | ||
navigate(`/administration/training-session/create?users=${selectedUsersBase64}`); | ||
return; | ||
} | ||
|
||
navigate(`/administration/training-session/create?users=${selectedUsersBase64}&request_uuid=${firstRequestUUID}`); | ||
}}> | ||
Lesson Erstellen ({selectedUsers.length} Teilnehmer) | ||
</Button> | ||
</ButtonRow> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.