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

Commit 5ffe58e

Browse files
committed
fix: missing edit time button
1 parent 7c4f79e commit 5ffe58e

3 files changed

Lines changed: 29 additions & 22 deletions

File tree

apps/admin-ui/.eslintrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
module.exports = {
22
root: true,
33
extends: ["custom/next"],
4+
rules: {
5+
// interface names break
6+
"@typescript-eslint/naming-convention": 0,
7+
},
48
ignorePatterns: [
59
"node_modules/",
610
".next/",

apps/admin-ui/src/spa/reservations/[id]/Calendar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from "react";
22
import CommonCalendar, { CalendarEvent } from "common/src/calendar/Calendar";
3-
import { Toolbar } from "common/src/calendar/Toolbar";
3+
import { Toolbar, ToolbarBtn } from "common/src/calendar/Toolbar";
44
import styled from "styled-components";
55
import { useTranslation } from "react-i18next";
66
import {
@@ -106,9 +106,9 @@ function Calendar({
106106
reservation={reservation}
107107
permission={UserPermissionChoice.CanManageReservations}
108108
>
109-
<button type="button" onClick={handleEditTimeClick}>
109+
<ToolbarBtn onClick={handleEditTimeClick}>
110110
{t("Reservation.EditTimeModal.acceptBtn")}
111-
</button>
111+
</ToolbarBtn>
112112
</VisibleIfPermission>
113113
)}
114114
</Toolbar>

packages/common/src/calendar/Toolbar.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Label = styled(NoWrap)`
3636
`;
3737

3838
/* TODO rewrite this to use inheritable button styles (or HDS buttons) */
39-
const Btn = styled.button<{
39+
export const ToolbarBtn = styled.button.attrs({ type: "button" })<{
4040
$borderless?: boolean;
4141
$active?: boolean;
4242
}>`
@@ -80,9 +80,16 @@ type ToolbarProps = {
8080
onView: (n: View) => void;
8181
view: string;
8282
date: Date;
83+
children?: React.ReactNode;
8384
};
8485

85-
export function Toolbar({ onNavigate, onView, view, date }: ToolbarProps) {
86+
export function Toolbar({
87+
onNavigate,
88+
onView,
89+
view,
90+
date,
91+
children,
92+
}: ToolbarProps) {
8693
const culture = { locale: fi };
8794
const { t } = useTranslation();
8895

@@ -124,59 +131,55 @@ export function Toolbar({ onNavigate, onView, view, date }: ToolbarProps) {
124131
$wrap="wrap"
125132
className="rbc-toolbar"
126133
>
127-
<div>
128-
<Btn
129-
type="button"
134+
<Flex $direction="row">
135+
<ToolbarBtn
130136
onClick={() => onNavigate("TODAY")}
131137
aria-label={t("reservationCalendar:showCurrentDay")}
132138
>
133139
{t("common:today")}
134-
</Btn>
135-
</div>
140+
</ToolbarBtn>
141+
{children}
142+
</Flex>
136143
<DateNavigationWrapper>
137-
<Btn
144+
<ToolbarBtn
138145
$borderless
139-
type="button"
140146
onClick={() => onNavigate("PREV")}
141147
aria-label={t("reservationCalendar:showPrevious", {
142148
view: t(`common:${view}`).toLowerCase(),
143149
})}
144150
>
145151
<IconAngleLeft />
146-
</Btn>
152+
</ToolbarBtn>
147153
<Label>{title}</Label>
148-
<Btn
154+
<ToolbarBtn
149155
$borderless
150-
type="button"
151156
onClick={() => onNavigate("NEXT")}
152157
aria-label={t("reservationCalendar:showNext", {
153158
view: t(`common:${view}`).toLowerCase(),
154159
})}
155160
>
156161
<IconAngleRight />
157-
</Btn>
162+
</ToolbarBtn>
158163
</DateNavigationWrapper>
159164
<div>
160-
<Btn
165+
<ToolbarBtn
161166
$active={view === "day"}
162-
type="button"
163167
onClick={() => onView("day")}
164168
aria-label={t("reservationCalendar:showView", {
165169
view: t("common:day").toLowerCase(),
166170
})}
167171
>
168172
{t("common:day")}
169-
</Btn>
170-
<Btn
173+
</ToolbarBtn>
174+
<ToolbarBtn
171175
$active={view === "week"}
172-
type="button"
173176
onClick={() => onView("week")}
174177
aria-label={t("reservationCalendar:showView", {
175178
view: t("common:week").toLowerCase(),
176179
})}
177180
>
178181
{t("common:week")}
179-
</Btn>
182+
</ToolbarBtn>
180183
</div>
181184
</Flex>
182185
);

0 commit comments

Comments
 (0)