Skip to content

Commit 316db9c

Browse files
committed
apply other review comments
1 parent e47909f commit 316db9c

4 files changed

Lines changed: 17 additions & 37 deletions

File tree

locale/defaultMessages.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7957,6 +7957,9 @@
79577957
"hYWxeg": {
79587958
"string": "The extension requests permissions you cannot grant or that exceed its allowed scope. Review the extension's manifest and your permissions. {docsLink} ({errorCode})"
79597959
},
7960+
"hh0xW7": {
7961+
"string": "Channel Name"
7962+
},
79607963
"hjEkEH": {
79617964
"string": "All webhooks registered by this extension. In case of failed webhook delivery, list of attempts is displayed."
79627965
},
@@ -8191,10 +8194,6 @@
81918194
"context": "Shown when shipping zone count cannot be determined",
81928195
"string": "Shipping zones: Unknown"
81938196
},
8194-
"j/vV0n": {
8195-
"context": "channel name",
8196-
"string": "Channel Name"
8197-
},
81988197
"j08fR9": {
81998198
"context": "Product collections",
82008199
"string": "Collections"

src/channels/pages/ChannelsListPage/ChannelsListPage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ const ChannelsListPage = ({ channelsList, limits, onRemove }: ChannelsListPagePr
8383
<TableHead>
8484
<TableRowLink>
8585
<TableCellHeader>
86-
<FormattedMessage
87-
id="j/vV0n"
88-
defaultMessage="Channel Name"
89-
description="channel name"
90-
/>
86+
<FormattedMessage id="hh0xW7" defaultMessage="Channel Name" />
9187
</TableCellHeader>
9288
<TableCell />
9389
</TableRowLink>

src/components/CountryList/CountryList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ChevronDownIcon, Trash2 } from "lucide-react";
1212
import * as React from "react";
1313
import { FormattedMessage } from "react-intl";
1414

15-
import { getStringOrPlaceholder } from "../../misc";
1615
import { DashboardCard } from "../Card";
1716
import { groupCountriesByStartingLetter } from "./utils";
1817

@@ -109,7 +108,7 @@ const CountryList = (props: CountryListProps) => {
109108
defaultMessage="{count, plural, one {# Country} other {# Countries}}"
110109
description="number of countries"
111110
values={{
112-
number: getStringOrPlaceholder(countries?.length.toString()),
111+
count: countries?.length ?? 0,
113112
}}
114113
/>
115114
</TableCell>

src/components/ResponsiveTable/ResponsiveTable.tsx

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1+
import useDebounce from "@dashboard/hooks/useDebounce";
12
import { Table } from "@material-ui/core";
23
import { Box, SearchInput, Text } from "@saleor/macaw-ui-next";
34
import clsx from "clsx";
45
import { X } from "lucide-react";
5-
import { useEffect, useRef, useState } from "react";
6+
import { ChangeEvent, KeyboardEvent, ReactNode, useState } from "react";
67
import { FormattedMessage } from "react-intl";
78

89
import { iconSize, iconStrokeWidthBySize } from "../icons";
910
import styles from "./ResponsiveTable.module.css";
1011

1112
interface ResponsiveTableProps {
12-
children: React.ReactNode | React.ReactNodeArray;
13+
children: ReactNode | ReactNode[];
1314
className?: string;
1415
onMouseLeave?: () => void;
1516
key?: string;
1617
search?: {
1718
placeholder?: string;
1819
initialValue?: string;
1920
onSearchChange?: (query: string) => void;
20-
toolbar?: React.ReactNode;
21+
toolbar?: ReactNode;
2122
};
22-
footer?: React.ReactNode;
23+
footer?: ReactNode;
2324
/** When 0 and search is active, shows "no results" state */
2425
filteredItemsCount?: number;
2526
}
@@ -30,47 +31,32 @@ export const ResponsiveTable = (props: ResponsiveTableProps) => {
3031

3132
const isSearchActive = searchValue.length > 0;
3233
const showFilteredEmptyState = isSearchActive && filteredItemsCount === 0;
33-
const debounceRef = useRef<NodeJS.Timeout | null>(null);
3434

35-
const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {
35+
const debouncedOnSearchChange = useDebounce((value: string) => {
36+
search?.onSearchChange?.(value);
37+
}, 300);
38+
39+
const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
3640
const value = e.target.value;
3741

3842
setSearchValue(value);
3943

4044
if (search?.onSearchChange) {
41-
if (debounceRef.current) {
42-
clearTimeout(debounceRef.current);
43-
}
44-
45-
debounceRef.current = setTimeout(() => {
46-
search.onSearchChange?.(value);
47-
}, 300);
45+
debouncedOnSearchChange(value);
4846
}
4947
};
5048

5149
const clearSearch = () => {
5250
setSearchValue("");
5351
search?.onSearchChange?.("");
54-
55-
if (debounceRef.current) {
56-
clearTimeout(debounceRef.current);
57-
}
5852
};
5953

60-
const handleSearchKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
54+
const handleSearchKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
6155
if (e.key === "Escape") {
6256
clearSearch();
6357
}
6458
};
6559

66-
useEffect(() => {
67-
return () => {
68-
if (debounceRef.current) {
69-
clearTimeout(debounceRef.current);
70-
}
71-
};
72-
}, []);
73-
7460
return (
7561
<div className={styles.container}>
7662
<div className={styles.wrapper}>

0 commit comments

Comments
 (0)