Commit 33e12ad8 by Liu

fix:点踩反馈逻辑

parent 3256bd57
import { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader } from '@heroui/react' import { Button, Modal, ModalBody, ModalContent, ModalFooter, ModalHeader, Textarea } from '@heroui/react'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { fetchGetFeedbackConfig, fetchSubmitFeedback } from '@/api/chat' import { fetchGetFeedbackConfig, fetchSubmitFeedback } from '@/api/chat'
import type { Answer } from '@/types/chat' import type { Answer } from '@/types/chat'
...@@ -11,7 +11,7 @@ interface UnLikeModalProps { ...@@ -11,7 +11,7 @@ interface UnLikeModalProps {
export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answer }) => { export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answer }) => {
const [feedbackConfig, setFeedbackConfig] = useState<any>() const [feedbackConfig, setFeedbackConfig] = useState<any>()
const [answerValue] = useState('') const [answerValue, setAnswerValue] = useState('')
const getConfig = async () => { const getConfig = async () => {
const res = await fetchGetFeedbackConfig() const res = await fetchGetFeedbackConfig()
if (res.ok) { if (res.ok) {
...@@ -19,22 +19,32 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe ...@@ -19,22 +19,32 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe
} }
} }
const handleClick = (item: any, index: number) => { const handleClick = (_item: any, index: number) => {
if (!feedbackConfig)
return
const _data = JSON.parse(JSON.stringify(feedbackConfig)) const _data = JSON.parse(JSON.stringify(feedbackConfig))
item.answerValue = item.answerValue === '1' ? '0' : '1' _data.questionList[0].answerList = _data.questionList[0].answerList.map((item: any, idx: number) =>
_data.questionList[0].answerList[index] = item idx === index
? {
...item,
answerValue: item.answerValue === '1' ? '0' : '1',
}
: item,
)
setFeedbackConfig(_data) setFeedbackConfig(_data)
} }
const onSubmit = async () => { const onSubmit = async () => {
const content = JSON.parse(JSON.stringify(feedbackConfig)) const content = JSON.parse(JSON.stringify(feedbackConfig))
content.questionList[0].answerList = content.questionList[0].answerList.filter(
(item: any) => item.answerValue === '1',
)
content.questionList[1].answerValue = answerValue content.questionList[1].answerValue = answerValue
const params = { const params = {
recordId: answer.recordId, recordId: answer.recordId,
feedbackStatus: '02', feedbackStatus: '02',
content: JSON.stringify(content), content: JSON.stringify(content),
} }
const res = await fetchSubmitFeedback(params) const res = await fetchSubmitFeedback(params)
if (res) { if (res) {
onClose(true) onClose(true)
...@@ -53,7 +63,7 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe ...@@ -53,7 +63,7 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe
<ModalContent> <ModalContent>
{onClose => ( {onClose => (
<> <>
<ModalHeader className="flex flex-col gap-1">你的反馈将帮助 晓得 优化进步</ModalHeader> <ModalHeader className="flex flex-col gap-1">感谢您的反馈!</ModalHeader>
<ModalBody className="text-[#27353C]"> <ModalBody className="text-[#27353C]">
<div className="flex flex-wrap gap-[6px]"> <div className="flex flex-wrap gap-[6px]">
{feedbackConfig && feedbackConfig.questionList[0].answerList.map((item: any, index: number) => ( {feedbackConfig && feedbackConfig.questionList[0].answerList.map((item: any, index: number) => (
...@@ -72,13 +82,13 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe ...@@ -72,13 +82,13 @@ export const UnLikeModal: React.FC<UnLikeModalProps> = ({ isOpen, onClose, answe
</Button> </Button>
) )
))} ))}
{/* <Textarea <Textarea
value={answerValue} value={answerValue}
onValueChange={setAnswerValue} onValueChange={setAnswerValue}
label="留下更多反馈" label="可在此详细描述您所遇到的问题"
placeholder="" placeholder=""
className="w-full mt-[10px]" className="w-full mt-[10px]"
/> */} />
</div> </div>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment