Skip to content

Commit

Permalink
add editing rank to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
radekm2000 committed May 16, 2024
1 parent 9906f47 commit ac94302
Show file tree
Hide file tree
Showing 7 changed files with 243 additions and 58 deletions.
168 changes: 115 additions & 53 deletions client/ecommerce/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/ecommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@mui/icons-material": "^5.15.1",
"@mui/joy": "^5.0.0-beta.19",
"@mui/material": "^5.15.1",
"@mui/x-data-grid": "^7.4.0",
"@stripe/react-stripe-js": "^2.4.0",
"@stripe/stripe-js": "^2.4.0",
"@tanstack/react-query": "^5.14.2",
Expand Down
7 changes: 7 additions & 0 deletions client/ecommerce/src/api/axios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,3 +360,10 @@ export const fetchUsers = async () => {
const response = await axiosApi.get<UserWithAvatar[]>("users");
return response.data;
};

export const grantAdminRoleFor = async (
userId: number
): Promise<MutationData> => {
const response = await axiosApi.patch(`users/grantAdmin/${userId}`);
return response.data;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import { Box, Divider } from "@mui/material";
import { UserWithAvatar } from "../../../types/types";
import { PersonCard } from "./PersonCard";
import { useDisplayPplWithoutMe } from "../../../utils/DisplayPplWithoutMe";
import React from "react";

type Props = {
users: UserWithAvatar[];
};

export const PeopleList = ({ users }: Props) => {
const filteredUsers = useDisplayPplWithoutMe(users);

return (
<Box sx={{ display: "flex", flexDirection: "column", gap: "10px" }}>
{filteredUsers.map((user) => (
<>
{filteredUsers.map((user, index) => (
<React.Fragment key={index}>
<PersonCard user={user} />
<Divider />
</>
</React.Fragment>
))}
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ import { Box, Button, Card, CardMedia, Typography } from "@mui/material";
import { UserWithAvatar } from "../../../types/types";
import { RenderAvatar } from "../../RenderAvatar";
import { useDisplayPplWithoutMe } from "../../../utils/DisplayPplWithoutMe";
import { useState } from "react";
import { PersonEditDialog } from "./PersonEditDialog";

type Props = {
user: UserWithAvatar;
};

export const PersonCard = ({ user }: Props) => {
const [dialogOpen, setDialogOpen] = useState(false);

const handleDialogOpen = () => setDialogOpen(true);
const handleDialogClose = () => setDialogOpen(false);
return (
<Box>
<Box sx={{ display: "flex", gap: "10px", justifyContent: 'center', alignItems: 'center' }}>
<Box
sx={{
display: "flex",
gap: "10px",
justifyContent: "center",
alignItems: "center",
}}
>
<RenderAvatar user={user} height="48px" width="48px" />
<Box sx={{ display: "flex", flexDirection: "column" }}>
<Typography>{user.username}</Typography>
Expand All @@ -20,7 +33,13 @@ export const PersonCard = ({ user }: Props) => {
</Box>

<Box sx={{ marginLeft: "auto" }}>
<Button sx={{ textTransform: "none", color: '#007782' }}>Edit</Button>
<Button
onClick={handleDialogOpen}
sx={{ textTransform: "none", color: "#007782" }}
>
Edit
</Button>
<PersonEditDialog open={dialogOpen} handleClose={handleDialogClose} user={user}/>
</Box>
</Box>
</Box>
Expand Down
Loading

0 comments on commit ac94302

Please sign in to comment.