GridTitle.hooks.ts 726 B

12345678910111213141516171819202122232425262728
  1. import { useAppDispatch, useAppSelector } from '@/appflowy_app/stores/store';
  2. import { useState } from 'react';
  3. export const useGridTitleHooks = function () {
  4. const dispatch = useAppDispatch();
  5. const grid = useAppSelector((state) => state.grid);
  6. const [title, setTitle] = useState(grid.title);
  7. const [changingTitle, setChangingTitle] = useState(false);
  8. const [showOptions, setShowOptions] = useState(false);
  9. const onTitleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
  10. setTitle(event.target.value);
  11. };
  12. const onTitleClick = () => {
  13. setChangingTitle(true);
  14. };
  15. return {
  16. title,
  17. onTitleChange,
  18. onTitleClick,
  19. changingTitle,
  20. showOptions,
  21. setShowOptions,
  22. };
  23. };