Skip to content

Commit

Permalink
fix: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-ae committed Jan 31, 2024
2 parents f8794be + 5afeeea commit 9597bab
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Header Component', () => {

const StartDate30 = today.clone().subtract(30, 'days');
expect(monthElement).toHaveTextContent(
`${StartDate30.format('DD MMM YYYY')} - ${expectedEndDate.format('DD MMM YYYY')}`
`${StartDate30.format('DD MMM')} - ${expectedEndDate.format('DD MMM YYYY')}`
);

act(() => {
Expand Down
105 changes: 47 additions & 58 deletions src/pages/tickets/org/orgHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef, useMemo } from 'react';
import styled from 'styled-components';
import { EuiCheckboxGroup, EuiPopover, EuiText } from '@elastic/eui';
import MaterialIcon from '@material/react-material-icon';
Expand Down Expand Up @@ -159,13 +159,6 @@ const SearchBar = styled.input`
border: none;
`;

const SoryByContainer = styled.span`
padding: 10px 0px;
display: flex;
justify-content: center;
align-items: center;
`;

const NumberOfBounties = styled.div`
height: 23px;
padding: 1.5px 983.492px 1.5px 10px;
Expand Down Expand Up @@ -285,12 +278,6 @@ const DropDownButton = styled.button`
padding-top: 5px;
`;

const FiltersLeft = styled.span`
display: flex;
height: 40px;
align-items: flex-start;
`;

const EuiPopOverCheckbox = styled.div<styledProps>`
width: 147px;
height: auto;
Expand Down Expand Up @@ -412,17 +399,18 @@ const StatusContainer = styled.div<styledProps>`
`;

const Status = ['Open', 'Assigned', 'Completed', 'Paid'];
const sortByArr = [{
id: "desc",
label: 'Newest First'
},
{
id: "asc",
label: "Oldest First"
}
]

const color = colors['light'];
const sortDirectionOptions = [
{
id: 'desc',
label: 'Newest First'
},
{
id: 'asc',
label: 'Oldest First'
}
];

export const OrgHeader = ({
onChangeLanguage,
checkboxIdToSelectedMapLanguage,
Expand All @@ -436,14 +424,19 @@ export const OrgHeader = ({
const [isPostBountyModalOpen, setIsPostBountyModalOpen] = useState(false);
const [filterClick, setFilterClick] = useState(false);
const [isStatusPopoverOpen, setIsStatusPopoverOpen] = useState<boolean>(false);
const [isSortByPopoverOpen, setIsSortByPopoverOpen] = useState(false)
const [sortBy, setSortBy] = useState<string>("desc")
const [isSortByPopoverOpen, setIsSortByPopoverOpen] = useState(false);
const [sortDirection, setSortDirection] = useState<string>('desc');

const onButtonClick = async () => {
setIsStatusPopoverOpen((isPopoverOpen: any) => !isPopoverOpen);
};
const closeStatusPopover = () => setIsStatusPopoverOpen(false);

const sortDirectionLabel = useMemo(
() => (sortDirection === 'asc' ? 'Oldest First' : 'Newest First'),
[sortDirection]
);

const onSortButtonClick = async () => {
setIsSortByPopoverOpen((isPopoverOpen: any) => !isPopoverOpen);
};
Expand Down Expand Up @@ -474,10 +467,10 @@ export const OrgHeader = ({
resetPage: true,
...checkboxIdToSelectedMap,
languageString,
direction: sortBy
direction: sortDirection
});
}
}, [org_uuid, checkboxIdToSelectedMap, sortBy, main, languageString]);
}, [org_uuid, checkboxIdToSelectedMap, sortDirection, main, languageString]);

const handleClick = () => {
setFilterClick(!filterClick);
Expand All @@ -497,7 +490,7 @@ export const OrgHeader = ({
return () => {
window.removeEventListener('click', handleWindowClick);
};
}, [filterClick]);
}, [org_uuid, checkboxIdToSelectedMap, languageString, main, filterClick]);

return (
<>
Expand Down Expand Up @@ -574,7 +567,7 @@ export const OrgHeader = ({
<div
style={{
display: 'flex',
flexDirection: 'row'
flex: 'row'
}}
>
<EuiPopOverCheckbox className="CheckboxOuter" color={color}>
Expand Down Expand Up @@ -619,20 +612,20 @@ export const OrgHeader = ({
<Icon src={searchIcon} alt="Search" />
</SearchWrapper>
</FiltersRight>
<SoryByContainer>
<EuiPopover
<EuiPopover
button={
<StatusContainer onClick={onSortButtonClick} className="CheckboxOuter" color={color}>
<div style={{minWidth: '145px'}}>
<div style={{ minWidth: '145px' }}>
<EuiText
className="statusText"
style={{
color: isSortByPopoverOpen ? color.grayish.G10 : ''
}}>
Sort By: {sortBy === "asc" ? "Oldest First" : "Newest First"}
</EuiText>
className="statusText"
style={{
color: isSortByPopoverOpen ? color.grayish.G10 : ''
}}
>
Sort By: {sortDirectionLabel}
</EuiText>
</div>

<div className="filterStatusIconContainer">
<MaterialIcon
className="materialStatusIcon"
Expand All @@ -659,25 +652,21 @@ export const OrgHeader = ({
panelPaddingSize="none"
anchorPosition="downLeft"
>
<div
style={{
display: 'flex',
flexDirection: 'row'
}}
>
<EuiPopOverCheckbox className="CheckboxOuter" color={color}>
<EuiCheckboxGroup
style={{}}
options={sortByArr}
idToSelectedMap={{[sortBy]: true}}
onChange={(id: any) => {
onChangeStatus(setSortBy(id));
}}
/>
</EuiPopOverCheckbox>
</div>
<div
style={{
display: 'flex',
flexDirection: 'row'
}}
>
<EuiPopOverCheckbox className="CheckboxOuter" color={color}>
<EuiCheckboxGroup
options={sortDirectionOptions}
idToSelectedMap={{ [sortDirection]: true }}
onChange={(id: string) => setSortDirection(id)}
/>
</EuiPopOverCheckbox>
</div>
</EuiPopover>
</SoryByContainer>
</Filters>
</FillContainer>
<NumberOfBounties>
Expand Down
1 change: 1 addition & 0 deletions src/people/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface BountyModalProps {

export interface OrgBountyHeaderProps {
organizationUrls: any;
direction?: string;
}

export interface FocusViewProps {
Expand Down
4 changes: 3 additions & 1 deletion src/people/widgetViews/__tests__/OrgHeader.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const MockProps: OrgBountyHeaderProps = {
Completed: false
},
languageString: '',
direction: 'desc',
org_uuid: 'clf6qmo4nncmf23du7ng',
onChangeStatus: jest.fn(),
onChangeLanguage: jest.fn(),
Expand Down Expand Up @@ -67,7 +68,8 @@ describe('OrgHeader Component', () => {

const updatedCheckboxIdToSelectedMap = {
...MockProps.checkboxIdToSelectedMap,
Open: true
Open: true,
direction: 'desc'
};

rerender(
Expand Down

0 comments on commit 9597bab

Please sign in to comment.