Fix minor bugs
This commit is contained in:
parent
186b373821
commit
45497e0d7d
4 changed files with 20 additions and 14 deletions
|
@ -22,7 +22,7 @@ const useStyles = makeStyles(
|
||||||
display: "inline-block"
|
display: "inline-block"
|
||||||
},
|
},
|
||||||
tabActionContainer: {
|
tabActionContainer: {
|
||||||
borderBottom: "1px solid #e8e8e8",
|
borderBottom: `1px solid ${theme.palette.divider}`,
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "flex-end",
|
justifyContent: "flex-end",
|
||||||
marginTop: theme.spacing.unit,
|
marginTop: theme.spacing.unit,
|
||||||
|
|
|
@ -64,6 +64,9 @@ const FilterBar: React.FC<FilterBarProps> = ({
|
||||||
return (
|
return (
|
||||||
<FilterChips
|
<FilterChips
|
||||||
currencySymbol={currencySymbol}
|
currencySymbol={currencySymbol}
|
||||||
|
displayTabAction={
|
||||||
|
!!initialSearch ? (isCustom ? "save" : "delete") : null
|
||||||
|
}
|
||||||
menu={filterMenu}
|
menu={filterMenu}
|
||||||
filtersList={filtersList}
|
filtersList={filtersList}
|
||||||
filterLabel={filterLabel}
|
filterLabel={filterLabel}
|
||||||
|
|
|
@ -23,9 +23,7 @@ const SearchBar: React.FC<SearchBarProps> = props => {
|
||||||
onTabDelete,
|
onTabDelete,
|
||||||
onTabSave
|
onTabSave
|
||||||
} = props;
|
} = props;
|
||||||
const [search, setSearch] = React.useState(initialSearch);
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
React.useEffect(() => setSearch(initialSearch), [initialSearch]);
|
|
||||||
|
|
||||||
const isCustom = currentTab === tabs.length + 1;
|
const isCustom = currentTab === tabs.length + 1;
|
||||||
|
|
||||||
|
@ -50,7 +48,9 @@ const SearchBar: React.FC<SearchBarProps> = props => {
|
||||||
)}
|
)}
|
||||||
</FilterTabs>
|
</FilterTabs>
|
||||||
<FilterSearch
|
<FilterSearch
|
||||||
displaySearchAction={!!search ? (isCustom ? "save" : "delete") : null}
|
displaySearchAction={
|
||||||
|
!!initialSearch ? (isCustom ? "save" : "delete") : null
|
||||||
|
}
|
||||||
initialSearch={initialSearch}
|
initialSearch={initialSearch}
|
||||||
searchPlaceholder={searchPlaceholder}
|
searchPlaceholder={searchPlaceholder}
|
||||||
onSearchChange={onSearchChange}
|
onSearchChange={onSearchChange}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const useStyles = makeStyles(
|
||||||
justifyContent: "space-around",
|
justifyContent: "space-around",
|
||||||
margin: `0 ${theme.spacing.unit * 2}px ${theme.spacing.unit}px`,
|
margin: `0 ${theme.spacing.unit * 2}px ${theme.spacing.unit}px`,
|
||||||
marginLeft: 0,
|
marginLeft: 0,
|
||||||
padding: "0 16px"
|
padding: `0 ${theme.spacing.unit * 2}px`
|
||||||
},
|
},
|
||||||
filterChipContainer: {
|
filterChipContainer: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
@ -76,6 +76,7 @@ const useStyles = makeStyles(
|
||||||
);
|
);
|
||||||
|
|
||||||
interface FilterChipProps extends FilterActionsProps {
|
interface FilterChipProps extends FilterActionsProps {
|
||||||
|
displayTabAction: "save" | "delete" | null;
|
||||||
filtersList: Filter[];
|
filtersList: Filter[];
|
||||||
search: string;
|
search: string;
|
||||||
isCustomSearch: boolean;
|
isCustomSearch: boolean;
|
||||||
|
@ -85,6 +86,7 @@ interface FilterChipProps extends FilterActionsProps {
|
||||||
|
|
||||||
export const FilterChips: React.FC<FilterChipProps> = ({
|
export const FilterChips: React.FC<FilterChipProps> = ({
|
||||||
currencySymbol,
|
currencySymbol,
|
||||||
|
displayTabAction,
|
||||||
filtersList,
|
filtersList,
|
||||||
menu,
|
menu,
|
||||||
filterLabel,
|
filterLabel,
|
||||||
|
@ -93,8 +95,7 @@ export const FilterChips: React.FC<FilterChipProps> = ({
|
||||||
search,
|
search,
|
||||||
onFilterAdd,
|
onFilterAdd,
|
||||||
onFilterSave,
|
onFilterSave,
|
||||||
onFilterDelete,
|
onFilterDelete
|
||||||
isCustomSearch
|
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const classes = useStyles({ theme });
|
const classes = useStyles({ theme });
|
||||||
|
@ -127,7 +128,7 @@ export const FilterChips: React.FC<FilterChipProps> = ({
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{isCustomSearch ? (
|
{displayTabAction === "save" ? (
|
||||||
<Link onClick={onFilterSave}>
|
<Link onClick={onFilterSave}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Save Custom Search"
|
defaultMessage="Save Custom Search"
|
||||||
|
@ -135,12 +136,14 @@ export const FilterChips: React.FC<FilterChipProps> = ({
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
|
displayTabAction === "delete" && (
|
||||||
<Link onClick={onFilterDelete}>
|
<Link onClick={onFilterDelete}>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
defaultMessage="Delete Search"
|
defaultMessage="Delete Search"
|
||||||
description="button"
|
description="button"
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link>
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|
Loading…
Reference in a new issue