Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit List View #102

Merged
merged 28 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3509664
implement initial route
PoliteUnicorn Apr 9, 2024
90f1c0a
Merge remote-tracking branch 'origin/main' into karen/demote-user-route
PoliteUnicorn Apr 10, 2024
16ede2d
fixed paginator
PoliteUnicorn Apr 24, 2024
31c6c1b
hover effect
PoliteUnicorn Apr 24, 2024
40defd7
fix lint errors
PoliteUnicorn Apr 24, 2024
e2a8aed
added pop-ups
PoliteUnicorn Apr 24, 2024
3276409
fixed lint errors
PoliteUnicorn Apr 30, 2024
f6e95cd
merging with main
PoliteUnicorn Apr 30, 2024
e97fff2
fix name issue
PoliteUnicorn May 8, 2024
97d00c3
Update frontend/src/pages/Profile.tsx
PoliteUnicorn May 8, 2024
78310dc
removed setallhousinglocators
PoliteUnicorn May 8, 2024
b6adff7
added paginator
PoliteUnicorn May 15, 2024
522a5c1
update
PoliteUnicorn May 15, 2024
838b476
cosmetic changes
PoliteUnicorn May 22, 2024
2daafb4
change all paginators
PoliteUnicorn May 22, 2024
30f20af
border to available and pending
PoliteUnicorn May 22, 2024
b747b00
more details
PoliteUnicorn May 22, 2024
c3095ac
trying to merge
PoliteUnicorn May 22, 2024
4083eea
fixed all paginators
PoliteUnicorn May 22, 2024
53c7c07
fix font
PoliteUnicorn May 22, 2024
ef333a9
Update frontend/src/components/ReferralTable.tsx
PoliteUnicorn May 29, 2024
fd78c80
fix changes
PoliteUnicorn May 29, 2024
dcf11b9
center aligned
PoliteUnicorn Jun 3, 2024
d48dc20
Merge remote-tracking branch 'refs/remotes/origin/karen/unit-list-vie…
PoliteUnicorn Jun 3, 2024
a6a1c9a
Merge remote-tracking branch 'origin/main' into karen/unit-list-view
petabite Jun 4, 2024
4596955
refactor
petabite Jun 4, 2024
6f9e8ad
fix routing
petabite Jun 4, 2024
f6decbc
remove pendingSelected state
petabite Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified frontend/bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions frontend/public/Group.svg
PoliteUnicorn marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/card_view_icon_selected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/card_view_icon_unselected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/list_view_icon_selected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/public/list_view_icon_unselected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions frontend/src/components/HousingLocatorTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from "react";
import styled from "styled-components";

import { Button } from "./Button";
import { TablePagination } from "./TablePagination";
import { Pagination } from "./Pagination";

import { User, demoteUser } from "@/api/users";
import { DataContext } from "@/contexts/DataContext";
Expand Down Expand Up @@ -68,9 +68,19 @@ const HLRow = styled.div`
margin-bottom: 20px;
`;

const HLTableFooterWrapper = styled.div`
display: flex;
flex-direction: row;
margin-right: 24px;
margin-bottom: 20px;
justify-content: right;
`;

const HLTableFooter = styled.div`
padding-left: 85%;
margin: 1vh 0vw 3vh 0vw;
display: flex;
flex-direction: row;

justify-content: space-between;
`;

const Overlay = styled.div`
Expand Down Expand Up @@ -219,6 +229,15 @@ export const HousingLocatorTable = () => {
></DeleteIcon>
</HLRow>
))}
<HLTableFooterWrapper>
<HLTableFooter>
<Pagination
totalPages={Math.ceil(housingLocators.length / ENTRIES_PER_PAGE)}
currPage={pageNumber}
setPageNumber={setPageNumber}
/>
</HLTableFooter>
</HLTableFooterWrapper>
</HLTableContainer>
{popup && selectedUser && (
<>
Expand Down Expand Up @@ -303,13 +322,6 @@ export const HousingLocatorTable = () => {
</Modal>
</>
)}
<HLTableFooter>
<TablePagination
totalPages={Math.ceil(housingLocators.length / ENTRIES_PER_PAGE)}
currPage={pageNumber}
setPageNumber={setPageNumber}
/>
</HLTableFooter>
</HLTableWrapper>
);
};
216 changes: 216 additions & 0 deletions frontend/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
import styled from "styled-components";

const NumPageButton = styled.button`
width: 25px;
height: 24px;
border-radius: 4px;
border: 1px solid #eeeeee;
opacity: 0px;
background: #f5f5f5;
align-content: center;

&:hover {
cursor: pointer;
background: #f5f5f5;
}

