1.0.11 • Published 2 years ago

@brut2com/myhome-common v1.0.11

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

myhome-common

For use Enums

Example :

import { Enum } from '@brut2com/myhome-common'

// or 

const { Enum } = require('@brut2com/myhome-common')

  const renderCategoryQuestion = () => {
    return (
      <SelectField
        label='Sélectionnez la catégorie de votre question'
        name='questionCategory'
        id='questionCategory'
        options={Enum.CategoryQuestionType()}
        variant='outlined'
        data-testid='question-form-category-select-test-id'
      />
    )
  }

Associate functions

In bdc-common npm package, we have associate function for use with enumerations.

// Require Utils part of bdc_common package
const { Utils } = require('@brutdecom/bdc_common')

// or

import { Utils } from '@brutdecom/bdc_common'

// Use utils function
const myConst = Utils.myUtilsFunction()
// return ...

Enum example for functions examples :

    const HabitatThemeQuestionType = [
        {
          value: 'theme-service-book',
          subTheme: [
              {
                value: 'sub-theme-service-book'
              }
          ]
        },
        {
            value: 'theme-framework',
            subTheme: [
                {
                  value: 'sub-theme-wood-state'
                },
                {
                  value: 'sub-theme-termites'
                }
            ]
          },
          {
            value: 'theme-roof',
            subTheme: [
                {
                  value: 'sub-theme-roof-tiles'
                },
                {
                  value: 'sub-theme-ridge-and-hip'
                }
            ]
          }
    ]

For use enum functions

Get values of the enum

const { Enum } = require('@brut2com/myhome-common')
const { Utils } = require('@brutdecom/bdc_common')

// or for REACT

import { Enum } from '@brut2com/myhome-common')
import { Utils } from '@brutdecom/bdc_common')


const enumValues = Utils.getEnumValues(Enum.HabitatThemeQuestionType()) // Look enum example Enum.HabitatThemeQuestionType() above for details
// enumValues = ['theme-service-book', 'theme-framework', 'theme-roof']

Get sub type values of the enum

const { Enum } = require('@brut2com/myhome-common')
const { Utils } = require('@brutdecom/bdc_common')

// or for REACT

import { Enum } from '@brut2com/myhome-common')
import { Utils } from '@brutdecom/bdc_common')


const enumSubTypeValues = Utils.getEnumSubTypeValues(Enum.HabitatThemeQuestionType(), 'subTheme') // Look enum example Enum.HabitatThemeQuestionType() above for details
// enumSubTypeValues = ['sub-theme-service-book', 'sub-theme-wood-state', 'sub-theme-termites', 'sub-theme-roof-tiles', 'sub-theme-ridge-and-hip']

Get sub type objects in enum

const { Enum } = require('@brut2com/myhome-common')
const { Utils } = require('@brutdecom/bdc_common')

// or for REACT

import { Enum } from '@brut2com/myhome-common')
import { Utils } from '@brutdecom/bdc_common')


const enumSubType = Utils.getEnumSubTypes(Enum.HabitatThemeQuestionType()) // Look enum example Enum.HabitatThemeQuestionType() above for details
// enumSubType = [
//   {
//     value: 'sub-theme-service-book'
//   },
//   {
//     value: 'sub-theme-wood-state'
//   },
//   {
//     value: 'sub-theme-termites'
//   },
//   {
//     value: 'sub-theme-roof-tiles'
//   },
//   {
//     value: 'sub-theme-ridge-and-hip'
//    }
//   ]

Get sub type objects in enum

const { Enum } = require('@brut2com/myhome-common')
const { Utils } = require('@brutdecom/bdc_common')

// or for REACT

import { Enum } from '@brut2com/myhome-common')
import { Utils } from '@brutdecom/bdc_common')


const subTypesValuesByParent = Utils.getEnumSubTypeValuesByParent(Enum.HabitatThemeQuestionType(), 'subTheme', 'theme-roof') // Look enum example Enum.HabitatThemeQuestionType() above for details
// subTypesValuesByParent = ['sub-theme-roof-tiles', 'sub-theme-ridge-and-hip']

Get sub type objects in enum

const { Enum } = require('@brut2com/myhome-common')
const { Utils } = require('@brutdecom/bdc_common')

// or for REACT

import { Enum } from '@brut2com/myhome-common')
import { Utils } from '@brutdecom/bdc_common')


const subTypesByParent = Utils.getEnumSubTypeByParent(Enum.HabitatThemeQuestionType(), 'subTheme', 'theme-roof') // Look enum example Enum.HabitatThemeQuestionType() above for details
// subTypesByParent = [
//     {
//       value: 'sub-theme-roof-tiles'
//     },
//     {
//       value: 'sub-theme-ridge-and-hip'
//     }
// ])

Enumerations

For look enums content.

const CategoryQuestionEnum = [
    {
      value: 'category-housing',
      text: 'Habitat'
    }
]

const CategoryQuestionType = () => {
  return CategoryQuestionEnum
}
const DiagnosticStatusEnum = [
    {
      value: 'diagnostic-status-validate'
    },
    {
      value: 'diagnostic-status-new'
    }
]

const DiagnosticStatusType = () => {
  return DiagnosticStatusEnum
}
const QuestionEnum = [
    {
      value: 'question-knowledge'
    },
    {
      value: 'question-inspection'
    },
    {
      value: 'question-historical'
    },
    {
      value: 'question-action'
    },
    {
      value: 'question-tax'
    },
    {
      value: 'question-aids'
    },
    {
      value: 'question-regulation'
    }
]

const QuestionType = () => {
  return QuestionEnum
}
const UserRoleEnum = [
    {
      value: 'admin'
    },
    {
      value: 'superAdmin'
    },
    {
      value: 'professional'
    },
    {
      value: 'client'
    }
]

const UserRoleType = () => {
  return UserRoleEnum
}
const HabitatThemeQuestionEnum = [
    {
      value: 'theme-service-book'
      subTheme: [
          {
            value: 'sub-theme-service-book'
          }
      ]
    },
    {
        value: 'theme-framework',
        subTheme: [
            {
              value: 'sub-theme-wood-state'
            },
            {
              value: 'sub-theme-sag'
            },
            {
              value: 'sub-theme-humidity'
            },
            {
              value: 'sub-theme-termites'
            }
        ]
      },
      {
        value: 'theme-roof',
        subTheme: [
            {
              value: 'sub-theme-roof-tiles'
            },
            {
              value: 'sub-theme-ridge-and-hip'
            },
            {
              value: 'sub-theme-chimney-stack'
            },
            {
              value: 'sub-theme-gutters'
            }
        ]
      },
      {
        value: 'theme-frontage',
        subTheme: [
            {
              value: 'sub-theme-crack'
            },
            {
              value: 'sub-theme-insulation'
            },
            {
              value: 'sub-theme-humidity'
            },
            {
              value: 'sub-theme-masonry'
            }
        ]
      },
      {
        value: 'theme-boiler',
        subTheme: [
            {
              value: 'sub-theme-control'
            }
        ]
      },
      {
        value: 'theme-electricity',
        subTheme: [
            {
              value: 'sub-theme-diagnostic'
            }
        ]
      },
      {
        value: 'theme-cellar-and-foundation',
        subTheme: [
            {
              value: 'sub-theme-humidity'
            },
            {
              value: 'sub-theme-mold'
            },
            {
              value: 'sub-theme-crack'
            }
        ]
      },
      {
        value: 'theme-chimney',
        subTheme: [
            {
              value: 'sub-theme-sweeping'
            }
        ]
      },
      {
        value: 'theme-carpentry-window',
        subTheme: [
            {
              value: 'sub-theme-sealing'
            },
            {
              value: 'sub-theme-aeration-grid'
            }
        ]
      },
      {
        value: 'theme-carpentry-water-consumption',
        subTheme: [
            {
              value: 'sub-theme-invoice'
            },
            {
              value: 'sub-theme-leaks'
            }
        ]
      },
      {
        value: 'theme-rge',
        subTheme: [
            {
              value: 'sub-theme-rge'
            }
        ]
      }
]

const HabitatThemeQuestionType = () => {
  return HabitatThemeQuestionEnum
}
1.0.9

2 years ago

1.0.8

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago