Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReportNameValuePairs key to Report Type #40661

Merged
merged 16 commits into from
May 14, 2024
Merged
7 changes: 6 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ const CONST = {
// The minimum number of typed lines needed to enable the full screen composer
FULL_COMPOSER_MIN_LINES: 3,
},
REPORT_NAME_KEYS: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend putting this under REPORT.NVPS rather than REPORT_NAME_KEYS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering if the same thing we did for nameValuePairs we should do for reportNameValuePairs. cc @iwiznia

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but rNVPs should be _a bit simpler since we always want to send all of them, right?

Anyway, I assume it should be easy to do by queuing the update at the lowest level in auth, probably in Report::setNameValuePair

isArchived: 'isArchived',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the keys in this file are typically always UPPER_SNAKE_CASE. You can extract all the camelCase values using ValueOf from type-fest.

},
MODAL: {
MODAL_TYPE: {
CONFIRM: 'confirm',
Expand Down Expand Up @@ -4620,6 +4623,8 @@ type Country = keyof typeof CONST.ALL_COUNTRIES;
type IOUType = ValueOf<typeof CONST.IOU.TYPE>;
type IOUAction = ValueOf<typeof CONST.IOU.ACTION>;

export type {Country, IOUAction, IOUType, RateAndUnit, OnboardingPurposeType};
type ReportNameKeys = keyof typeof CONST.REPORT_NAME_KEYS;

export type {Country, IOUAction, IOUType, RateAndUnit, OnboardingPurposeType, ReportNameKeys};

export default CONST;
4 changes: 4 additions & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import {ReportNameKeys} from '@src/CONST';

Check failure on line 3 in src/types/onyx/Report.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

All imports in the declaration are only used as types. Use `import type`
import type ONYXKEYS from '@src/ONYXKEYS';
import type CollectionDataSet from '@src/types/utils/CollectionDataSet';
import type * as OnyxCommon from './OnyxCommon';
Expand Down Expand Up @@ -186,6 +187,9 @@
transactionThreadReportID?: string;

fieldList?: Record<string, PolicyReportField>;

/** The reports name value pairs */
reportNameValuePairs?: Record<ReportNameKeys, string>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type seems pretty sus - are all rNVP values strings?

},
PolicyReportField['fieldID']
>;
Expand Down
Loading