Enterprise-CMCS/macpro-mako

View on GitHub
react-app/src/utils/stateNames.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { STATES } from "@/hooks";

type State = keyof typeof STATES;
const isStringAState = (supposedState: string): supposedState is State =>
  supposedState in STATES;

export const convertStateAbbrToFullName = (input: string): string => {
  if (isStringAState(input)) {
    return STATES[input].split(",")[0];
  }

  return input;
};