Skip to content

Commit

Permalink
some design cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Feb 25, 2024
1 parent 5420bf7 commit 9036319
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 13 deletions.
22 changes: 11 additions & 11 deletions components/StatusChip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ import Chip, { chipClasses, ChipProps } from "@mui/material/Chip";

export type Status = "validated" | "review" | "refused" | "dropped";
interface StatusChipProps extends ChipProps {
status: Status;
status?: Status;
}

function getColor(status: StatusChipProps["status"], theme: Theme) {
if (status === "validated") {
return theme.palette.success;
switch (status) {
case "validated":
return theme.palette.success;
case "review":
return theme.palette.info;
case "refused":
return theme.palette.warning;
case "dropped":
default:
return { main: theme.palette.grey[800], light: theme.palette.grey[100] };
}
if (status === "review") {
return theme.palette.info;
}
if (status === "dropped") {
return theme.palette.warning;
}
return { main: theme.palette.grey[800], light: theme.palette.grey[100] };
}

function StatusChip(props: StatusChipProps) {
Expand All @@ -40,7 +41,6 @@ const StyledStatusChip = styled(StatusChip, {
...(size === "small" && {
height: 26,
borderRadius: 26 / 2,
color: theme.palette.grey[900],
}),
[`& .${chipClasses.label}`]: {
paddingLeft: theme.spacing(1),
Expand Down
25 changes: 24 additions & 1 deletion components/folders/AmendementTab/AmendementCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ import AccordionDetails from "@mui/material/AccordionDetails";
import AccordionSummary from "@mui/material/AccordionSummary";

import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import StatusChip from "@/components/StatusChip";

function getStatus(label: string) {
switch (label) {
case "Adopté":
return "validated";
case "Rejeté":
case "Irrecevable":
case "Tombé":
case "Irrecevable 40":
return "refused";
case "Non soutenu":
case "Retiré":
return "dropped";
default:
return "review";
}
}

export default function AmendementCard(props: Amendement) {
const {
dateDepot,
Expand Down Expand Up @@ -55,7 +74,11 @@ export default function AmendementCard(props: Amendement) {
<span>
{prenom} {nom}
</span>
<span>{sortAmendement || etatLibelle}</span>
<StatusChip
size="small"
label={sortAmendement || etatLibelle}
status={getStatus(sortAmendement || etatLibelle)}
/>
</Stack>
</AccordionSummary>
<AccordionDetails>
Expand Down
2 changes: 1 addition & 1 deletion components/folders/AmendementTab/AmendementList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function AmendementsList(

return (
<Stack>
{filteredAmendements.slice(0, 10).map((amendement) => (
{filteredAmendements.map((amendement) => (
<AmendementCard {...amendement} key={amendement.uid} />
))}
</Stack>
Expand Down

0 comments on commit 9036319

Please sign in to comment.