Skip to content

Conversation

@ruhani2
Copy link
Contributor

@ruhani2 ruhani2 commented Oct 28, 2023

What does this PR do?

It removes the welcome card for email preview

Fixes #1491

https://watch.screencastify.com/v/kj9xb2pQK605Bw6wdl9L

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change adds a new database migration
  • This change requires a documentation update

How should this be tested?

  • Publish your survey, which will open up Share or embed your survey modal
  • Please select Embed in an Email, you can see preview with first question of the survey.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

@vercel
Copy link

vercel bot commented Oct 28, 2023

@ruhani2 is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the bug Something isn't working label Oct 28, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 28, 2023

Thank you for following the naming conventions for pull request titles! 🙏

@review-agent-prime
Copy link
Contributor

The changes in this PR seem to be mostly about refactoring and cleaning up the code, which is great. However, there are a few points that could be improved:

  1. It seems like the getEmailTemplate function is doing too much. It's handling the rendering of different types of questions, which makes it quite long and hard to read. Consider breaking it down into smaller, more manageable functions, each handling a specific question type.

  2. The EmailTemplateWrapper component is not used in the new code. If it's not needed, consider removing it to keep the codebase clean.

  3. The firstQuestion object is used multiple times in the getEmailTemplate function. It might be more efficient to destructure the properties you need from firstQuestion at the start of the function.

Here's a suggestion for the first point:

const renderOpenTextQuestion = (firstQuestion, url, brandColor) => {
  return (
    <EmailTemplateWrapper surveyUrl={url} brandColor={brandColor}>
      <Text className="m-0 mr-8 block p-0 text-base font-semibold leading-6 text-slate-800">
        {firstQuestion.headline}
      </Text>
      <Text className="m-0 block p-0 text-sm font-normal leading-6 text-slate-500">
        {firstQuestion.subheader}
      </Text>
      <Section className="mt-4 block h-20 w-full rounded-lg border border-solid border-gray-200 bg-slate-50" />
      <EmailFooter />
    </EmailTemplateWrapper>
  );
};

// Do the same for other question types...

const getEmailTemplate = (survey: TSurvey, surveyUrl: string, brandColor: string, preview: boolean) => {
  const url = preview ? `${surveyUrl}?preview=true` : surveyUrl;
  const urlWithPrefilling = preview ? `${surveyUrl}?preview=true&` : `${surveyUrl}?`;
  const firstQuestion = survey.questions[0];

  switch (firstQuestion.type) {
    case TSurveyQuestionType.OpenText:
      return renderOpenTextQuestion(firstQuestion, url, brandColor);
    // Handle other question types...
  }
};

This way, each function has a single responsibility, making the code easier to understand and maintain.

@ruhani2
Copy link
Contributor Author

ruhani2 commented Oct 28, 2023

@jobenjada I request, that you can please add a hacktoberfest label just in case it gets accepted.

@jobenjada jobenjada added hacktoberfest complete these issues to gather points for Hacktoberfest formtribe-2023 labels Oct 29, 2023
Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

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

@ruhani2 thanks a lot for the fix :-)

@mattinannt mattinannt enabled auto-merge October 30, 2023 17:08
@mattinannt mattinannt added this pull request to the merge queue Oct 30, 2023
Merged via the queue into formbricks:main with commit 07ce774 Oct 30, 2023
kevinkong91 added a commit to kevinkong91/formbricks that referenced this pull request Oct 30, 2023
* main: (28 commits)
  chore: Add Table of Contents to README (formbricks#1427)
  fix: account deletion failing issue (formbricks#1509)
  fix: remove welcome card from email preview (formbricks#1495)
  fix(bug): default role implemented (formbricks#1524)
  fix: changing description of Code Action (formbricks#1522)
  refactor: Migrate activity service (formbricks#1471)
  fix: Error in Docs navigation formbricks#1518 (formbricks#1521)
  feat: dynamic title and description (formbricks#1459)
  fix: Spelling Errors (formbricks#1517)
  fix: added scrollbar whenever overflowed in the settings/profile page (formbricks#1498)
  fix: long url not getting reset after closing modal (formbricks#1502)
  fix: Unexpected Behavior when Toggling Italics in Text Editor and improve clarity of formatting status (formbricks#1506)
  fix: zod pin validation failing (formbricks#1507)
  fix: Error message on Login not shown  (formbricks#1508)
  fix: downgrade nextjs to fix error with react email (formbricks#1516)
  chore: downgrade next version in formbricks-com (formbricks#1513)
  feat: picture selection question (formbricks#1388)
  feat: formtribe leaderboard update as per today (formbricks#1505)
  fix: Added if statement for preventing use of reserved word in question ID (formbricks#1435)
  fix: Disabling Welcome Card leads buggy preview (formbricks#1320)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hacktoberfest complete these issues to gather points for Hacktoberfest hacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Email Preview: Skip welcome card for preview

3 participants