From ccad52e93cec5ee677982e36585a0ec4794f0247 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 3 Aug 2023 15:05:52 +0300 Subject: [PATCH] feat(nx-dev): when feedback button is pressed hide buttons (#18141) --- nx-dev/feature-ai/src/lib/feature-ai.tsx | 81 ++++++++++++++---------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/nx-dev/feature-ai/src/lib/feature-ai.tsx b/nx-dev/feature-ai/src/lib/feature-ai.tsx index 733681efe036c..f2e57f852d87f 100644 --- a/nx-dev/feature-ai/src/lib/feature-ai.tsx +++ b/nx-dev/feature-ai/src/lib/feature-ai.tsx @@ -10,13 +10,13 @@ export function FeatureAi(): JSX.Element { const [error, setError] = useState(null); const [query, setSearchTerm] = useState(''); const [loading, setLoading] = useState(false); + const [feedbackSent, setFeedbackSent] = useState(false); const warning = ` {% callout type="warning" title="Always double check!" %} This feature is still in Alpha. The results may not be accurate, so please always double check with our documentation. {% /callout %} - `; const handleSubmit = async () => { @@ -33,11 +33,24 @@ export function FeatureAi(): JSX.Element { setLoading(false); } sendCustomEvent('ai_query', 'ai', 'query', undefined, { query, ...usage }); + setFeedbackSent(false); setFinalResult( renderMarkdown(warning + completeText, { filePath: '' }).node ); }; + const handleFeedback = (type: 'good' | 'bad') => { + try { + sendCustomEvent('ai_feedback', 'ai', type, undefined, { + query, + result: finalResult, + }); + setFeedbackSent(true); + } catch (error) { + setFeedbackSent(false); + } + }; + return (
Thinking...
) : null} - {finalResult && !error ? ( + {finalResult && !loading && !error ? ( <>
{finalResult}
-
- - -
+ {!feedbackSent && ( +
+ + +
+ )} + {feedbackSent && ( +

+ + ✅ + {' '} + Thank you for your feedback! +

+ )} ) : null} {error ?
There was an error: {error['message']}
: null}