feat(plan): show project name instead of raw id in cell
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { ResolvedCell } from "../lib/queries/plan";
|
||||
import type { Project } from "../lib/queries/projects";
|
||||
|
||||
interface Props {
|
||||
cell: ResolvedCell | null;
|
||||
project: Project | null;
|
||||
readonly?: boolean;
|
||||
}
|
||||
|
||||
@@ -15,19 +17,32 @@ const CATEGORY_LABELS: Record<string, string> = {
|
||||
other: "Jiné",
|
||||
};
|
||||
|
||||
export default function PlanRangeChips({ cell, readonly }: Props) {
|
||||
export default function PlanRangeChips({ cell, project, readonly }: Props) {
|
||||
void readonly;
|
||||
if (!cell) return null;
|
||||
const projectLabel = project
|
||||
? project.project_number
|
||||
? `${project.project_number} — ${project.name}`
|
||||
: project.name
|
||||
: null;
|
||||
const projectTitle = project
|
||||
? project.project_number
|
||||
? `${project.project_number} — ${project.name}`
|
||||
: project.name
|
||||
: undefined;
|
||||
return (
|
||||
<div>
|
||||
<span className={`plan-chip plan-chip--${cell.category}`}>
|
||||
{CATEGORY_LABELS[cell.category] ?? cell.category}
|
||||
</span>
|
||||
{cell.project_id && (
|
||||
<span style={{ marginLeft: 6, fontSize: 12, fontWeight: 600 }}>
|
||||
{`#${cell.project_id}`}
|
||||
<div className="plan-chip-block">
|
||||
<div className="plan-chip-line">
|
||||
<span className={`plan-chip plan-chip--${cell.category}`}>
|
||||
{CATEGORY_LABELS[cell.category] ?? cell.category}
|
||||
</span>
|
||||
)}
|
||||
{cell.note && <span className="plan-cell-note">{cell.note}</span>}
|
||||
{projectLabel && (
|
||||
<span className="plan-chip-project" title={projectTitle}>
|
||||
{projectLabel}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{cell.note && <div className="plan-cell-note">{cell.note}</div>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user