Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { memo } from 'react';
  2. import { connect } from 'react-redux';
  3. import {
  4.   getVideoTable,
  5.   getVideoTableIsLoading,
  6.   getVideoTableIsLoadingFailed,
  7.   updateVideoFetchSaga,
  8.   removeVideoFetchSaga,
  9. } from '@/pages/home/_redux/get-video-module';
  10. import { Action } from '@/services/redux/_types';
  11. // import { FontSizeType } from '@/_components/text';
  12. // import { Table } from '../make-table';
  13. // import { AddVideoForm } from './_components/add-video-form';
  14. // import { EditVideoForm } from './_components/edit-video-form';
  15. import { Table } from '../table';
  16.  
  17. type IProps = {
  18.   videoData: Array<any>;
  19.   onShowModal(...title: any): void;
  20.   onCloseModal(): void;
  21.   isLoading: boolean;
  22.   isError: boolean | string;
  23.   updateVideo: any;
  24.   removeVideo: Action<string>;
  25. };
  26.  
  27. const Wrapper = memo(
  28.   ({
  29.     videoData,
  30.     onShowModal,
  31.     onCloseModal,
  32.     isLoading,
  33.     isError,
  34.     updateVideo,
  35.     removeVideo,
  36.   }: IProps) => {
  37.     const onAddNewVideo = () => {
  38.       // onShowModal(
  39.       //   'Добавить видео',
  40.       //   <AddVideoForm onCloseModal={onCloseModal} dispatch={dispatch} />,
  41.       // );
  42.     };
  43.  
  44.     const onEditVideo = id => {
  45.       console.log('Edit', id);
  46.       // const finded = video.find(elem => elem.id === id);
  47.       // onShowModal(
  48.       //   'Редактировать',
  49.       //   <EditVideoForm
  50.       //     onCloseModal={onCloseModal}
  51.       //     dispatch={dispatch}
  52.       //     editFormData={finded}
  53.       //   />,
  54.       // );
  55.     };
  56.  
  57.     const onRemoveVideo = id => {
  58.       removeVideo(id);
  59.     };
  60.  
  61.     return (
  62.       <Table
  63.         data={videoData}
  64.         onAddNew={onAddNewVideo}
  65.         onEdit={onEditVideo}
  66.         onRemove={removeVideo}
  67.       />
  68.     );
  69.   },
  70. );
  71.  
  72. const mapStateToProps = state => {
  73.   return {
  74.     videoData: getVideoTable(state),
  75.     isLoading: getVideoTableIsLoading(state),
  76.     isError: getVideoTableIsLoadingFailed(state),
  77.   };
  78. };
  79.  
  80. // const mapDispatchToProps = () => ({
  81. //   updateVideo: updateVideoFetchSaga,
  82. //   removeVideo: removeVideoFetchSaga,
  83. // });
  84.  
  85. export const VideoPage = connect(
  86.   mapStateToProps,
  87.   {
  88.     removeVideo: removeVideoFetchSaga,
  89.   },
  90. )(Wrapper);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement