Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit bd87005

Browse files
committed
refactor: remove more unused code
1 parent 7671a8c commit bd87005

17 files changed

Lines changed: 23 additions & 539 deletions

File tree

apps/admin-ui/nginx/nginx.conf

Lines changed: 0 additions & 43 deletions
This file was deleted.

apps/admin-ui/src/component/BigRadio.tsx

Lines changed: 0 additions & 81 deletions
This file was deleted.

apps/admin-ui/src/component/Dialog.tsx

Lines changed: 0 additions & 87 deletions
This file was deleted.

apps/admin-ui/src/component/ReservationsList.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styled from "styled-components";
44
import { useTranslation } from "react-i18next";
55
import { Button } from "hds-react";
66

7-
type NewReservationListItem = {
7+
export type NewReservationListItem = {
88
date: Date;
99
startTime: string;
1010
endTime: string;
@@ -140,13 +140,15 @@ const StatusElement = ({ item }: { item: NewReservationListItem }) => {
140140
);
141141
};
142142

143-
const ReservationList = ({
143+
/// Used by the RecurringReservation pages to show a list of reservations
144+
/// TODO should be renamed / moved to signify that this is only for recurring reservations
145+
export function ReservationList({
144146
header,
145147
items,
146148
hasPadding,
147149
onLoadMore,
148150
hasMore,
149-
}: Props) => {
151+
}: Props) {
150152
const { t } = useTranslation();
151153

152154
if (!items.length) return null;
@@ -187,7 +189,4 @@ const ReservationList = ({
187189
</StyledList>
188190
</ListWrapper>
189191
);
190-
};
191-
192-
export default ReservationList;
193-
export type { NewReservationListItem };
192+
}

apps/admin-ui/src/component/my-units/MyUnitRecurringReservation/MyUnitRecurringReservationForm.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import {
1717
type RecurringReservationForm,
1818
} from "@/schemas";
1919
import { SortedSelect } from "@/component/SortedSelect";
20-
import ReservationList, {
21-
NewReservationListItem,
20+
import {
21+
ReservationList,
22+
type NewReservationListItem,
2223
} from "@/component/ReservationsList";
2324
import { useNotification } from "@/context/NotificationContext";
2425
import { ActionsWrapper, Grid, Element } from "./commonStyling";

apps/admin-ui/src/component/my-units/MyUnitRecurringReservation/RecurringReservationDone.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { ErrorBoundary } from "react-error-boundary";
77
import { z } from "zod";
88
import { H1, H6 } from "common/src/common/typography";
99
import { breakpoints } from "common/src/common/style";
10-
import RecurringReservationsView from "app/component/reservations/requested/RecurringReservationsView";
10+
import RecurringReservationsView from "@/component/reservations/requested/RecurringReservationsView";
1111
import { ActionsWrapper } from "./commonStyling";
12-
import ReservationList from "../../ReservationsList";
12+
import { ReservationList } from "@/component/ReservationsList";
1313

1414
const InfoSection = styled.p`
1515
margin: var(--spacing-l) 0;

apps/admin-ui/src/component/my-units/MyUnitRecurringReservation/ReservationsList.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { addDays, format, nextMonday } from "date-fns";
55
import { ReservationStartInterval } from "common/types/gql-types";
66
import { toUIDate } from "common/src/common/util";
77
import { generateReservations } from "./generateReservations";
8-
import ReservationList from "../../ReservationsList";
8+
import { ReservationList } from "../../ReservationsList";
99

1010
const DATE_FORMAT = "dd.MM.yyyy";
1111
const today = new Date();

apps/admin-ui/src/component/reservations/requested/ApprovalButtons.tsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
11
import React from "react";
22
import { type ReservationNode, State } from "common/types/gql-types";
33
import { useTranslation } from "react-i18next";
4-
import { addHours, isToday } from "date-fns";
54
import { Button } from "hds-react";
65
import { ButtonLikeLink } from "@/component/ButtonLikeLink";
76
import DenyDialog from "./DenyDialog";
87
import ApproveDialog from "./ApproveDialog";
98
import ReturnToRequiredHandlingDialog from "./ReturnToRequiresHandlingDialog";
109
import { useModal } from "@/context/ModalContext";
11-
12-
/* Rules
13-
* Approve only if REQUIRES_HANDLING
14-
* Deny if REQUIRES_HANDLING or CONFIRMED
15-
* Return to handling if DENIED or CONFIRMED
16-
* Other states (e.g. WAITING_FOR_PAYMENT) are not allowed to be modified
17-
*
18-
* Allowed to change state (except deny unconfirmed) only till it's ended.
19-
* Allowed to modify the reservation after ending as long as it's the same date or within one hour.
20-
*/
21-
const isPossibleToApprove = (state: State, end: Date): boolean =>
22-
state === State.RequiresHandling && end > new Date();
23-
24-
const isPossibleToDeny = (state: State, end: Date): boolean => {
25-
if (state === State.RequiresHandling) {
26-
return true;
27-
}
28-
return state === State.Confirmed && end > new Date();
29-
};
30-
31-
const isPossibleToReturn = (state: State, end: Date): boolean =>
32-
(state === State.Denied || state === State.Confirmed) && end > new Date();
33-
34-
const isPossibleToEdit = (state: State, end: Date): boolean => {
35-
if (state !== State.Confirmed) {
36-
return false;
37-
}
38-
const now = new Date();
39-
return end > addHours(now, -1) || isToday(end);
40-
};
10+
import {
11+
isPossibleToApprove,
12+
isPossibleToDeny,
13+
isPossibleToEdit,
14+
isPossibleToReturn,
15+
} from "./reservationModificationRules";
4116

4217
const ApprovalButtons = ({
4318
state,

apps/admin-ui/src/component/reservations/requested/RecurringReservationsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
} from "common/types/gql-types";
1010
import { type ApolloQueryResult } from "@apollo/client";
1111
import { useRecurringReservations } from "./hooks";
12-
import ReservationList from "../../ReservationsList";
13-
import ReservationListButton from "../../ReservationListButton";
12+
import { ReservationList } from "@/component/ReservationsList";
13+
import ReservationListButton from "@/component/ReservationListButton";
1414
import DenyDialog from "./DenyDialog";
1515
import { useModal } from "@/context/ModalContext";
1616
import EditTimeModal from "../EditTimeModal";

apps/admin-ui/src/spa/HomePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Ingress = styled(H2).attrs({ $legacy: true })`
1616
line-height: 1.8125rem;
1717
`;
1818

19-
function ApplicationRounds(): JSX.Element {
19+
function HomePage(): JSX.Element {
2020
const { t } = useTranslation();
2121

2222
const { user } = usePermission();
@@ -37,4 +37,4 @@ function ApplicationRounds(): JSX.Element {
3737
);
3838
}
3939

40-
export default ApplicationRounds;
40+
export default HomePage;

0 commit comments

Comments
 (0)