Skip to content

Commit

Permalink
Enable correctness/useHookAtTopLevel
Browse files Browse the repository at this point in the history
Fixes #205
  • Loading branch information
starsep committed Feb 13, 2024
1 parent 6d0be85 commit 75f30ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"correctness": {
"useHookAtTopLevel": "error"
}
}
}
}
7 changes: 4 additions & 3 deletions src/components/sidebar/defibrillatorDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
mdiPhoneOutline,
} from "@mdi/js";
import Icon from "@mdi/react";
import React, { FC } from "react";
import React, { FC, useState } from "react";
import { Button, Card, Columns, Image } from "react-bulma-components";
import { useTranslation } from "react-i18next";
import ImageGallery, { ReactImageGalleryItem } from "react-image-gallery";
Expand Down Expand Up @@ -36,14 +36,15 @@ const PhotoGallery: FC<DefibrillatorDetailsProps> = ({
data,
closeSidebar,
}) => {
if (data === null) return null;
const { t } = useTranslation();
const {
authState: { auth },
setSidebarAction,
setModalState,
} = useAppContext();
const [imageError, setImageError] = React.useState("");
const [imageError, setImageError] = useState("");

if (data === null) return null;
let images: ReactImageGalleryItem[] = [];
// Currently only one photo allowed
if (data.photoRelativeUrl !== undefined && data.photoRelativeUrl !== null) {
Expand Down
13 changes: 8 additions & 5 deletions src/components/sidebar/openingHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ function getOpeningHoursConfig(language: string): argument_hash {
};
}

function parseOpeningHours(openingHours: string): string | null {
function parseOpeningHours(
openingHours: string,
language: string,
): string | null {
if (!openingHours) return null;

try {
const oh = new OpeningHours(openingHours, null, 2);
const language = useLanguage();
const config = getOpeningHoursConfig(language);
// @ts-ignore
return oh.prettifyValue({ conf: config });
Expand Down Expand Up @@ -100,18 +102,19 @@ export const OpeningHoursDescription: FC<OpeningHoursProps> = ({
openingHours,
timezoneOffsetUTCMinutes,
}) => {
const language = useLanguage();
const { t } = useTranslation();

if (!openingHours) {
return <SpanNoData />;
}

const { t } = useTranslation();

return (
<span>
<span className="has-text-weight-medium">
{openingHours === "24/7"
? t("opening_hours.24_7")
: parseOpeningHours(openingHours)}
: parseOpeningHours(openingHours, language)}
</span>
<CurrentlyOpenStatus
openingHours={openingHours}
Expand Down

0 comments on commit 75f30ff

Please sign in to comment.