Skip to content

Commit 908ca80

Browse files
authored
Fix scenario editor (#128)
* Fix ScenarioEditor error OPENHEXA-C4 * Sentry: add user information to sentry payload
1 parent 306b7c1 commit 908ca80

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/features/analysis/AccessibilityAnalysisForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ const AccessibilityAnalysisForm = (props: Props) => {
147147
}
148148
const { success, errors } = data.updateAccessmodAccessibilityAnalysis;
149149

150-
if (success) return;
150+
if (success) {
151+
return;
152+
}
151153

152154
if (
153155
errors.includes(UpdateAccessmodAccessibilityAnalysisError.NameDuplicate)
@@ -158,7 +160,7 @@ const AccessibilityAnalysisForm = (props: Props) => {
158160
});
159161

160162
useEffect(() => {
161-
if (form.isDirty) {
163+
if (form.isDirty && form.previousFormData !== form.formData) {
162164
form.handleSubmit();
163165
}
164166
}, [form]);

src/features/dataset/ScenarioEditor.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const ScenarioEditor = (props: ScenarioEditorProps) => {
2727
},
2828
[data, onChange]
2929
);
30+
3031
const handleRowRemove = useCallback(
3132
(index: number) => {
3233
const newData = data.filter((_, i) => i !== index);
@@ -35,11 +36,13 @@ const ScenarioEditor = (props: ScenarioEditorProps) => {
3536
},
3637
[data, onChange]
3738
);
39+
3840
const handleRowAdd = useCallback(() => {
3941
const newData = data.concat({ kls: `class ${data.length + 1}`, speed: 0 });
4042
setData(newData);
4143
onChange(newData);
4244
}, [data, onChange]);
45+
4346
const handleUpload = useCallback(
4447
(event: ChangeEvent<HTMLInputElement>) => {
4548
if (event.target.files && event.target.files.length === 1) {
@@ -126,13 +129,13 @@ const ScenarioEditor = (props: ScenarioEditorProps) => {
126129
</tr>
127130
</thead>
128131
<tbody>
129-
{scenario.map((row, i) => {
132+
{data.map((row, i) => {
130133
return (
131134
<tr key={i}>
132135
<td className="whitespace-nowrap px-3 py-1 text-sm font-medium text-gray-800 md:py-2">
133136
<Input
134137
className="w-full"
135-
value={data[i].kls}
138+
value={row.kls}
136139
onChange={(e) =>
137140
handleRowChange(i, "kls", e.target.value)
138141
}
@@ -142,7 +145,7 @@ const ScenarioEditor = (props: ScenarioEditorProps) => {
142145
<td className="whitespace-nowrap px-3 py-1 text-sm font-medium text-gray-800 md:py-2">
143146
<Input
144147
className="w-full"
145-
value={data[i].speed}
148+
value={row.speed}
146149
onChange={(e) =>
147150
handleRowChange(i, "speed", e.target.value)
148151
}

src/pages/_app.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { Settings } from "luxon";
77
import { appWithTranslation } from "next-i18next";
88
import Head from "next/head";
99
import NavigationProgress from "nextjs-progressbar";
10+
import { useEffect } from "react";
11+
import * as Sentry from "@sentry/nextjs";
12+
1013
import "../styles/globals.css";
1114

1215
Settings.defaultLocale = "en";
@@ -19,6 +22,14 @@ function CustomApp({ Component, pageProps }: AppPropsWithLayout) {
1922
Component.getLayout ??
2023
((page) => <Layout pageProps={pageProps}>{page}</Layout>);
2124

25+
useEffect(() => {
26+
Sentry.setUser(
27+
pageProps.user
28+
? { email: pageProps.user.email, id: pageProps.user.id }
29+
: null
30+
);
31+
}, [pageProps.user]);
32+
2233
return (
2334
<>
2435
<NavigationProgress color="#002C5F" height={3} />

0 commit comments

Comments
 (0)