Skip to content

Commit

Permalink
misc: manual CN sync + last fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol committed Jun 3, 2024
1 parent bc97d00 commit c9970a8
Show file tree
Hide file tree
Showing 8 changed files with 292 additions and 51 deletions.
1 change: 1 addition & 0 deletions ditto/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
"text_6650b36fc702a4014c87899a": "Netsuite invoice url",
"text_6655a88569eed300ee8c4d44": "NetSuite synchronisation successfully triggered.",
"text_6650b36fc702a4014c8788fd": "Sync invoice to NetSuite",
"text_665d742ee9853200e3a6be7f": "Sync credit note to NetSuite",
"text_62f50d3cc15266f3bd1d83ce": "Infos copied to clipboard",
"text_62f50d26c989ab0319688498": "Environment information",
"text_62f50d26c989ab031968849a": "Use and share this information if you’re <a rel=\"external\" target=\"_blank\" href=\"https://github.com/getlago/lago-front/issues/new?labels=%F0%9F%90%9E+bug&template=bug.md&title=%5BBUG%5D\">reporting a bug to Lago</a>",
Expand Down
11 changes: 5 additions & 6 deletions src/components/customers/CustomerMainInfos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ gql`
name
accountId
}
# Only added to satisfy type check in the code bellow
... on OktaIntegration {
id
}
}
}
}
Expand Down Expand Up @@ -135,7 +130,11 @@ export const CustomerMainInfos = ({ loading, customer, onEdit }: CustomerMainInf
(provider) => provider?.code === customer?.paymentProviderCode,
)

const connectedNetsuiteIntegration = integrationsData?.integrations?.collection?.find(
const allNetsuiteIntegrations = integrationsData?.integrations?.collection.filter(
(i) => i.__typename === 'NetsuiteIntegration',
) as NetsuiteIntegration[] | undefined

const connectedNetsuiteIntegration = allNetsuiteIntegrations?.find(
(integration) => integration?.id === customer?.netsuiteCustomer?.integrationId,
) as NetsuiteIntegration

Expand Down
32 changes: 17 additions & 15 deletions src/components/customers/addDrawer/ExternalAppsAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
CreateCustomerInput,
CurrencyEnum,
IntegrationTypeEnum,
NetsuiteIntegration,
ProviderPaymentMethodsEnum,
ProviderTypeEnum,
UpdateCustomerInput,
Expand Down Expand Up @@ -95,12 +96,7 @@ gql`
integrations(limit: $limit, page: $page, type: $type) {
collection {
... on NetsuiteIntegration {
id
code
name
}
# OktaIntegration have to be defined to fix TS linting
... on OktaIntegration {
__typename
id
code
name
Expand Down Expand Up @@ -149,9 +145,13 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
(p) => p.code === formikProps.values.paymentProviderCode,
)

const selectedNetsuiteIntegration = integrationsData?.integrations?.collection.find(
const allNetsuiteIntegrations = integrationsData?.integrations?.collection.filter(
(i) => i.__typename === 'NetsuiteIntegration',
) as NetsuiteIntegration[] | undefined

const selectedNetsuiteIntegration = allNetsuiteIntegrations?.find(
(i) => i.code === formikProps.values.integrationCustomer?.integrationCode,
)
) as NetsuiteIntegration

const { data: subsidiariesData } =
useSubsidiariesListForCustomerCreateEditExternalAppsAccordionQuery({
Expand Down Expand Up @@ -183,9 +183,9 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
}, [providersData?.paymentProviders?.collection])

const connectedIntegrationsData: BasicComboBoxData[] | [] = useMemo(() => {
if (!integrationsData?.integrations?.collection.length) return []
if (!allNetsuiteIntegrations?.length) return []

return integrationsData?.integrations?.collection.map((integration) => ({
return allNetsuiteIntegrations?.map((integration) => ({
value: integration.code,
label: integration.name,
labelNode: (
Expand All @@ -200,7 +200,7 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
</Item>
),
}))
}, [integrationsData?.integrations?.collection])
}, [allNetsuiteIntegrations])

const connectedIntegrationSubscidiaries: BasicComboBoxData[] | [] = useMemo(() => {
if (!subsidiariesData?.integrationSubsidiaries?.collection.length) return []
Expand Down Expand Up @@ -257,7 +257,6 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
})}
/>
</div>

{showPaymentProviderSection && (
<Accordion
noContentMargin
Expand Down Expand Up @@ -597,6 +596,7 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
{/* Select Integration account */}
<ComboBox
onOpen={getIntegrationsData}
disabled={isEdition}
data={connectedIntegrationsData}
label={translate('text_66423cad72bbad009f2f5695')}
placeholder={translate('text_66423cad72bbad009f2f5697')}
Expand All @@ -616,14 +616,17 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
<>
<TextInputField
name="integrationCustomer.externalCustomerId"
disabled={!!formikProps.values.integrationCustomer?.syncWithProvider}
disabled={
!!formikProps.values.integrationCustomer?.syncWithProvider || isEdition
}
label={translate('text_66423cad72bbad009f2f569a')}
placeholder={translate('text_66423cad72bbad009f2f569c')}
formikProps={formikProps}
/>

<Checkbox
name="integrationCustomer.syncWithProvider"
disabled={isEdition}
value={!!formikProps.values.integrationCustomer?.syncWithProvider}
label={translate('text_66423cad72bbad009f2f569e', {
connectionName: selectedNetsuiteIntegration?.name,
Expand All @@ -643,6 +646,7 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
<ComboBoxField
name="integrationCustomer.subsidiaryId"
data={connectedIntegrationSubscidiaries}
disabled={isEdition}
label={translate('text_66423cad72bbad009f2f56a0')}
placeholder={translate('text_66423cad72bbad009f2f56a2')}
PopperProps={{ displayInDialog: true }}
Expand All @@ -659,7 +663,6 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
</Stack>
</Accordion>
)}

<Popper
PopperProps={{ placement: 'bottom-start' }}
opener={
Expand Down Expand Up @@ -724,7 +727,6 @@ export const ExternalAppsAccordion = ({ formikProps, isEdition }: TExternalAppsA
</MenuPopper>
)}
</Popper>

{isSyncWithProviderDisabled &&
(formikProps.values.paymentProvider === ProviderTypeEnum.Gocardless ||
formikProps.values.paymentProvider === ProviderTypeEnum.Adyen) && (
Expand Down
2 changes: 1 addition & 1 deletion src/components/settings/integrations/AddNetsuiteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const AddNetsuiteDialog = forwardRef<AddNetsuiteDialogRef>((_, ref) => {
return handleError(res.errors)
}
} else {
const connectionId = `${componentId.replace(':', '')}-${Date.now()}`
const connectionId = `${componentId.replaceAll(':', '')}-${Date.now()}`
const nango = new Nango({ publicKey: nangoPublicKey })

try {
Expand Down
6 changes: 6 additions & 0 deletions src/core/constants/externalUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ export const buildNetsuiteInvoiceUrl = (
) => {
return `https://${connectionAccountId}.app.netsuite.com/app/accounting/transactions/custinvc.nl?id=${netsuiteInvoiceId}`
}
export const buildNetsuiteCreditNoteUrl = (
connectionAccountId?: string | null,
netsuiteCreditNoteId?: string | null,
) => {
return `https://${connectionAccountId}.app.netsuite.com/app/accounting/transactions/custcred.nl?id=${netsuiteCreditNoteId}`
}
Loading

0 comments on commit c9970a8

Please sign in to comment.