&.active {
background: #ec8537;
color: #ffffff;
border-color: #ec8537;
}
`;

const ButtonWrapper = styled.div`
display: flex;
flex-direction: row;
//width: 341.87px;
height: 24px;
justify-content: space-between;
gap: 20px;
opacity: 0px;
`;

const NavButton = styled(NumPageButton)``;

const NavButtonIcon = styled.img`
width: 24px;
height: 24px;
flex-shrink: 0;
border-radius: 4px;
border: 0;
`;

const EllipsesWrapper = styled.div`
width: 24px;
height: 24px;
`;

type PaginationProps = {
totalPages: number;
currPage: number;
setPageNumber: (newPageNumber: number) => void;
};

const BUTTONS_PER_PAGE = 5;

export const Pagination = (props: PaginationProps) => {
const pages = [];

const handleClick = (increase: boolean): void => {
if (increase && props.currPage !== props.totalPages) {
props.setPageNumber(props.currPage + 1);
}

if (!increase && props.currPage > 1) {
props.setPageNumber(props.currPage - 1);
}
};

//case 1: num pages < buttons per page -> show all
if (props.totalPages <= BUTTONS_PER_PAGE) {
for (let i = 1; i <= props.totalPages; i++) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
}
}
//case 2: on page 1-3 -> show first 4 ... and last
else if (props.currPage <= BUTTONS_PER_PAGE - 2) {
for (let i = 1; i <= props.totalPages; i++) {
//add button for first three pages
if (i <= BUTTONS_PER_PAGE - 1) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
} else if (i === props.totalPages) {
pages.push(<EllipsesWrapper>...</EllipsesWrapper>);
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
}
}
}
//case 3: on page end - 4 + 1-> show first ... last 4
else if (props.currPage > props.totalPages - BUTTONS_PER_PAGE + 2) {
//add button for first three pages
for (let i = 1; i <= props.totalPages; i++) {
if (i >= props.totalPages - BUTTONS_PER_PAGE + 2) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
} else if (i === 1) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
pages.push(<EllipsesWrapper>...</EllipsesWrapper>);
}
}
}
//case 4: middle -> show first ... middle - 1, middle, middle + 1, ... last
else {
for (let i = 1; i <= props.totalPages; i++) {
if (i === 1) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
pages.push(<EllipsesWrapper>...</EllipsesWrapper>);
} else if (i === props.currPage - 1 || i === props.currPage || i === props.currPage + 1) {
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
} else if (i === props.totalPages) {
pages.push(<EllipsesWrapper>...</EllipsesWrapper>);
pages.push(
<NumPageButton
key={i}
onClick={() => {
props.setPageNumber(i);
}}
className={props.currPage === i ? "active" : ""}
>
{i}
</NumPageButton>,
);
}
}
}

return (
<ButtonWrapper>
<NavButton>
<NavButtonIcon
src={"/ic_caretleft.svg"}
onClick={() => {
handleClick(false);
}}
/>
</NavButton>
{pages}
<NavButton>
<NavButtonIcon
src={"/ic_caretright.svg"}
onClick={() => {
handleClick(true);
}}
/>
</NavButton>
</ButtonWrapper>
);
};
1 change: 1 addition & 0 deletions frontend/src/components/ReferralTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useContext, useState } from "react";
import { Link } from "react-router-dom";
import styled from "styled-components";
// import { Pagination } from "./Pagination";
PoliteUnicorn marked this conversation as resolved.
Show resolved Hide resolved

import { Button } from "./Button";
import { ReferralTableDropDown } from "./ReferralTableDropDown";
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import styled from "styled-components";

import { TablePagination } from "./TablePagination";
import { Pagination } from "./Pagination";

const TableContainer = styled.div`
display: flex;
Expand Down Expand Up @@ -43,6 +43,9 @@ const TableCell = styled.div`
`;

const TableFooter = styled.div`
display: flex;
flex-direction: row;
justify-content: right;
padding-top: 20px;
`;

Expand Down Expand Up @@ -82,7 +85,7 @@ export const Table = (props: TableProps) => {
))}
<TableFooter>
{/* TODO: Replace this with new pagination when it is implemented */}
<TablePagination
<Pagination
PoliteUnicorn marked this conversation as resolved.
Show resolved Hide resolved
totalPages={Math.ceil(rows.length / rowsPerPage)}
currPage={pageNumber}
setPageNumber={setPageNumber}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/UnitCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const RentText = styled(UnitCardText)`
font-weight: 700;
line-height: 121%;
letter-spacing: 0.331px;
font-family: Inter;
font-family: "Neutraface Text";
`;

const AddressText = styled(UnitCardText)`
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/UnitCardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { UnitCard } from "@/components/UnitCard";
import { DataContext } from "@/contexts/DataContext";

const UnitCardLayout = styled.div`
// margin: 95px;
display: flex;
flex-direction: row;
flex-wrap: wrap;
Expand Down Expand Up @@ -42,8 +41,8 @@ const GridContainer = styled.div`
const ButtonsWrapper = styled.div`
display: flex;
flex-direction: row;
left: 74vw;
position: absolute;
left: 69vw;
`;

const PendingButton = styled.div<{ selected: boolean }>`
Expand Down
Loading
Loading