Types.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { Dispatch, ReactElement, SetStateAction } from 'react';
  2. import { CollectionView } from '../pages/collections/Types';
  3. import { NavInfo } from '../router/Types';
  4. export type RootContextType = {
  5. openSnackBar: OpenSnackBarType;
  6. dialog: DialogType;
  7. setDialog: (params: DialogType) => void;
  8. handleCloseDialog: () => void;
  9. setDrawer: (params: any) => void;
  10. versionInfo: { attu: string; sdk: string };
  11. };
  12. // this is for any custom dialog
  13. export type DialogType = {
  14. open: boolean;
  15. type: 'notice' | 'custom';
  16. params: {
  17. title?: string;
  18. component?: React.ReactNode;
  19. confirm?: () => Promise<any>;
  20. cancel?: () => Promise<any>;
  21. confirmLabel?: string;
  22. cancelLabel?: string;
  23. confirmClass?: string;
  24. /**
  25. * Usually we control open status in root context,
  26. * if we need a hoc component depend on setDialog in context,
  27. * we may need control open status by ourself
  28. **/
  29. handleClose?: () => void;
  30. // used for dialog position
  31. containerClass?: string;
  32. };
  33. };
  34. export type SnackBarType = {
  35. open: boolean;
  36. message: string | ReactElement;
  37. type?: 'error' | 'info' | 'success' | 'warning';
  38. autoHideDuration?: number | null;
  39. horizontal: 'center' | 'left' | 'right';
  40. vertical: 'bottom' | 'top';
  41. };
  42. export type OpenSnackBarType = (
  43. message: string | ReactElement,
  44. type?: 'error' | 'info' | 'success' | 'warning',
  45. autoHideDuration?: number | null,
  46. position?: {
  47. horizontal: 'center' | 'left' | 'right';
  48. vertical: 'bottom' | 'top';
  49. }
  50. ) => void;
  51. export type AuthContextType = {
  52. isAuth: boolean;
  53. address: string;
  54. setAddress: Dispatch<SetStateAction<string>>;
  55. };
  56. export type NavContextType = {
  57. navInfo: NavInfo;
  58. setNavInfo: (param: NavInfo) => void;
  59. };
  60. export type WebSocketType = {
  61. collections: CollectionView[];
  62. setCollections: (data: CollectionView[]) => void;
  63. };