Skip to content

Commit

Permalink
fix: reset persisted reportstate
Browse files Browse the repository at this point in the history
  • Loading branch information
okorie2 committed Nov 14, 2023
1 parent 98f35dd commit 513d0a5
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/app/modules/report-module/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export default function ReportModule() {
rowFrame.content.length === 1 &&
rowFrame.content[0] === ReportElementsType.DIVIDER;

const content = rowFrame.items.map((item, index) => {
const content = rowFrame?.items?.map((item, index) => {
return rowFrame.contentTypes[index] === "text"
? EditorState.createWithContent(convertFromRaw(item as any))
: item;
Expand All @@ -292,7 +292,7 @@ export default function ReportModule() {
},

type: rowFrame.type,
content,
content: content ?? [],
contentWidths: rowFrame.contentWidths,
contentHeights: rowFrame.contentHeights,
contentTypes: rowFrame.contentTypes,
Expand Down Expand Up @@ -394,6 +394,48 @@ export default function ReportModule() {

const resetReport = () => {
const id = v4();
setPersistedReportState({
reportName: "Untitled report",
headerDetails: {
title: "",
description: JSON.stringify(
convertToRaw(EditorState.createEmpty().getCurrentContent())
),
showHeader: true,
backgroundColor: "#252c34",
titleColor: "#ffffff",
descriptionColor: "#ffffff",
dateColor: "#ffffff",
},
appliedHeaderDetails: {
title: "",
description: JSON.stringify(
convertToRaw(EditorState.createEmpty().getCurrentContent())
),
showHeader: true,
backgroundColor: "#252c34",
titleColor: "#ffffff",
descriptionColor: "#ffffff",
dateColor: "#ffffff",
},
framesArray: JSON.stringify([
{
id,
frame: {
rowIndex: 0,
rowId: id,
handlePersistReportState,
handleRowFrameItemResize,
type: "rowFrame",
},
content: [],
contentWidths: [],
contentHeights: [],
contentTypes: [],
structure: null,
},
]),
});
setFramesArray([
{
id,
Expand Down

0 comments on commit 513d0a5

Please sign in to comment.