Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/components/rich-text-editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export const RichEditor: React.FC<{
autofocus: true,
content: selectedItem?.data?.rte || "",
editable: !viewMode,
onUpdate: ({ editor }) => {
onUpdate: ({ editor: updatedEditor }) => {
if (selectedItem) {
editItem({
...selectedItem,
data: {
...selectedItem.data,
rte: editor.getJSON(),
rte: updatedEditor.getJSON(),
},
});
}
Expand Down
13 changes: 13 additions & 0 deletions src/app/hooks/queries/report-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,3 +651,16 @@ export const useFilteredDatasetPage = ({
placeholderData: (previousData) => previousData,
});
};

export const useSendErrorReport = () => {
return useMutation({
mutationKey: ["ReportBuilderSendErrorReport"],
mutationFn: (data: {
action: string | null;
details: string;
reportId: string | undefined;
reportName: string | undefined;
errorMessage: string | null;
}) => axiosInstance.post(`/report/report-an-error`, data),
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,7 @@ export const ReportBuilderPageHeader: React.FC = () => {
reportId={id}
reportName={name}
error={updateReport.error}
onSubmit={(payload) => {
console.log("Report issue submitted:", payload);
onSubmitted={() => {
setSnackbarMessage(
"Thank you for reporting the issue. We will look into it.",
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface ReportBuilderReportIssueSubmitPayload {
export interface ReportBuilderReportIssueModalProps {
open: boolean;
onClose: () => void;
onSubmit?: (payload: ReportBuilderReportIssueSubmitPayload) => void;
onSubmitted?: () => void;
activityOptions?: string[];
maxDetailsLength?: number;
reportId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import {
ReportBuilderReportIssueModalProps,
} from "app/pages/report-builder/main/components/report-issue-modal/data";
import { format } from "date-fns";
import { useSendErrorReport } from "app/hooks/queries/report-builder";

export const ReportBuilderReportIssueModal: React.FC<
ReportBuilderReportIssueModalProps
> = ({
open,
onClose,
onSubmit,
onSubmitted,
reportId,
reportName,
error,
Expand All @@ -36,17 +37,24 @@ export const ReportBuilderReportIssueModal: React.FC<
);
};

const sendErrorReport = useSendErrorReport();

const handleDetailsChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
if (e.target.value.length <= maxDetailsLength) {
setDetails(e.target.value);
}
};

const handleSubmit = () => {
onSubmit?.({
activity: selectedActivity,
const payload = {
action: selectedActivity,
details,
});
reportId,
reportName,
errorMessage: error?.message || null,
};
sendErrorReport.mutate(payload);
onSubmitted?.();
};

React.useEffect(() => {
Expand Down Expand Up @@ -342,7 +350,7 @@ export const ReportBuilderReportIssueModal: React.FC<
},
}}
>
Send Report
{sendErrorReport.isPending ? "Reporting..." : "Send Report"}
</Button>
</Box>
</Box>
Expand Down