Skip to content

Commit

Permalink
clients: Fix typing for cancellation reason mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
birkjernstrom committed Dec 13, 2024
1 parent 9bce66f commit 25ac5e7
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ import React, { MouseEvent, useCallback, useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { twMerge } from 'tailwind-merge'

const CANCELLATION_REASONS = {
const CANCELLATION_REASONS: {
[key: string]: string
} = {
unused: 'Unused',
too_expensive: 'Too Expensive',
missing_features: 'Missing Features',
Expand All @@ -80,10 +82,12 @@ const CANCELLATION_REASONS = {
}

const getHumanCancellationReason = (
key: keyof typeof CANCELLATION_REASONS | null,
key: string | null,
) => {
if (!key) return null
return CANCELLATION_REASONS[key]
if (key && (key in CANCELLATION_REASONS)) {
return CANCELLATION_REASONS[key]
}
return null
}

const StatusLabel = ({
Expand Down

0 comments on commit 25ac5e7

Please sign in to comment.