Skip to content

Commit d21bfe4

Browse files
committed
fix: refactor envTagVariant function to use switch statement for better clarity
1 parent d241891 commit d21bfe4

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/lib/envTagVariant.ts

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
import type { TagProps } from '@nais/ds-svelte-community/components/Tag/type.js';
22

3+
// HACK: mantained manually - should have been provided by Nais API
34
export const envTagVariant = (env: string): TagProps['variant'] => {
4-
if (env.includes('prod')) {
5-
if (env.includes('fss')) {
5+
switch (env) {
6+
case 'non-prod':
7+
case 'sandbox':
8+
case 'dev-gcp':
9+
case 'ci':
10+
case 'test':
11+
case 'dev':
12+
return 'neutral-filled';
13+
case 'prod-gcp':
14+
case 'prod':
15+
return 'info-moderate';
16+
case 'prod-fss':
617
return 'alt3-moderate';
7-
}
8-
return 'info-moderate';
18+
case 'dev-fss':
19+
return 'neutral-moderate';
20+
default:
21+
if (env.includes('prod')) {
22+
return 'info-moderate';
23+
}
24+
return 'neutral-filled';
925
}
10-
if (env.includes('fss')) {
11-
return 'neutral-moderate';
12-
}
13-
return 'neutral-filled';
1426
};

0 commit comments

Comments
 (0)