Types.ts 1.6 KB

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