From 12c43e9a00faa66fbd9420c3394d48471387b629 Mon Sep 17 00:00:00 2001 From: toqvist Date: Fri, 5 Apr 2024 13:38:19 +0200 Subject: [PATCH] Style dispatches --- astro/src/components/KiosMap.tsx | 37 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/astro/src/components/KiosMap.tsx b/astro/src/components/KiosMap.tsx index e6a325e..48be123 100644 --- a/astro/src/components/KiosMap.tsx +++ b/astro/src/components/KiosMap.tsx @@ -66,7 +66,7 @@ type Dispatch = { courier?: User; timeSensitive: boolean; - status: DispatchStatus[]; + status: DispatchStatus; departureDate: string; arrivalDate: string; @@ -151,6 +151,26 @@ const locationSwitcharoo = (location: number[]) => { return location } + +const dashArrays: Record = { + requested: '20, 10', + accepted: '0, 0', + archived: '1, 5', +} + +const dashColors: Record = { + requested: '#000', + accepted: '#000', + archived: '#000', +} + +const dashOpacities: Record = { + requested: 0.7, + accepted: 0.7, + archived: 0.5 +} + + export const KiosMap = () => { const { data: makers, isLoading: isLoadingMakers } = useGetMakers(); @@ -228,17 +248,20 @@ export const KiosMap = () => { productsString += product.productTitle + (i + 1 < dispatch.products.length ? ', ' : ''); }); - const myDashArray = - dispatch.status === 'requested' ? '20, 10' : - dispatch.status === 'archived' ? '1, 5' : - '0, 0'; + //status type should already be inferred when list of dispatches is created, weird that is is required + const status: DispatchStatus = dispatch.status; + const dashArray:string = dashArrays[status] + const dashColor:string = dashColors[status] + const dashOpacity:number = dashOpacities[status] + return (
+ color={dashColor} + opacity={dashOpacity} + dashArray={dashArray} />
); }