All files / libs/data-capture/fields/components/src/lib/user/container UserContainer.tsx

100% Statements 24/24
100% Branches 2/2
100% Functions 1/1
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x  
import { omit } from 'lodash-es';
import { memo } from 'react';
 
import { type KeysOfUserWithStringValues } from '@amalia/tenants/users/types';
 
import { UserFetchContainer, type UserFetchContainerProps } from '../fetch-container/UserFetchContainer';
import { UserNullValue } from '../null-value/UserNullValue';
import { USER_NULL_VALUE } from '../types';
 
export type UserContainerProps<TProperty extends KeysOfUserWithStringValues> = UserFetchContainerProps<TProperty>;
 
export const UserContainerBase = function UserContainerBase<TProperty extends KeysOfUserWithStringValues>(
  props: UserContainerProps<TProperty>,
) {
  const { value } = props;
 
  if (value.toLowerCase() === USER_NULL_VALUE) {
    return <UserNullValue {...omit(props, 'isComputing')} />;
  }
 
  return <UserFetchContainer {...props} />;
};
 
export const UserContainer = memo(UserContainerBase) as typeof UserContainerBase;