Skip to content

Commit

Permalink
fix: parse draft discussions for csv (#10540)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Dec 2, 2024
1 parent 2f59f38 commit 3d9032e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {generateText} from '@tiptap/core'
import graphql from 'babel-plugin-relay/macro'
import type {Parser as JSON2CSVParser} from 'json2csv'
import Parser from 'json2csv/lib/JSON2CSVParser' // only grab the sync parser
Expand All @@ -7,6 +8,8 @@ import extractTextFromDraftString from 'parabol-client/utils/draftjs/extractText
import withMutationProps, {WithMutationProps} from 'parabol-client/utils/relay/withMutationProps'
import {useEffect} from 'react'
import useAtmosphere from '~/hooks/useAtmosphere'
import {isDraftJSContent} from '../../../../shared/tiptap/isDraftJSContent'
import {serverTipTapExtensions} from '../../../../shared/tiptap/serverTipTapExtensions'
import {ExternalLinks, PokerCards} from '../../../../types/constEnums'
import {CorsOptions} from '../../../../types/cors'
import AnchorIfEmail from './MeetingSummaryEmail/AnchorIfEmail'
Expand Down Expand Up @@ -242,7 +245,10 @@ const ExportToCSV = (props: Props) => {
const {node} = edge
const {createdAt, createdByUser, __typename: type, replies, content} = node
const author = createdByUser?.preferredName ?? 'Anonymous'
const discussionThread = extractTextFromDraftString(content!)
const contentJSON = JSON.parse(content!)
const discussionThread = isDraftJSContent(contentJSON)
? extractTextFromDraftString(content!)
: generateText(contentJSON, serverTipTapExtensions)
rows.push({
reflectionGroup: title!,
author,
Expand Down

0 comments on commit 3d9032e

Please sign in to comment.