Skip to content

Commit

Permalink
add nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Aug 12, 2024
1 parent 190de87 commit a881d6a
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/libs/actions/connections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import type Policy from '@src/types/onyx/Policy';

type ConnectionNameExceptNetSuite = Exclude<ConnectionName, typeof CONST.POLICY.CONNECTIONS.NAME.NETSUITE>;

type Nullable<T> = {
[P in keyof T]: T[P] | null;
};

function removePolicyConnection(policyID: string, connectionName: PolicyConnectionName) {
const optimisticData: OnyxUpdate[] = [
{
Expand Down Expand Up @@ -73,7 +77,7 @@ function updatePolicyXeroConnectionConfig<TConnectionName extends ConnectionName
connectionName: TConnectionName,
settingName: TSettingName,
settingValue: Partial<Connections[TConnectionName]['config'][TSettingName]>,
oldSettingValue?: Partial<Connections[TConnectionName]['config'][TSettingName]>,
oldSettingValue?: Nullable<Partial<Connections[TConnectionName]['config'][TSettingName]>>,
) {
const optimisticData: OnyxUpdate[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) {
{
enabled: !autoSync?.enabled,
},
{enabled: autoSync?.enabled},
{enabled: autoSync?.enabled ?? null},
)
}
pendingAction={settingsPendingAction([CONST.XERO_CONFIG.ENABLED], pendingFields)}
Expand All @@ -89,7 +89,7 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) {
{
syncReimbursedReports: !sync?.syncReimbursedReports,
},
{syncReimbursedReports: sync?.syncReimbursedReports},
{syncReimbursedReports: sync?.syncReimbursedReports ?? null},
)
}
pendingAction={settingsPendingAction([CONST.XERO_CONFIG.SYNC_REIMBURSED_REPORTS], pendingFields)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function XeroBillPaymentAccountSelectorPage({policy}: WithPolicyConnectionsProps
{
reimbursementAccountID: value,
},
{reimbursementAccountID},
{reimbursementAccountID: reimbursementAccountID ?? null},
);
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function XeroInvoiceAccountSelectorPage({policy}: WithPolicyConnectionsProps) {
{
invoiceCollectionsAccountID: value,
},
{invoiceCollectionsAccountID},
{invoiceCollectionsAccountID: invoiceCollectionsAccountID ?? null},
);
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.getRoute(policyID));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function XeroBankAccountSelectPage({policy}: WithPolicyConnectionsProps) {
{
nonReimbursableAccount: value,
},
{nonReimbursableAccount: config?.export?.nonReimbursableAccount},
{nonReimbursableAccount: config?.export?.nonReimbursableAccount ?? null},
);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function XeroPreferredExporterSelectPage({policy}: WithPolicyConnectionsProps) {
CONST.POLICY.CONNECTIONS.NAME.XERO,
CONST.XERO_CONFIG.EXPORT,
{exporter: row.value},
{exporter: config?.export?.exporter},
{exporter: config?.export?.exporter ?? null},
);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT.getRoute(policyID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function XeroPurchaseBillDateSelectPage({policy}: WithPolicyConnectionsProps) {
CONST.POLICY.CONNECTIONS.NAME.XERO,
CONST.XERO_CONFIG.EXPORT,
{billDate: row.value},
{billDate: config?.export?.billDate},
{billDate: config?.export?.billDate ?? null},
);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_EXPORT_PURCHASE_BILL_DATE_SELECT.getRoute(policyID));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function XeroPurchaseBillStatusSelectorPage({policy}: WithPolicyConnectionsProps
{
billStatus: {...config?.export?.billStatus, purchase: row.value},
},
{billStatus: config?.export?.billStatus},
{billStatus: config?.export?.billStatus ?? null},
);
}
Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_BILL_STATUS_SELECTOR.getRoute(policyID));
Expand Down

0 comments on commit a881d6a

Please sign in to comment.