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 defaults for missing NSQS values #56987

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function NSQSAdvancedPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const isAutoSyncEnabled = nsqsConfig?.autoSync.enabled ?? false;
const isAutoSyncEnabled = nsqsConfig?.autoSync?.enabled ?? false;
const approvalAccount = nsqsConfig?.approvalAccount ?? '';
const nsqsData = policy?.connections?.netsuiteQuickStart?.data;
const payableAccounts: NSQSPayableAccount[] = useMemo(() => nsqsData?.payableAccounts ?? [], [nsqsData?.payableAccounts]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function NSQSCustomersDisplayedAsPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const importType = nsqsConfig?.syncOptions.mapping.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const importType = nsqsConfig?.syncOptions?.mapping?.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;

const sectionData: Array<SelectorType<Option>> = Options.map((option) => ({
keyForList: option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function NSQSCustomersPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const importType = nsqsConfig?.syncOptions.mapping.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const importType = nsqsConfig?.syncOptions?.mapping?.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const isImportEnabled = importType !== CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;

const toggleImport = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ function NSQSImportPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const customersImportType = nsqsConfig?.syncOptions.mapping.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const projectsImportType = nsqsConfig?.syncOptions.mapping.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const customersImportType = nsqsConfig?.syncOptions?.mapping?.customers ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const projectsImportType = nsqsConfig?.syncOptions?.mapping?.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;

return (
<ConnectionLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function NSQSProjectsDisplayedAsPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const importType = nsqsConfig?.syncOptions.mapping.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const importType = nsqsConfig?.syncOptions?.mapping?.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;

const sectionData: Array<SelectorType<Option>> = Options.map((option) => ({
keyForList: option,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function NSQSProjectsPage({policy}: WithPolicyProps) {
const styles = useThemeStyles();
const policyID = policy?.id;
const nsqsConfig = policy?.connections?.netsuiteQuickStart?.config;
const importType = nsqsConfig?.syncOptions.mapping.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const importType = nsqsConfig?.syncOptions?.mapping?.projects ?? CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;
const isImportEnabled = importType !== CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT;

const toggleImport = useCallback(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ type NSQSConnectionData = {
*/
type NSQSConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Configuration of automatic synchronization from NSQS to the app */
autoSync: {
autoSync?: {
/** Job ID of the synchronization */
jobID: string;

Expand All @@ -1114,9 +1114,9 @@ type NSQSConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{
};

/** Configuration options pertaining to sync */
syncOptions: {
syncOptions?: {
/** Configuration of import settings from NSQS to Expensify */
mapping: {
mapping?: {
/** How NSQS customers are displayed as */
customers: ValueOf<typeof CONST.NSQS_INTEGRATION_ENTITY_MAP_TYPES>;

Expand All @@ -1136,7 +1136,7 @@ type NSQSConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{

/** NSQS credentials */
credentials: {
/** Encrypted token for NSQS authentification */
/** Encrypted token for NSQS authentication */
accessToken: string;

/** The company ID */
Expand Down