Skip to content

Commit

Permalink
feat(spu-ui): enhance metadata schema in QueueItem component
Browse files Browse the repository at this point in the history
- Including simple aquisition plan metadata to the schema.
  • Loading branch information
brnovasco committed Jan 21, 2025
1 parent 793b339 commit 3989702
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions apps/spu-ui/src/app/_components/queue/queue-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ const commonKwargsSchema = z.object({
sampleTag: z.string().optional(),
metadata: z
.object({
sampleType: z.string(),
sampleTag: z.string(),
bufferTag: z.string(),
sampleType: z.string().optional(),
sampleTag: z.string().optional(),
bufferTag: z.string().optional(),
row: z.string().optional(),
col: z.string().optional(),
tray: z.string().optional(),
})
.optional(),
});
Expand Down Expand Up @@ -180,6 +183,8 @@ function RemoveButton({ uid, disabled }: { uid?: string; disabled?: boolean }) {
export function PlanContent({ props }: { props: QueueItemProps }) {
const common = commonKwargsSchema.safeParse(props.kwargs);
if (!common.success) {
console.error(common.error);
console.error(props.kwargs);
return null;
}
return (
Expand All @@ -188,9 +193,15 @@ export function PlanContent({ props }: { props: QueueItemProps }) {
<Badge variant="outline">proposal: {common.data.proposal}</Badge>
)}
{common.data.tray && <Badge variant="outline">{common.data.tray}</Badge>}
{common.data.metadata?.tray && (
<Badge variant="outline">{common.data.metadata.tray}</Badge>
)}
{common.data.col && common.data.row && (
<Badge variant="outline">{`${common.data.col}${common.data.row}`}</Badge>
)}
{common.data.metadata?.col && common.data.metadata.row && (
<Badge variant="outline">{`${common.data.metadata.col}${common.data.metadata.row}`}</Badge>
)}
{common.data.sampleType && common.data.sampleTag && (
<Badge
className={cn("border-none bg-slate-400 text-slate-800", {
Expand All @@ -204,7 +215,7 @@ export function PlanContent({ props }: { props: QueueItemProps }) {
{common.data.sampleTag && <span>: {common.data.sampleTag}</span>}
</Badge>
)}
{common.data.metadata && (
{common.data.metadata?.sampleType && common.data.metadata?.sampleTag && (

Check failure on line 218 in apps/spu-ui/src/app/_components/queue/queue-item.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

Unnecessary optional chain on a non-nullish value
<Badge
className={cn("border-none bg-slate-400 text-slate-800", {
"bg-emerald-200 text-emerald-800":
Expand Down

0 comments on commit 3989702

Please sign in to comment.