Skip to content

Commit

Permalink
fix: missing edit time button
Browse files Browse the repository at this point in the history
  • Loading branch information
joonatank committed Dec 8, 2024
1 parent 7c4f79e commit 5ffe58e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
4 changes: 4 additions & 0 deletions apps/admin-ui/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
module.exports = {
root: true,
extends: ["custom/next"],
rules: {
// interface names break
"@typescript-eslint/naming-convention": 0,
},
ignorePatterns: [
"node_modules/",
".next/",
Expand Down
6 changes: 3 additions & 3 deletions apps/admin-ui/src/spa/reservations/[id]/Calendar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import CommonCalendar, { CalendarEvent } from "common/src/calendar/Calendar";
import { Toolbar } from "common/src/calendar/Toolbar";
import { Toolbar, ToolbarBtn } from "common/src/calendar/Toolbar";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import {
Expand Down Expand Up @@ -106,9 +106,9 @@ function Calendar({
reservation={reservation}
permission={UserPermissionChoice.CanManageReservations}
>
<button type="button" onClick={handleEditTimeClick}>
<ToolbarBtn onClick={handleEditTimeClick}>
{t("Reservation.EditTimeModal.acceptBtn")}
</button>
</ToolbarBtn>
</VisibleIfPermission>
)}
</Toolbar>
Expand Down
41 changes: 22 additions & 19 deletions packages/common/src/calendar/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Label = styled(NoWrap)`
`;

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

export function Toolbar({ onNavigate, onView, view, date }: ToolbarProps) {
export function Toolbar({
onNavigate,
onView,
view,
date,
children,
}: ToolbarProps) {
const culture = { locale: fi };
const { t } = useTranslation();

Expand Down Expand Up @@ -124,59 +131,55 @@ export function Toolbar({ onNavigate, onView, view, date }: ToolbarProps) {
$wrap="wrap"
className="rbc-toolbar"
>
<div>
<Btn
type="button"
<Flex $direction="row">
<ToolbarBtn
onClick={() => onNavigate("TODAY")}
aria-label={t("reservationCalendar:showCurrentDay")}
>
{t("common:today")}
</Btn>
</div>
</ToolbarBtn>
{children}
</Flex>
<DateNavigationWrapper>
<Btn
<ToolbarBtn
$borderless
type="button"
onClick={() => onNavigate("PREV")}
aria-label={t("reservationCalendar:showPrevious", {
view: t(`common:${view}`).toLowerCase(),
})}
>
<IconAngleLeft />
</Btn>
</ToolbarBtn>
<Label>{title}</Label>
<Btn
<ToolbarBtn
$borderless
type="button"
onClick={() => onNavigate("NEXT")}
aria-label={t("reservationCalendar:showNext", {
view: t(`common:${view}`).toLowerCase(),
})}
>
<IconAngleRight />
</Btn>
</ToolbarBtn>
</DateNavigationWrapper>
<div>
<Btn
<ToolbarBtn
$active={view === "day"}
type="button"
onClick={() => onView("day")}
aria-label={t("reservationCalendar:showView", {
view: t("common:day").toLowerCase(),
})}
>
{t("common:day")}
</Btn>
<Btn
</ToolbarBtn>
<ToolbarBtn
$active={view === "week"}
type="button"
onClick={() => onView("week")}
aria-label={t("reservationCalendar:showView", {
view: t("common:week").toLowerCase(),
})}
>
{t("common:week")}
</Btn>
</ToolbarBtn>
</div>
</Flex>
);
Expand Down

0 comments on commit 5ffe58e

Please sign in to comment.