|
@@ -5,18 +5,18 @@ import {
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter,
|
|
Modal, ModalHeader, ModalBody, ModalFooter,
|
|
|
} from 'reactstrap';
|
|
} from 'reactstrap';
|
|
|
|
|
|
|
|
|
|
+import { IQuestionnaireOrderHasId } from '~/interfaces/questionnaire/questionnaire-order';
|
|
|
import { useQuestionnaireModal } from '~/stores/modal';
|
|
import { useQuestionnaireModal } from '~/stores/modal';
|
|
|
-import { useSWRxQuestionnaireOrders } from '~/stores/questionnaire';
|
|
|
|
|
|
|
|
|
|
import Question from './Question';
|
|
import Question from './Question';
|
|
|
|
|
|
|
|
-const QuestionnaireModal = (): JSX.Element => {
|
|
|
|
|
- const { data: questionnaireModalData, close: closeQuestionnaireModal } = useQuestionnaireModal();
|
|
|
|
|
- const isOpened = questionnaireModalData?.isOpened;
|
|
|
|
|
-
|
|
|
|
|
- const { data: questionnaireOrders } = useSWRxQuestionnaireOrders();
|
|
|
|
|
|
|
+type QuestionnaireModalProps = {
|
|
|
|
|
+ questionnaireOrder: IQuestionnaireOrderHasId
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- const questions = questionnaireOrders?.flatMap(questionnaireOrder => questionnaireOrder.questions);
|
|
|
|
|
|
|
+const QuestionnaireModal = ({ questionnaireOrder }: QuestionnaireModalProps): JSX.Element => {
|
|
|
|
|
+ const { data: questionnaireModalData, close: closeQuestionnaireModal } = useQuestionnaireModal();
|
|
|
|
|
+ const isOpened = questionnaireModalData?.[questionnaireOrder._id];
|
|
|
|
|
|
|
|
const [answered, setAnswered] = useState(false);
|
|
const [answered, setAnswered] = useState(false);
|
|
|
|
|
|
|
@@ -25,22 +25,22 @@ const QuestionnaireModal = (): JSX.Element => {
|
|
|
return (<Modal
|
|
return (<Modal
|
|
|
size="lg"
|
|
size="lg"
|
|
|
isOpen={isOpened}
|
|
isOpen={isOpened}
|
|
|
- toggle={() => closeQuestionnaireModal()}
|
|
|
|
|
|
|
+ toggle={() => closeQuestionnaireModal(questionnaireOrder._id)}
|
|
|
>
|
|
>
|
|
|
<ModalHeader
|
|
<ModalHeader
|
|
|
tag="h4"
|
|
tag="h4"
|
|
|
- toggle={() => closeQuestionnaireModal()}
|
|
|
|
|
|
|
+ toggle={() => closeQuestionnaireModal(questionnaireOrder._id)}
|
|
|
className="bg-primary text-light">
|
|
className="bg-primary text-light">
|
|
|
{answered
|
|
{answered
|
|
|
? <span className="mr-auto">{t('questionnaire.thank you for answering')}</span>
|
|
? <span className="mr-auto">{t('questionnaire.thank you for answering')}</span>
|
|
|
- : <span>アンケートのタイトル</span>
|
|
|
|
|
|
|
+ : <span>{t('questionnaire.Give us feedback for improvements')}</span>
|
|
|
}
|
|
}
|
|
|
</ModalHeader>
|
|
</ModalHeader>
|
|
|
<ModalBody className="my-4">
|
|
<ModalBody className="my-4">
|
|
|
{answered
|
|
{answered
|
|
|
? <>その他ご意見ご要望は<a href="">こちら</a>からお願い致します。</>
|
|
? <>その他ご意見ご要望は<a href="">こちら</a>からお願い致します。</>
|
|
|
: <div className="container">
|
|
: <div className="container">
|
|
|
- <h3 className="grw-modal-head">{t('questionnaire.Give us feedback for improvements')}</h3>
|
|
|
|
|
|
|
+ <h3 className="grw-modal-head">{questionnaireOrder.title}</h3>
|
|
|
<div className="row mt-4">
|
|
<div className="row mt-4">
|
|
|
<div className="col-6"></div>
|
|
<div className="col-6"></div>
|
|
|
<div className="col-1 p-0 font-weight-bold text-center">{t('questionnaire.no answer')}</div>
|
|
<div className="col-1 p-0 font-weight-bold text-center">{t('questionnaire.no answer')}</div>
|
|
@@ -49,7 +49,7 @@ const QuestionnaireModal = (): JSX.Element => {
|
|
|
<span className="font-weight-bold pr-3">{t('questionnaire.agree')}</span>
|
|
<span className="font-weight-bold pr-3">{t('questionnaire.agree')}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- {questions?.map((question) => {
|
|
|
|
|
|
|
+ {questionnaireOrder.questions?.map((question) => {
|
|
|
return <Question question={question} key={question._id.toString()}/>;
|
|
return <Question question={question} key={question._id.toString()}/>;
|
|
|
})}
|
|
})}
|
|
|
</div>
|
|
</div>
|
|
@@ -57,7 +57,7 @@ const QuestionnaireModal = (): JSX.Element => {
|
|
|
</ModalBody>
|
|
</ModalBody>
|
|
|
<ModalFooter>
|
|
<ModalFooter>
|
|
|
{answered
|
|
{answered
|
|
|
- ? <button type="button" className="btn btn-primary" onClick={() => closeQuestionnaireModal()}>{t('Close')}</button>
|
|
|
|
|
|
|
+ ? <button type="button" className="btn btn-primary" onClick={() => closeQuestionnaireModal(questionnaireOrder._id)}>{t('Close')}</button>
|
|
|
: <>
|
|
: <>
|
|
|
<div className="form-check form-check-inline mr-4">
|
|
<div className="form-check form-check-inline mr-4">
|
|
|
<input className="form-check-input" type="checkbox"/>
|
|
<input className="form-check-input" type="checkbox"/>
|