|
@@ -3,12 +3,12 @@ import React, { useState, useCallback } from 'react';
|
|
|
import type { Nullable, IUserHasId } from '@growi/core';
|
|
import type { Nullable, IUserHasId } from '@growi/core';
|
|
|
import { pagePathUtils } from '@growi/core/dist/utils';
|
|
import { pagePathUtils } from '@growi/core/dist/utils';
|
|
|
import { format } from 'date-fns';
|
|
import { format } from 'date-fns';
|
|
|
-import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
import { useOnTemplateButtonClicked } from '~/client/services/use-on-template-button-clicked';
|
|
import { useOnTemplateButtonClicked } from '~/client/services/use-on-template-button-clicked';
|
|
|
import { toastError } from '~/client/util/toastr';
|
|
import { toastError } from '~/client/util/toastr';
|
|
|
import { LabelType } from '~/interfaces/template';
|
|
import { LabelType } from '~/interfaces/template';
|
|
|
-import { useCurrentUser } from '~/stores/context';
|
|
|
|
|
|
|
+import { useCurrentUser, useIsGuestUser } from '~/stores/context';
|
|
|
|
|
+import { useCurrentPagePath } from '~/stores/page';
|
|
|
|
|
|
|
|
import { CreateButton } from './CreateButton';
|
|
import { CreateButton } from './CreateButton';
|
|
|
import { DropendMenu } from './DropendMenu';
|
|
import { DropendMenu } from './DropendMenu';
|
|
@@ -26,8 +26,6 @@ const generateTodaysPath = (currentUser?: Nullable<IUserHasId>, isGuestUser?: bo
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export const PageCreateButton = React.memo((): JSX.Element => {
|
|
export const PageCreateButton = React.memo((): JSX.Element => {
|
|
|
- const { t } = useTranslation('commons');
|
|
|
|
|
-
|
|
|
|
|
const { data: currentPagePath, isLoading } = useCurrentPagePath();
|
|
const { data: currentPagePath, isLoading } = useCurrentPagePath();
|
|
|
const { data: currentUser } = useCurrentUser();
|
|
const { data: currentUser } = useCurrentUser();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
@@ -37,7 +35,7 @@ export const PageCreateButton = React.memo((): JSX.Element => {
|
|
|
const todaysPath = generateTodaysPath(currentUser, isGuestUser);
|
|
const todaysPath = generateTodaysPath(currentUser, isGuestUser);
|
|
|
|
|
|
|
|
const { onClickHandler: onClickNewButton, isPageCreating: isNewPageCreating } = useOnNewButtonClicked(currentPagePath, isLoading);
|
|
const { onClickHandler: onClickNewButton, isPageCreating: isNewPageCreating } = useOnNewButtonClicked(currentPagePath, isLoading);
|
|
|
- const { onClickHandler: onClickTodaysButton, isPageCreating: isTodaysPageCreating } = useOnTodaysButtonClicked(todaysPath, currentUser);
|
|
|
|
|
|
|
+ const { onClickHandler: onClickTodaysButton, isPageCreating: isTodaysPageCreating } = useOnTodaysButtonClicked(todaysPath);
|
|
|
const { onClickHandler: onClickTemplateButton, isPageCreating: isTemplatePageCreating } = useOnTemplateButtonClicked(currentPagePath, isLoading);
|
|
const { onClickHandler: onClickTemplateButton, isPageCreating: isTemplatePageCreating } = useOnTemplateButtonClicked(currentPagePath, isLoading);
|
|
|
|
|
|
|
|
const onClickTemplateButtonHandler = useCallback(async(label: LabelType) => {
|
|
const onClickTemplateButtonHandler = useCallback(async(label: LabelType) => {
|