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

Feature/crud user #35

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open

Feature/crud user #35

wants to merge 44 commits into from

Conversation

binhtt13122000
Copy link
Collaborator

@binhtt13122000 binhtt13122000 commented Aug 23, 2021

@binhtt13122000 binhtt13122000 added the ready for review PR is ready to be reviewed label Aug 23, 2021
Copy link
Collaborator

@zKirinz zKirinz left a comment

Choose a reason for hiding this comment

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

Cool ^^

<BoxBase pt={2} width={1} display="flex" justifyContent="flex-end">
<BoxBase mr={1}>
<ButtonBase
onClick={() => userProps.onUpdate(userProps.userId)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you need to test this behavior so as to get full coverage, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image
now, test coverages 100%, thank for your help!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool 🔥

interface IUpSertPageProps {
userProps?: IUser;
isUpdate: boolean;
sendDatatoServer: (user: IUser) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should be "sendDataToServer"

}}
src={user.avatar || anonymousAvatarLink}
style={avatarStyle}
/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should use AvatarBase component instead of img tag. AvatarBase already has a BoxBase outside of it. You can easily custom it to fit your need.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok I will do it to reuse

Copy link
Collaborator

@zKirinz zKirinz left a comment

Choose a reason for hiding this comment

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

Great work! But it will be better to have a record of live demo and the stories, don't you think?

const AlertBase = (props: AlertBaseProps) => {
return <MaterialAlert {...props} />;
};
const AlertBase = React.forwardRef(function AlertBase(props: AlertBaseProps, ref) {
Copy link
Owner

Choose a reason for hiding this comment

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

Please add generic here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Comment on lines 18 to 19
sizeWidth = null,
sizeHeight = null,
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 we should set a default size here

Copy link
Owner

Choose a reason for hiding this comment

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

Or you can force these props in the interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image
I will ignore they in the interface

export interface SlideBaseProps extends MaterialSlideProps {}

const SlideBase = React.forwardRef((props: SlideBaseProps, ref) => {
return <MaterialSlide ref={ref} {...props} mountOnEnter unmountOnExit />;
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 we should give other devs ways to customize mount behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image


export interface SlideBaseProps extends MaterialSlideProps {}

const SlideBase = React.forwardRef((props: SlideBaseProps, ref) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Please add generic here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image
I choose generic for Ref is unknown because it is set Ref in the root source.

render(<UserCard {...props} />);
const UserCardButtons = screen.getByTestId("UserCard__buttons").querySelectorAll("button");
const UpdateButton = UserCardButtons[0];
fireEvent.click(UpdateButton!);
Copy link
Owner

Choose a reason for hiding this comment

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

Are you sure you don't need to await this?

Copy link
Collaborator Author

@binhtt13122000 binhtt13122000 Aug 29, 2021

Choose a reason for hiding this comment

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

I think await is not need, because in this code, click is set updatedId = userId. This action is not needed waiting for time to test so await is not need in this test


export const anonymousAvatarLink =
"https://cdn1.vectorstock.com/i/thumb-large/22/05/male-profile-picture-vector-1862205.jpg";
const UserCard = (userProps: IUserProps) => {
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 we should put user's exclusive components in /pages/user or something

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Copy link
Owner

Choose a reason for hiding this comment

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

@kien123456k hello please help me check again


const sendDataToServer = (user: IUser) => {
mutate({
name: user.name || "",
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 we should validate instead of sending ""

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

src/pages/Users/index.tsx Outdated Show resolved Hide resolved

const useGetUser = (limit: number = 1, offset: number = 0, _ilike: string = "%%") => {
const queryClient = useQueryClient();
const result = useQuery(["GetUsersWithPagingQuery", { limit, offset, _ilike }], async () => {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
const result = useQuery(["GetUsersWithPagingQuery", { limit, offset, _ilike }], async () => {
const result = useQuery(["GetUsersWithPagingQuery", limit, offset, _ilike ], async () => {

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 will change it


const sendDataToServer = (user: IUser) => {
mutate({
name: user.name || "",
Copy link
Owner

Choose a reason for hiding this comment

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

Please validate instead of sending blank to db

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

@binh1298 binh1298 added require adjustment PR needs adjustments and removed ready for review PR is ready to be reviewed labels Aug 29, 2021
zKirinz added 20 commits January 5, 2022 19:12
… DrawerBase, DrawerTriggerButton, ImageBase, ListItemButtonBase and ListBase
@zKirinz zKirinz added ready for review PR is ready to be reviewed and removed require adjustment PR needs adjustments labels Jan 17, 2022
Comment on lines +46 to +48
sx={{
borderRadius: "calc(1rem + 6px)",
}}
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is from the old code of @thienduc12311 to make the styling like in Reply design.

options?: UseMutationOptions<UpdateUserMutation, GraphQLErrorType, UpdateUserMutationVariables>
) => {
return useMutation<UpdateUserMutation, UpdateUserMutationVariables>({
queryKey: ["UpdateUser"],
Copy link
Owner

Choose a reason for hiding this comment

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

this query key is missing something, do you know what it is?

Comment on lines +6 to +7
unmountOnExit?: boolean;
mountOnEnter?: boolean;
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure if it's necessary to add this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, I removed it.

describe("<ButtonGroupBase />", () => {
let props: ButtonGroupBaseProps;

it("should exist children with primary color", () => {
Copy link
Owner

Choose a reason for hiding this comment

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

You're not testing for primary color here but your test says so

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, my bad.

@@ -11,3 +12,11 @@ export type QueryInfo = {
preloadedQuery: PreloadedQuery<OperationType>;
queryObject: any;
};

export interface IUser {
Copy link
Owner

Choose a reason for hiding this comment

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

Not sure why this is necessary?

</TypographyBase>
</BoxBase>
</BoxBase>
<BoxBase width={1} mt={5} display="flex" justifyContent="center" alignItems="center">
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 you should consider use grid for this one right?

@binh1298 binh1298 added require adjustment PR needs adjustments and removed ready for review PR is ready to be reviewed labels Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
require adjustment PR needs adjustments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants