Skip to content

Conversation

@prd-duy-huynh
Copy link

Code change

  • Render result

@prd-duy-huynh prd-duy-huynh requested a review from Copilot July 24, 2025 10:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements support for generic surveys/assessments in the Traitify widget system. The implementation adds a complete generic survey flow including taking the survey, submitting responses, and viewing results.

  • Adds generic assessment query handling and GraphQL integration
  • Implements complete generic survey UI components with progress tracking, question sets, and modal instructions
  • Creates comprehensive results display with scoring, breakdown, and individual question analysis

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lib/recoil/assessment.js Adds generic assessment query and integrates it into the assessment selector
src/lib/graphql/index.js Exports new generic GraphQL module
src/lib/graphql/generic.js Defines GraphQL queries and mutations for generic surveys
src/components/survey/index.js Adds generic survey routing
src/components/survey/generic/* Complete generic survey implementation with styling, responses, question sets, and container
src/components/results/index.js Adds generic results routing
src/components/results/generic/* Complete results display with header, scoring, breakdown, and question analysis
src/components/common/modal/index.js Adds containerClass prop for custom modal styling
public/index.js Adds generic survey setup and creation functionality
package.json Version bump to 3.8.0
Comments suppressed due to low confidence (4)

src/components/results/generic/header.js:1

  • The import should use 'PropTypes' with a capital P to match the standard naming convention used throughout the codebase.
import propTypes from "prop-types";

src/components/results/generic/header.js:22

  • Should use 'PropTypes' instead of 'propTypes' to match the import and standard convention.
  profile: propTypes.shape({

src/components/results/generic/header.js:26

  • Should use 'PropTypes' instead of 'propTypes' to match the import and standard convention.
  assessment: propTypes.shape({

}

const assessment = response.data.genericSurveyQuestions;
if(!assessment?.length || !assessment?.completedAt) { return assessment; }
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition !assessment?.length is checking for an array length property on what should be an assessment object. Based on the API response structure, this should likely check !assessment?.survey?.questionSets?.length or similar property instead.

Suggested change
if(!assessment?.length || !assessment?.completedAt) { return assessment; }
if(!assessment?.survey?.questionSets?.length || !assessment?.completedAt) { return assessment; }

Copilot uses AI. Check for mistakes.

http.post(graphQL.generic.path, {query, variables}).then(({data, errors}) => {
if(!errors && data.genericAssessmentResult) {
console.log("Generic assessment result data:", data.genericAssessmentResult);
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug console.log statements should not be left in production code. This should be removed or replaced with proper logging.

Copilot uses AI. Check for mistakes.
Copy link
Member

@tomprats tomprats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the survey looks really nice! Couple of things required for that:

  • translations
  • css - keeping it shallow, using theme helper for colors, alphabetize properties!

I haven't been able to render the results, I get the following error in the generic survey component (feel free to follow up in slack about this):

TypeError: can't access property "survey", assessment is null

Copy link
Member

@tomprats tomprats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing a quick grep to see where cognitive is that's missing generic, I found these:

  • ./src/lib/hooks/use-skip-assessment.js - Are there endpoints for skipping generic?
  • ./src/lib/common/order-from-query.js - Recommendation, also using it in the recoil query

@prd-duy-huynh
Copy link
Author

@tomprats

Are there endpoints for skipping generic?

Recommendation, also using it in the recoil query

Let me discuss with Ryan

@prd-duy-huynh
Copy link
Author

@tomprats let's wrap this up. Skipping and recommendation logic will be handled in another PR later

Survey: {
Cognitive: CognitiveSurvey,
Container: Survey,
GenericSurvey,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent let's make this Generic: GenericSurvey,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to add the results as well at Results.Generic

Copy link
Member

@tomprats tomprats Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need using Generic: GenericSurvey and also adding the results component

Copy link
Member

@tomprats tomprats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments are all relatively minor, but the main things left are:

  • mobile - several things break out of their containers on smaller screen sizes
  • tests

Survey: {
Cognitive: CognitiveSurvey,
Container: Survey,
GenericSurvey,
Copy link
Member

@tomprats tomprats Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need using Generic: GenericSurvey and also adding the results component

Copy link
Member

@tomprats tomprats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Looks great!

Just want to make sure the generic service is out in prod before merging this. We also want to make sure the translations are in Contentful so next time we sync they'll still come over (and hopefully will bring more translations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants