From 8a05bf5c41ca1607f096bbf4cf03b253df2d880c Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 30 Dec 2024 13:34:24 -0500 Subject: [PATCH] Layout tweaks and add custom other responses --- .../dashboard/TypeformDashboard.jsx | 158 ++++++++++-------- 1 file changed, 90 insertions(+), 68 deletions(-) diff --git a/dashboard/src/components/dashboard/TypeformDashboard.jsx b/dashboard/src/components/dashboard/TypeformDashboard.jsx index 993223a..0581628 100644 --- a/dashboard/src/components/dashboard/TypeformDashboard.jsx +++ b/dashboard/src/components/dashboard/TypeformDashboard.jsx @@ -113,28 +113,8 @@ const ResponseFeed = ({ responses, title, renderSummary }) => (
{responses.items.map((response) => ( -
-
-
-
- - {response.hidden?.name || 'Anonymous'} - - {response.hidden?.email && ( - - ({response.hidden.email}) - - )} -
- -
- {renderSummary(response)} -
+
+ {renderSummary(response)}
))}
@@ -152,18 +132,40 @@ const ProductRelevanceFeed = ({ responses }) => ( const textAnswer = response.answers?.find(a => a.type === 'text')?.text; return ( -
- - {answer?.boolean ? "Yes" : "No"} - +
+
+
+ {response.hidden?.email ? ( + + {response.hidden?.name || 'Anonymous'} + + ) : ( + + {response.hidden?.name || 'Anonymous'} + + )} + + {answer?.boolean ? "Yes" : "No"} + +
+ +
{textAnswer && ( - +
"{textAnswer}" - +
)}
); @@ -178,38 +180,58 @@ const WinbackFeed = ({ responses }) => ( renderSummary={(response) => { const likelihoodAnswer = response.answers?.find(a => a.type === 'number'); const reasonsAnswer = response.answers?.find(a => a.type === 'choices'); - const otherAnswer = response.answers?.find(a => a.type === 'text' && a.field.ref.includes('other')); - const feedbackAnswer = response.answers?.find(a => a.type === 'text' && !a.field.ref.includes('other')); + const feedbackAnswer = response.answers?.find(a => a.type === 'text' && a.field.type === 'long_text'); return (
-
- +
+ {response.hidden?.email ? ( + + {response.hidden?.name || 'Anonymous'} + + ) : ( + + {response.hidden?.name || 'Anonymous'} + + )} + + {likelihoodAnswer?.number}/5 + +
+
+ {format(new Date(response.submitted_at), "MMM d")} + +
+
{(reasonsAnswer?.choices?.labels || []).map((label, idx) => ( {label} ))} + {reasonsAnswer?.choices?.other && ( + + {reasonsAnswer.choices.other} + + )}
- {otherAnswer?.text && ( -
- Other:{" "} - {otherAnswer.text} -
- )} {feedbackAnswer?.text && ( -
+
{feedbackAnswer.text}
)} @@ -293,7 +315,7 @@ const TypeformDashboard = () => { ? Math.round((likelihoodAnswers.reduce((a, b) => a + b, 0) / likelihoodAnswers.length) * 10) / 10 : 0; - // Get reasons for not ordering + // Get reasons for not ordering (only predefined choices) const reasonsMap = new Map(); form2Responses.forEach(response => { const reasonsAnswer = response.answers?.find(a => a.type === 'choices'); @@ -388,7 +410,7 @@ const TypeformDashboard = () => { - +
How likely are you to place another order with us? { { - return value === "1" ? "Not at all likely" : value === "5" ? "Extremely likely" : ""; + return value === "1" ? "Not at all" : value === "5" ? "Extremely" : ""; }} textAnchor="middle" interval={0} height={50} - className="text-muted-foreground" + className="text-muted-foreground text-xs md:text-sm" /> - + { if (payload && payload.length) { @@ -459,12 +481,12 @@ const TypeformDashboard = () => { - -
+ +
Were the suggested products in this email relevant to you?
- {metrics.productRelevance.yesPercentage}% Positive + {metrics.productRelevance.yesPercentage}% Relevant
@@ -513,7 +535,7 @@ const TypeformDashboard = () => { return null; }} /> - + { {metrics.productRelevance.yesPercentage}% - +
@@ -537,8 +559,8 @@ const TypeformDashboard = () => {
-
-
+
+
Reasons for Not Ordering @@ -568,10 +590,10 @@ const TypeformDashboard = () => {
-
+
-
+