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

feat/developer search paginate #13

Merged
merged 43 commits into from
Jun 20, 2023
Merged

Conversation

SebassNoob
Copy link
Collaborator

This PR adds search and pagination to the /developer page.

This PR may cause a merge conflict with #12 if both are approved, which I will fix if a conflict is present :).

@SebassNoob SebassNoob added the enhancement New feature or request label Jun 15, 2023
</TableCell>
</TableRow>
<TablePagination
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we already have a Pagination component? Use that instead. Don't rewrite a new component that does the same thing

@@ -12,9 +12,12 @@ import {
TableContainer,
TableHead,
TableRow,
OutlinedInput,
TablePagination,
} from "@mui/material";
import EditIcon from "@mui/icons-material/Edit";
import React from "react";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think can just import what you need like ChangeEvent, no need React.ChangeEvent

holy-grail-frontend/src/features/Developer/TabContent.tsx Outdated Show resolved Hide resolved
const handleEditClick = (id: number) => {
handleEdit(id, type);
};

//filter data based on query
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need comment for self-evident code, just rename the function to something clearer like filterContent or something

@@ -65,7 +128,10 @@ export const TabContent = ({
</TableRow>
))}
</TableBody>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remember to use yarn format before pushing

@SebassNoob SebassNoob force-pushed the feat/developer-search-paginate branch from 66be574 to 6a00261 Compare June 17, 2023 09:07
interface PaginationProps {
pageInfo: { page: number; size: number; total: number; pages: number };
handlePageChange: (newPage: number) => void;
HStackStyles?: HStackStyles;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this optional parameter to customise Hstack properties

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no need ba, just straight away pass it in, this one abit verbose since you can just pass into HStack straight

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure what you mean, but i dont think i can pass styles into Hstack directly via the pagination component. hence the reasoning for this addition

return validData;
};

//paginate data into chunks
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the comment alr

<TableCell colSpan={2}>
<ChakraProvider>
<Pagination
// page is 0 indexed, but Pagination component is 1 indexed
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to comment for this

interface HStackStyles {
spacing?: number;
mt?: string;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you yarn format?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep i did

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok nvm, i think is some inconsistent styling, usually it should have at least some space in between different code component

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this new interface, remove HStackStyles from PaginationProps, Allow Pagination to take in new prop styles

const debouncedHandlePageChange = debounce(handlePageChange, 100);

return (
<HStack spacing={4} justifyContent="center" mt="10%">
<HStack
spacing={HStackStyles?.spacing ? HStackStyles.spacing : 4}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a new data structure just to do spacing for hstacks? just declare the values by itself here lo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just dont want to break anything, so previous implementations have a default value of 4

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea you can just pass in directly and do a conditional for default spacing 4 if spacing doesn't exist here, no need for new interface just to pass this in

also make sure that when you change screen components this way, it doesn't mess up the mobile design because its supposed to be responsive

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pagination should be consistent throughout, just keep it as 4

@@ -12,9 +12,13 @@ import {
TableContainer,
TableHead,
TableRow,
OutlinedInput,
TablePagination,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need this import?

} from "@mui/material";
import EditIcon from "@mui/icons-material/Edit";
import React from "react";
import React, { useState, ChangeEvent, MouseEvent } from "react";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove react also right?

<HStack
spacing={HStackStyles?.spacing ? HStackStyles.spacing : 4}
justifyContent="center"
mt={HStackStyles?.mt ? HStackStyles.mt : "10%"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after adding styles prop just change to mt={styles?.mt ? styles.mt : "10%"}

imo this 10% warrants a review but just do ^ first

handlePageChange={(newPage: number) => {
setPage(newPage - 1);
}}
HStackStyles={{ spacing: 10, mt: "0%" }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can styles={{ mt: "0%" }} after everything above

@ddaarrrryyll
Copy link
Collaborator

ddaarrrryyll commented Jun 18, 2023

other than the comments everything else lgtm

chakra needs to be migrated to mui but that can be done another time when we do a clean up after we merge the new FE in

@ddaarrrryyll ddaarrrryyll merged commit 483caaf into dev Jun 20, 2023
@SebassNoob SebassNoob deleted the feat/developer-search-paginate branch June 21, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants