Advertisement
ronaldkwandy

problem-category-picker.tsx

May 18th, 2022
955
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { PickerDefault } from 'Components/molecules/card/picker-default';
  2. import React, { useRef } from 'react';
  3. import DefaultCategoryListBs, { DISPLAYED_CATEGORY_LIST } from '../bottom-sheet/default-category-list-bs';
  4.  
  5. export interface ICategoryPicker {
  6.   className?: string;
  7.   id?: any;
  8.   data: any;
  9.   onChange: (e: any) => void;
  10.   title?: string;
  11.   noSelectLabel: string;
  12.   selectedItem?: string;
  13.   activeId?: number;
  14.   showBs?: boolean;
  15.   testingKey?: string;
  16.   isTranslate?: boolean;
  17. }
  18. interface RefObject {
  19.   openModal: () => void;
  20. }
  21.  
  22. export const CategoryPicker = (props: ICategoryPicker) => {
  23.   const subSupportRef = useRef<RefObject>(null);
  24.   const handleDataChange = (e: any) => {
  25.     props.onChange && props.onChange(e);
  26.   };
  27.   return (
  28.     <>
  29.       <PickerDefault //
  30.         className={props.className}
  31.         id={props.id}
  32.         onClick={() => subSupportRef.current?.openModal()}
  33.         noSelectLabel={props.noSelectLabel}
  34.         title={props.title}
  35.         selectedItem={props.selectedItem}
  36.         testingKey={props.testingKey}
  37.       />
  38.       <DefaultCategoryListBs //
  39.         ref={subSupportRef}
  40.         activeId={props.activeId}
  41.         content={props.data}
  42.         isShown={props.showBs}
  43.         displayedData={DISPLAYED_CATEGORY_LIST.NAME}
  44.         onChange={handleDataChange}
  45.         testingKey={props.testingKey}
  46.         isTranslate={props.isTranslate}
  47.       />
  48.     </>
  49.   );
  50. };
  51.  
  52. CategoryPicker.defaultProps = {
  53.   showBs: false,
  54. };
  55.  
  56. export default React.memo(CategoryPicker);
  57.  
Advertisement
RAW Paste Data Copied
Advertisement