Skip to content

Commit

Permalink
Merge pull request #39 from jadmsaadaot/SUBMIT-task#64
Browse files Browse the repository at this point in the history
Integrate project resource with front end projects page
  • Loading branch information
jadmsaadaot authored Aug 22, 2024
2 parents 13e364d + 7442c8b commit d880ff3
Show file tree
Hide file tree
Showing 18 changed files with 247 additions and 194 deletions.
1 change: 1 addition & 0 deletions submit-api/src/submit_api/models/account_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AccountProject(BaseModel):
id = Column(db.Integer, primary_key=True, autoincrement=True)
account_id = Column(db.Integer, ForeignKey('accounts.id'), nullable=False)
project_id = Column(db.Integer, ForeignKey('projects.id'), nullable=False)
project = db.relationship('Project', foreign_keys=[project_id], lazy='joined')

@classmethod
def add_projects_bulk(cls, projects):
Expand Down
3 changes: 1 addition & 2 deletions submit-api/src/submit_api/models/queries/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def get_projects_by_account_id(cls, account_id: int):
"""Find projects by account_id"""
result = (db.session.query(AccountProject)
.filter(AccountProject.account_id == account_id)
.join(Project)
.first())
.join(Project))
return result

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions submit-api/src/submit_api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from flask_restx import Namespace, Resource, cors

from submit_api.schemas.project import AddProjectSchema, ProjectSchema
from submit_api.schemas.project import AddProjectSchema, ProjectSchema, AccountProjectSchema
from submit_api.services.project_service import ProjectService
from submit_api.utils.util import cors_preflight

Expand Down Expand Up @@ -50,7 +50,7 @@ class ProjectsByAccount(Resource):
def get(account_id):
"""Get projects by account id."""
projects = ProjectService.get_projects_by_account_id(account_id)
return ProjectSchema(many=True).dump(projects), HTTPStatus.OK
return AccountProjectSchema(many=True).dump(projects), HTTPStatus.OK

@staticmethod
@ApiHelper.swagger_decorators(API, endpoint_description="Add projects in bulk")
Expand Down
17 changes: 15 additions & 2 deletions submit-api/src/submit_api/schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class ProjectSchema(Schema):
"""Account schema."""
"""project schema."""

class Meta: # pylint: disable=too-few-public-methods
"""Exclude unknown fields in the deserialized output."""
Expand All @@ -21,11 +21,24 @@ class Meta: # pylint: disable=too-few-public-methods


class AddProjectSchema(Schema):
"""Account schema."""
"""add project schema."""

class Meta: # pylint: disable=too-few-public-methods
"""Exclude unknown fields in the deserialized output."""

unknown = EXCLUDE

project_ids = fields.List(fields.Int(), data_key="project_ids")


class AccountProjectSchema(Schema):
"""Account project schema."""

class Meta: # pylint: disable=too-few-public-methods
"""Exclude unknown fields in the deserialized output."""

unknown = EXCLUDE

account_id = fields.Int(data_key="account_id")
project_id = fields.Int(data_key="project_id")
project = fields.Nested(ProjectSchema, data_key="project")
8 changes: 4 additions & 4 deletions submit-web/package-lock.json

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

2 changes: 1 addition & 1 deletion submit-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@tanstack/router-devtools": "^1.45.7",
"@tanstack/router-plugin": "^1.45.7",
"axios": "^1.7.2",
"epic.theme": "^1.0.6",
"epic.theme": "^1.0.8",
"keycloak-js": "^25.0.1",
"oidc-client-ts": "^3.0.1",
"react": "^18.2.0",
Expand Down
128 changes: 128 additions & 0 deletions submit-web/src/components/Projects/Project.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { Box, Button, Divider, Paper, styled, Typography } from "@mui/material";
import { BCDesignTokens } from "epic.theme";
import AddIcon from "@mui/icons-material/Add";
import { ProjectStatus } from "../registration/addProjects/ProjectStatus";
import { PROJECT_STATUS } from "../registration/addProjects/ProjectCard/constants";
import SubmissionTable from "./SubmissionTable";
import { defaultPlans } from "./constants";
import { AccountProject } from "@/models/Project";

const HEADER_HEIGHT = 54;

const CardInnerBox = styled(Box)({
display: "flex",
alignItems: "flex-start",
justifyContent: "center",
flexDirection: "column",
height: "100%",
padding: "0 12px",
});

type ProjectParam = {
accountProject: AccountProject;
};

export const Project = ({ accountProject }: ProjectParam) => {
const plans = defaultPlans;
return (
<Paper
sx={{
width: "90%",
height: "100%",
borderRadius: "6px",
}}
elevation={2}
>
<Box
bgcolor={BCDesignTokens.themeBlue10}
sx={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
borderRadius: "3px 3px 0 0",
}}
height={HEADER_HEIGHT}
>
<Typography
variant="h3"
fontWeight={600}
px={2}
color={BCDesignTokens.typographyColorPrimary}
>
{accountProject.project.name}
</Typography>
<Typography
variant="h4"
color={BCDesignTokens.themeGray70}
sx={{
mr: 2,
fontWeight: 400,
}}
>
EAC #1234567
</Typography>
</Box>

<Box
sx={{
padding: "36px 12px 12px 12px",
}}
>
<Box
sx={{
borderRadius: "3px",
border: `1px solid #F2F2F2`,
boxShadow: "0px 1px 2px rgba(0, 0, 0, 0.1)",
}}
>
<Box
display={"flex"}
justifyContent={"space-between"}
sx={{ py: BCDesignTokens.layoutPaddingXlarge }}
>
<CardInnerBox>
<Typography variant="h4" fontWeight={400}>
Management Plans
</Typography>
<ProjectStatus bold status={PROJECT_STATUS.POST_DECISION} />
</CardInnerBox>
<CardInnerBox>
<Button>
<AddIcon sx={{ p: 0, mr: 0.5 }} />
New Submission
</Button>
</CardInnerBox>
</Box>
<Box height={"100%"} px={BCDesignTokens.layoutPaddingXsmall}>
<Divider sx={{ mb: 0.5 }} />
<Typography
variant="body1"
sx={{
fontWeight: "bold",
backgroundColor: BCDesignTokens.themeGold10,
}}
>
Active Submissions
</Typography>
<CardInnerBox sx={{ height: "100%", py: 2 }}>
<SubmissionTable plans={plans} />
</CardInnerBox>
<Divider sx={{ mb: 0.5 }} />
<Typography
variant="body1"
sx={{
fontWeight: "bold",
backgroundColor: BCDesignTokens.themeGold10,
}}
>
Past Submissions
</Typography>
<CardInnerBox sx={{ height: "100%", my: 2 }}>
<SubmissionTable headless plans={plans} />
</CardInnerBox>
</Box>
</Box>
</Box>
</Paper>
);
};
2 changes: 1 addition & 1 deletion submit-web/src/components/Projects/SubmissionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function SubmissionTable({
)}
<TableBody>
{plans?.map((plan) => (
<TableRow component={Box} sx={{ my: 1 }}>
<TableRow key={`row-${plan.id}`} component={Box} sx={{ my: 1 }}>
<TableCell
component="th"
scope="row"
Expand Down
42 changes: 0 additions & 42 deletions submit-web/src/components/Projects/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,4 @@ export const defaultPlans: Array<Plan> = [
submittedBy: "Jane Doe",
isCompleted: false,
},
{
id: 3,
name: "Management Plan 123",
submittedDate: "2021-10-10",
submittedBy: "John Doe",
isCompleted: false,
},
{
id: 4,
name: "Management Plan 456",
submittedDate: "2021-10-11",
submittedBy: "Jane Doe",
isCompleted: false,
},
{
id: 5,
name: "Management Plan 123",
submittedDate: "2021-10-10",
submittedBy: "John Doe",
isCompleted: true,
},
{
id: 6,
name: "Management Plan 456",
submittedDate: "2021-10-11",
submittedBy: "Jane Doe",
isCompleted: true,
},
{
id: 7,
name: "Management Plan 123",
submittedDate: "2021-10-10",
submittedBy: "John Doe",
isCompleted: true,
},
{
id: 8,
name: "Management Plan 456",
submittedDate: "2021-10-11",
submittedBy: "Jane Doe",
isCompleted: false,
},
];
26 changes: 26 additions & 0 deletions submit-web/src/components/Projects/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { AccountProject } from "@/models/Project";
import { Skeleton, Stack } from "@mui/material";
import { Project } from "./Project";

type ProjectsParams = {
accountProjects: AccountProject[];
};
export const Projects = ({ accountProjects }: ProjectsParams) => {
return (
<Stack spacing={2} direction={"column"}>
{accountProjects.map((accountProject) => (
<Project key={accountProject.id} accountProject={accountProject} />
))}
</Stack>
);
};

export const ProjectsSkeleton = () => {
return (
<Stack spacing={2} direction={"column"}>
<Skeleton variant="rectangular" height={690} width={1334} />
<Skeleton variant="rectangular" height={690} width={1334} />
<Skeleton variant="rectangular" height={690} width={1334} />
</Stack>
);
};
2 changes: 1 addition & 1 deletion submit-web/src/components/Shared/Modals/UpdateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const UpdateModal = ({ header, subText }: UpdateModalProps) => {
</Grid>
<Grid container direction="row" item xs={12}>
{subText.map((subtext) => (
<Grid item xs={12}>
<Grid key={subtext.text} item xs={12}>
<Typography variant="body1" sx={{ mb: 1 }}>
{subtext.text}
</Typography>
Expand Down
4 changes: 2 additions & 2 deletions submit-web/src/components/Shared/YellowBar.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Box } from "@mui/material";
import React from "react";
import { BCDesignTokens } from "epic.theme";

export const YellowBar = () => {
return (
<Box
sx={{
height: "5px",
width: "50px",
backgroundColor: "#FCBA19",
backgroundColor: BCDesignTokens.themeGold100,
}}
/>
);
Expand Down
7 changes: 1 addition & 6 deletions submit-web/src/components/Shared/layout/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import { theme } from "@/styles/theme";

const Footer = () => {
return (
<Grid
container
justifyContent="center"
alignItems="center"
spacing={0}
>
<Grid container justifyContent="center" alignItems="center" spacing={0}>
<Grid
item
xs={12}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function SideNavBar() {
};

return (
<div>
<div style={{ height: "100%" }}>
<Box
sx={{
overflow: "auto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Case, Default, Switch } from "react-if";
import ModeStandbyIcon from "@mui/icons-material/ModeStandby";
import { Stack } from "@mui/material";
import { PROJECT_STATUS } from "./ProjectCard/constants";
import { EAOColors } from "epic.theme";

type ProjectStatusProps = {
status: string;
Expand All @@ -16,10 +17,10 @@ export const ProjectStatus = ({ status, bold = false }: ProjectStatusProps) => {
spacing={1}
direction="row"
alignItems={"center"}
color={"#947BB6"}
color={EAOColors.DecisionMain}
>
<ModeStandbyIcon />
<Caption2 color={"#947BB6"} bold={bold}>
<Caption2 color={EAOColors.DecisionMain} bold={bold}>
Post-Decision
</Caption2>
</Stack>
Expand Down
Loading

0 comments on commit d880ff3

Please sign in to comment.