Skip to content

Commit

Permalink
feat: table status friendly name
Browse files Browse the repository at this point in the history
  • Loading branch information
KostyalBalint committed Dec 29, 2024
1 parent 8b9583b commit 7becab3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/InfiniteLoad/ExerciseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CategoryDifficulties } from "../CategoryDifficulties";
import { KaTeX } from "../Katex";
import { StyledTableRow } from "@/components/StyledTableRow.tsx";
import dayjs from "dayjs";
import { exerciseStatusToHuman } from "@/util/const.ts";

const ExerciseRow: FC<{ data: ExerciseListElemFragment }> = ({ data }) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -37,7 +38,13 @@ const ExerciseRow: FC<{ data: ExerciseListElemFragment }> = ({ data }) => {
<TableCell sx={{ minWidth: 210 }}>
<CategoryDifficulties value={difficulties} />
</TableCell>
<TableCell sx={{ verticalAlign: "middle" }}>{data.status}</TableCell>
<TableCell sx={{ verticalAlign: "middle" }}>
<Chip
variant="outlined"
color={exerciseStatusToHuman[data.status].color}
label={exerciseStatusToHuman[data.status].text}
/>
</TableCell>
<TableCell>
{data.tags.map((tag, index) => (
<Chip key={index} label={tag.name} sx={{ margin: 0.5 }} />
Expand Down
33 changes: 33 additions & 0 deletions src/util/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Exercise,
ExerciseAgeGroup,
ExerciseCheckType,
ExerciseStatus,
} from "@/generated/graphql";
import { ExerciseFieldsType, ExerciseQuery } from "./types";

Expand Down Expand Up @@ -114,3 +115,35 @@ export const createExerciseInitialValue: ExerciseFieldsType = {
tags: [],
sameLogicGroup: "",
};

export const exerciseStatusToHuman: Record<
ExerciseStatus,
{
color:
| "primary"
| "default"
| "secondary"
| "error"
| "info"
| "success"
| "warning";
text: string;
}
> = {
APPROVED: {
color: "success",
text: "Kész",
},
CREATED: {
color: "default",
text: "Beküldve",
},
DELETED: {
color: "error",
text: "Törölve",
},
DRAFT: {
color: "warning",
text: "Vázlat",
},
};

0 comments on commit 7becab3

Please sign in to comment.