diff --git a/frontend/src/component/project/Project/ProjectInfo/ChangeRequestsWidget.tsx b/frontend/src/component/project/Project/ProjectInfo/ChangeRequestsWidget.tsx new file mode 100644 index 0000000000..1f46be6b56 --- /dev/null +++ b/frontend/src/component/project/Project/ProjectInfo/ChangeRequestsWidget.tsx @@ -0,0 +1,95 @@ +import { FC } from 'react'; +import useLoading from 'hooks/useLoading'; +import { Link as RouterLink } from 'react-router-dom'; +import { Box, styled, Typography, Link } from '@mui/material'; +import { IChangeRequest } from 'component/changeRequest/changeRequest.types'; + +import { + StyledCount, + StyledProjectInfoWidgetContainer, + StyledWidgetTitle, +} from './ProjectInfo.styles'; +import { useProjectChangeRequests } from 'hooks/api/getters/useProjectChangeRequests/useProjectChangeRequests'; + +interface IChangeRequestsWidgetProps { + projectId: string; +} + +const StyledChangeBox = styled(Box)(({ theme }) => ({ + textAlign: 'left', + padding: theme.spacing(1.5), + marginBottom: theme.spacing(1.5), + borderRadius: theme.shape.borderRadiusMedium, + alignItems: 'center', +})); + +const StyledChangeRequestStatusInfo = styled(Box)(({ theme }) => ({ + display: 'flex', + alignItems: 'center', +})); + +const StyledApprovedCount = styled(StyledCount)(({ theme }) => ({ + background: theme.palette.activityIndicators.recent, + padding: theme.spacing(0, 1), + marginRight: theme.spacing(0.5), + borderRadius: theme.shape.borderRadius, +})); + +const StyledInReviewCount = styled(StyledCount)(({ theme }) => ({ + background: theme.palette.activityIndicators.primary, + padding: theme.spacing(0, 1), + marginRight: theme.spacing(0.5), + borderRadius: theme.shape.borderRadius, +})); + +const ChangeRequestsLabel = () => ( + + change requests + +); + +export const ChangeRequestsWidget: FC = ({ + projectId, +}) => { + const { changeRequests, loading } = useProjectChangeRequests(projectId); + const loadingRef = useLoading(loading); + const toBeApplied = changeRequests?.filter( + (changeRequest: IChangeRequest) => changeRequest?.state === 'Approved' + ).length; + const toBeReviewed = changeRequests?.filter( + (changeRequest: IChangeRequest) => changeRequest?.state === 'In review' + ).length; + + return ( + + Open change requests + + theme.palette.success.light }} + > + To be applied + + {toBeApplied}{' '} + + + + theme.palette.secondary.light }} + > + To be reviewed + + {toBeReviewed}{' '} + + + + + + View change requests + + + + ); +}; diff --git a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx index 3b729b2f93..ddbc3e349f 100644 --- a/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx +++ b/frontend/src/component/project/Project/ProjectInfo/ProjectInfo.tsx @@ -7,6 +7,7 @@ import { ToggleTypesWidget } from './ToggleTypesWidget'; import { MetaWidget } from './MetaWidget'; import { ProjectMembersWidget } from './ProjectMembersWidget'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; +import { ChangeRequestsWidget } from './ChangeRequestsWidget'; interface IProjectInfoProps { id: string; @@ -23,10 +24,18 @@ const ProjectInfo = ({ health, features, }: IProjectInfoProps) => { - const { uiConfig } = useUiConfig(); + const { uiConfig, isEnterprise } = useUiConfig(); + return (