diff --git a/src/components/common/User/UserIOCList.js b/src/components/common/User/UserIOCList.js deleted file mode 100644 index 7fbe2963ac9d95af0628e6425501791111d6deeb..0000000000000000000000000000000000000000 --- a/src/components/common/User/UserIOCList.js +++ /dev/null @@ -1,72 +0,0 @@ -import { useContext } from "react"; -import { Card, CardHeader } from "@mui/material"; -import { useEffect } from "react"; -import { initRequestParams } from "../Helper"; -import IOCTable from "../../IOC/IOCTable"; -import { apiContext } from "../../../api/DeployApi"; -import { useAPIMethod, usePagination } from "@ess-ics/ce-ui-common"; - -export function UserIocList({ userName }) { - const client = useContext(apiContext); - - const { - value: iocs, - wrapper: getIocs, - loading, - dataReady, - abort - } = useAPIMethod({ - fcn: client.apis.IOCs.listIocs, - call: false - }); - - const rowsPerPage = [20, 50]; - const { pagination, setPagination } = usePagination({ - rowsPerPageOptions: rowsPerPage, - initLimit: rowsPerPage[0], - initPage: 0 - }); - - // update pagination whenever search result total pages change - useEffect(() => { - setPagination({ totalCount: iocs?.totalCount ?? 0 }); - }, [setPagination, iocs?.totalCount]); - - // Request more results when pagination changes - useEffect(() => { - let requestParams = initRequestParams(pagination); - - requestParams.created_by = userName; - - getIocs(requestParams); - - return () => { - abort(); - }; - }, [getIocs, pagination, userName, abort]); - - // Invoked by Table on change to pagination - const onPage = (params) => { - setPagination(params); - abort(); - }; - - return ( - <Card variant="plain"> - <CardHeader - title={"IOCs registered"} - titleTypographyProps={{ - variant: "h2", - component: "h2" - }} - /> - <IOCTable - iocs={iocs?.iocList} - loading={loading || !dataReady} - rowType="explore" - pagination={pagination} - onPage={onPage} - /> - </Card> - ); -} diff --git a/src/components/common/User/UserProfile.js b/src/components/common/User/UserProfile.js deleted file mode 100644 index f9f0f58952c006c44b81e0e70cd7c7ec3b60c0a8..0000000000000000000000000000000000000000 --- a/src/components/common/User/UserProfile.js +++ /dev/null @@ -1,41 +0,0 @@ -import { - Avatar, - Card, - CardMedia, - CardContent, - Typography -} from "@mui/material"; - -export function UserProfile({ userInfo }) { - return ( - <Card - variant="plain" - sx={{ display: "flex", flexDirection: "row" }} - > - <CardContent> - <CardMedia> - <Avatar - sx={{ width: 96, height: 96 }} - src={userInfo?.avatar} - variant="circle" - /> - </CardMedia> - </CardContent> - <CardContent> - <Typography - component="h2" - variant="h2" - > - {userInfo?.fullName} - </Typography> - <Typography - component="h3" - variant="h3" - fontWeight="bold" - > - {`@${userInfo?.loginName}`} - </Typography> - </CardContent> - </Card> - ); -} diff --git a/src/components/common/User/UserProfile.tsx b/src/components/common/User/UserProfile.tsx new file mode 100644 index 0000000000000000000000000000000000000000..065e7e3baac374950559a4c79b5554ea88fd1221 --- /dev/null +++ b/src/components/common/User/UserProfile.tsx @@ -0,0 +1,36 @@ +import { UserInfoResponse } from "../../../store/deployApi"; +import { Avatar, Box, Typography, Stack } from "@mui/material"; + +interface UserProfileProps { + userInfo: UserInfoResponse; +} + +export const UserProfile = ({ userInfo }: UserProfileProps) => { + return ( + <Stack + flexDirection="row" + gap={4} + sx={{ padding: 2 }} + > + <Avatar + sx={{ width: 96, height: 96 }} + src={userInfo?.avatar} + /> + <Box> + <Typography + component="h2" + variant="h2" + > + {userInfo?.fullName} + </Typography> + <Typography + component="h3" + variant="h3" + fontWeight="bold" + > + {`@${userInfo?.loginName}`} + </Typography> + </Box> + </Stack> + ); +}; diff --git a/src/components/common/User/index.js b/src/components/common/User/index.js index 416c1fc44ff1a708b7b8c28bf8597077ee8f2184..9359a560d4f8a2e33aec28892c68513b90db931f 100644 --- a/src/components/common/User/index.js +++ b/src/components/common/User/index.js @@ -1,6 +1,5 @@ -import { UserIocList } from "./UserIOCList"; import { UserOperationList } from "./UserOperationList"; import { UserProfile } from "./UserProfile"; import { UserAvatar } from "./UserAvatar"; -export { UserIocList, UserOperationList, UserProfile, UserAvatar }; +export { UserOperationList, UserProfile, UserAvatar }; diff --git a/src/views/UserPage/UserPageView.js b/src/views/UserPage/UserPageView.js index 3c1becaf22347e9b330b408ac1aa1f9830b8d1c6..2f92f8b5254515befb6dec10706b4a1783a52fd0 100644 --- a/src/views/UserPage/UserPageView.js +++ b/src/views/UserPage/UserPageView.js @@ -3,7 +3,6 @@ import { Grid } from "@mui/material"; import { GlobalAppBarContext } from "@ess-ics/ce-ui-common"; import { applicationTitle } from "../../components/common/Helper"; import { UserProfile } from "../../components/common/User/UserProfile"; -import { UserIocList } from "../../components/common/User/UserIOCList"; import { UserOperationList } from "../../components/common/User/UserOperationList"; export function UserPageView({ userName, userInfo }) { @@ -21,12 +20,6 @@ export function UserPageView({ userName, userInfo }) { > <UserProfile userInfo={userInfo} /> </Grid> - <Grid - item - xs={12} - > - <UserIocList userName={userName} /> - </Grid> <Grid item xs={12}