Skip to content

Commit

Permalink
fix(client): app bar navigation for non admin, delete hover button re…
Browse files Browse the repository at this point in the history
…st props
  • Loading branch information
Jozwiaczek committed Sep 7, 2021
1 parent 81c39e9 commit d6c1812
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/elements/AppBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const AppBar = ({ tabs = defaultTabs }: AppBarProps) => {

const handleChange = (event: MouseEvent, newValue: number) => {
setActiveTab(newValue);
const selectedTab = tabs.find(
const selectedTab = sortedItems.find(
(tab) => newValue === (isMobile ? tab.indexMobile ?? tab.index : tab.index),
);
if (selectedTab) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/elements/buttons/CloseButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const CloseButton = ({
}: CloseButtonProps) => (
<StyledButton
data-testid="closeButton"
{...rest}
color={color}
hoverColor={hoverColor}
size={size}
{...rest}
>
<LeftRight />
<RightLeft />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { Meta, Story } from '@storybook/react/types-6-0';
import React from 'react';

import DeleteHoverButton from '.';
import { DeleteHoverButtonProps } from './DeleteHoverButton.types';

export default {
title: 'Elements/buttons/Delete Hover Button',
component: DeleteHoverButton,
} as Meta;

const Template: Story = (args) => <DeleteHoverButton {...args} />;
const Template: Story<DeleteHoverButtonProps> = (args) => <DeleteHoverButton {...args} />;

export const Default = Template.bind({});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ButtonHTMLAttributes } from 'react';

interface DeleteHoverButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
disabled?: boolean;
}
15 changes: 8 additions & 7 deletions packages/client/src/elements/buttons/DeleteHoverButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { ButtonHTMLAttributes } from 'react';
import { useTranslation } from 'react-i18next';

import { TrashIcon } from '../../../icons';
import { StyledButton } from './DeleteHoverButton.styled';
import { DeleteHoverButtonProps } from './DeleteHoverButton.types';

interface DeleteHoverButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
disabled?: boolean;
}

const DeleteHoverButton = ({ disabled }: DeleteHoverButtonProps) => {
const DeleteHoverButton = ({ disabled, ...rest }: DeleteHoverButtonProps) => {
const { t } = useTranslation();

return (
<StyledButton data-testid="delete-hover-button" colorVariant="red" disabled={disabled}>
<StyledButton
data-testid="delete-hover-button"
{...rest}
colorVariant="red"
disabled={disabled}
>
<p>{t('actions.delete')}</p>
<TrashIcon />
</StyledButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const Tab = ({
tabRef.current?.scrollIntoView({ behavior: 'smooth', inline: 'nearest', block: 'nearest' });
}
};

const isActive = value === index;

let width = variant === 'fullWidth' ? '100%' : `${tabWidth}px`;
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/authorized/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const History = () => {
return `${firstName} ${lastName}`;
}}
/>
<DateField label="routes.history.date" source="createdAt" showTime />
<DateField label="history.date" source="createdAt" showTime />
<FunctionField<ApiHistoryRecord>
label="routes.history.event"
label="history.event"
render={({ event }) => mapHistoryEventToLabel(event)}
/>
</DetailedList>
Expand Down

0 comments on commit d6c1812

Please sign in to comment.