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

fix: missing edit time button #1563

Merged
merged 1 commit into from
Dec 8, 2024
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
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
Loading