Skip to content

Commit d613c14

Browse files
committed
feat: use debounced variables for field report title generation
1 parent 0686327 commit d613c14

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

app/src/views/FieldReportForm/ContextFields/TitlePreview/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TextOutput } from '@ifrc-go/ui';
33
import { useTranslation } from '@ifrc-go/ui/hooks';
44

55
import useAlert from '#hooks/useAlert';
6+
import useDebouncedValue from '#hooks/useDebouncedValue';
67
import { useRequest } from '#utils/restRequest';
78

89
import i18n from './i18n.json';
@@ -38,12 +39,14 @@ function TitlePreview(props: Props) {
3839
title,
3940
}), [country, isCovidReport, startDate, disasterType, event, title]);
4041

42+
const debouncedVariables = useDebouncedValue(variables);
43+
4144
const {
42-
response: genereateTitleResponse,
45+
response: generateTitleResponse,
4346
} = useRequest({
4447
url: '/api/v2/field-report/generate-title/',
4548
method: 'POST',
46-
body: variables,
49+
body: debouncedVariables,
4750
preserveResponse: true,
4851
onFailure: () => {
4952
alert.show(
@@ -57,7 +60,7 @@ function TitlePreview(props: Props) {
5760

5861
return (
5962
<TextOutput
60-
value={genereateTitleResponse?.title}
63+
value={generateTitleResponse?.title}
6164
label={strings.titlePreview}
6265
strongLabel
6366
/>

translationMigrations/000007-1735886091614.json renamed to translationMigrations/000012-1738141854510.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"parent": "000006-1735037040790.json",
2+
"parent": "000011-1738138922126.json",
33
"actions": [
44
{
55
"action": "add",

0 commit comments

Comments
 (0)