|
@@ -1,23 +1,34 @@
|
|
|
-import React from 'react';
|
|
|
|
|
|
|
+import React, { useCallback } from 'react';
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
import {
|
|
import {
|
|
|
ModalHeader, ModalBody, ModalFooter, Input,
|
|
ModalHeader, ModalBody, ModalFooter, Input,
|
|
|
} from 'reactstrap';
|
|
} from 'reactstrap';
|
|
|
|
|
|
|
|
|
|
+import { AiAssistantShareScope } from '~/features/openai/interfaces/ai-assistant';
|
|
|
|
|
+import { useCurrentUser } from '~/stores-universal/context';
|
|
|
|
|
+
|
|
|
import { useAiAssistantManagementModal, AiAssistantManagementModalPageMode } from '../../../stores/ai-assistant';
|
|
import { useAiAssistantManagementModal, AiAssistantManagementModalPageMode } from '../../../stores/ai-assistant';
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
instruction: string;
|
|
instruction: string;
|
|
|
|
|
+ shareScope: AiAssistantShareScope
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const AiAssistantManagementHome = (props: Props): JSX.Element => {
|
|
export const AiAssistantManagementHome = (props: Props): JSX.Element => {
|
|
|
- const { instruction } = props;
|
|
|
|
|
|
|
+ const { instruction, shareScope } = props;
|
|
|
|
|
|
|
|
const { t } = useTranslation();
|
|
const { t } = useTranslation();
|
|
|
-
|
|
|
|
|
|
|
+ const { data: currentUser } = useCurrentUser();
|
|
|
const { close: closeAiAssistantManagementModal, changePageMode } = useAiAssistantManagementModal();
|
|
const { close: closeAiAssistantManagementModal, changePageMode } = useAiAssistantManagementModal();
|
|
|
|
|
|
|
|
|
|
+ const getShareScopeLabel = useCallback((shareScope: AiAssistantShareScope) => {
|
|
|
|
|
+ const baseLabel = `modal_ai_assistant.share_scope.${shareScope}.label`;
|
|
|
|
|
+ return shareScope === AiAssistantShareScope.OWNER
|
|
|
|
|
+ ? t(baseLabel, { username: currentUser?.username })
|
|
|
|
|
+ : t(baseLabel);
|
|
|
|
|
+ }, [currentUser?.username, t]);
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
<ModalHeader tag="h4" toggle={closeAiAssistantManagementModal} className="pe-4">
|
|
<ModalHeader tag="h4" toggle={closeAiAssistantManagementModal} className="pe-4">
|
|
@@ -59,7 +70,7 @@ export const AiAssistantManagementHome = (props: Props): JSX.Element => {
|
|
|
>
|
|
>
|
|
|
<span className="fw-normal">{t('modal_ai_assistant.page_mode_title.share')}</span>
|
|
<span className="fw-normal">{t('modal_ai_assistant.page_mode_title.share')}</span>
|
|
|
<div className="d-flex align-items-center text-secondary">
|
|
<div className="d-flex align-items-center text-secondary">
|
|
|
- <span>UserNameのみ</span>
|
|
|
|
|
|
|
+ <span>{getShareScopeLabel(shareScope)}</span>
|
|
|
<span className="material-symbols-outlined ms-2 align-middle">chevron_right</span>
|
|
<span className="material-symbols-outlined ms-2 align-middle">chevron_right</span>
|
|
|
</div>
|
|
</div>
|
|
|
</button>
|
|
</button>
|