Skip to content

Commit

Permalink
use setInitialCreateReportFieldsForm
Browse files Browse the repository at this point in the history
  • Loading branch information
rezkiy37 committed Jun 21, 2024
1 parent bfdd2b9 commit 473629c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/pages/workspace/reportFields/CreatePolicyReportFieldPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback, useRef} from 'react';
import React, {useCallback, useEffect, useRef} from 'react';
import {View} from 'react-native';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import type {FormInputErrors, FormOnyxValues, FormRef} from '@components/Form/types';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import ScreenWrapper from '@components/ScreenWrapper';
import TextPicker from '@components/TextPicker';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {setInitialCreateReportFieldsForm} from '@libs/actions/WorkspaceReportFields';
import DateUtils from '@libs/DateUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@navigation/types';
Expand All @@ -19,7 +21,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceReportFieldsForm';
import DateSelector from './DateSelector';
import TypeSelector from './TypeSelector';

type CreatePolicyReportFieldPageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.REPORT_FIELDS_CREATE>;
Expand Down Expand Up @@ -52,6 +53,10 @@ function CreatePolicyReportFieldPage({
return errors;
}, []);

useEffect(() => {
setInitialCreateReportFieldsForm();
}, []);

return (
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
Expand Down Expand Up @@ -117,11 +122,10 @@ function CreatePolicyReportFieldPage({
)}

{inputValues[INPUT_IDS.TYPE] === CONST.REPORT_FIELD_TYPES.DATE && (
<InputWrapper
InputComponent={DateSelector}
inputID={INPUT_IDS.INITIAL_VALUE}
defaultValue={defaultDate}
label={translate('common.date')}
<MenuItemWithTopDescription
title={translate('common.currentDate')}
description={translate('common.date')}
interactive={false}
/>
)}

Expand Down

0 comments on commit 473629c

Please sign in to comment.