Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rejecting application reservation unit option #1157

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ResourceEditorView = dynamic(
);

const ApplicationDetails = dynamic(
() => import("./component/applications/ApplicationDetails")
() => import("./spa/applications/[id]/index")
);

const ReservationUnits = dynamic(
Expand Down
74 changes: 42 additions & 32 deletions apps/admin-ui/src/component/Unit/UnitsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,48 @@ type Props = {
isLoading?: boolean;
};

const getColConfig = (t: TFunction, isMyUnits?: boolean) => [
{
headerName: t("Units.headings.name"),
key: "nameFi",
transform: ({ nameFi, pk }: UnitNode) => (
<TableLink href={isMyUnits ? myUnitUrl(pk ?? 0) : unitUrl(pk ?? 0)}>
{truncate(nameFi ?? "-", MAX_UNIT_NAME_LENGTH)}
</TableLink>
),
width: "50%",
isSortable: true,
},
{
headerName: t("Units.headings.serviceSector"),
key: "serviceSector",
isSortable: false,
transform: (unit: UnitNode) =>
(unit?.serviceSectors || [])
.map((serviceSector) => serviceSector?.nameFi)
.join(","),
width: "25%",
},
{
headerName: t("Units.headings.reservationUnitCount"),
key: "typeFi",
isSortable: false,
transform: (unit: UnitNode) => (
<> {unit?.reservationunitSet?.length ?? 0} </>
),
width: "25%",
},
];
type ColumnType = {
headerName: string;
key: string;
transform?: (unit: UnitNode) => JSX.Element | string;
width: string;
isSortable: boolean;
};

function getColConfig(t: TFunction, isMyUnits?: boolean): ColumnType[] {
return [
{
headerName: t("Units.headings.name"),
key: "nameFi",
transform: ({ nameFi, pk }: UnitNode) => (
<TableLink href={isMyUnits ? myUnitUrl(pk ?? 0) : unitUrl(pk ?? 0)}>
{truncate(nameFi ?? "-", MAX_UNIT_NAME_LENGTH)}
</TableLink>
),
width: "50%",
isSortable: true,
},
{
headerName: t("Units.headings.serviceSector"),
key: "serviceSector",
isSortable: false,
transform: (unit: UnitNode) =>
(unit?.serviceSectors || [])
.map((serviceSector) => serviceSector?.nameFi)
.join(","),
width: "25%",
},
{
headerName: t("Units.headings.reservationUnitCount"),
key: "typeFi",
isSortable: false,
transform: (unit: UnitNode) => (
<> {unit?.reservationunitSet?.length ?? 0} </>
),
width: "25%",
},
];
}

export function UnitsTable({
sort,
Expand Down
56 changes: 0 additions & 56 deletions apps/admin-ui/src/component/applications/util.ts

This file was deleted.

54 changes: 54 additions & 0 deletions apps/admin-ui/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import {
type ReservationNode,
ReservationTypeChoice,
ApplicantTypeChoice,
type ApplicationNode,
ApplicationSectionStatusChoice,
ApplicationStatusChoice,
} from "common/types/gql-types";
import { addSeconds } from "date-fns";

Expand Down Expand Up @@ -61,3 +65,53 @@ export const reservationToInterval = (
type: x.type ?? undefined,
};
};

export function getApplicantName(app: ApplicationNode): string {
if (app.applicantType === ApplicantTypeChoice.Individual) {
const { firstName, lastName } = app.contactPerson || {};
return `${firstName || "-"} ${lastName || "-"}`;
}
return app.organisation?.name || "-";
}

export function getApplicationStatusColor(
status: ApplicationStatusChoice,
size: "s" | "l"
): string {
switch (status) {
case ApplicationStatusChoice.Handled:
return "var(--color-info)";
case ApplicationStatusChoice.InAllocation:
return "var(--color-alert-dark)";
case ApplicationStatusChoice.Received:
case ApplicationStatusChoice.Draft:
case ApplicationStatusChoice.ResultsSent:
return "var(--color-white)";
case ApplicationStatusChoice.Expired:
case ApplicationStatusChoice.Cancelled:
default:
switch (size) {
case "s":
return "var(--color-error)";
case "l":
default:
return "var(--color-error-dark)";
}
}
}

export function getApplicationSectiontatusColor(
status: ApplicationSectionStatusChoice
): string {
switch (status) {
case ApplicationSectionStatusChoice.Reserved:
case ApplicationSectionStatusChoice.Unallocated:
case ApplicationSectionStatusChoice.InAllocation:
return "var(--color-alert-dark)";
case ApplicationSectionStatusChoice.Handled:
return "var(--color-success)";
case ApplicationSectionStatusChoice.Failed:
default:
return "var(--color-error)";
}
}
5 changes: 5 additions & 0 deletions apps/admin-ui/src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ const translations: ITranslations = {
mutationFailed: ["Muutos epäonnistui"],
noPermission: ["Sinulla ei ole käyttöoikeutta."],
mutationNoDataReturned: ["Odottamaton vastaus."],
cantRejectAlreadyAllocated: ["Jo jaettua vuoroa ei voi hylätä."],
formValidationError: ["Lomakkeessa on virheitä. {{ message }}"],
descriptive: {
"Reservation overlaps with reservation before due to buffer time.": [
"Varaus menee päällekkäin edellisen varauksen kanssa tauon takia.",
Expand Down Expand Up @@ -413,6 +415,9 @@ const translations: ITranslations = {
numTurns: ["Vuorojen määrä"],
authenticatedUser: ["Tunnistautunut käyttäjä"],
emptyFilterPageName: ["hakemusta"],
rejected: ["Hylätty"],
btnReject: ["Hylkää"],
btnRevert: ["Palauta"],
headings: {
id: ["id"],
customer: ["Hakija"],
Expand Down
Loading