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

Feat/update wording import success #2656

Merged
merged 2 commits into from
Apr 26, 2023
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
10 changes: 10 additions & 0 deletions docs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ The service also determines if a delayed notification schedule at D+3 and D+7 is

ℹ️ This service can be run via CLI via `yarn service konnectorAlerts`

### Import

slug: `import`

Allows you to import bank data into Cozy, from the Cozy bank export file (.csv format)
This service is launched manually once the import of the file has been successful on the cozy.
It also saves the number of imported transactions in the doctype `io.cozy.bank.settings` (`lastImportSuccess.savedTransactionsCount`)
Merkur39 marked this conversation as resolved.
Show resolved Hide resolved

ℹ️ This service can be run via CLI via `yarn service import`

## I am writing a banking konnector, what should I do?

If you want to benefit from all the features of these services, the most
Expand Down
27 changes: 22 additions & 5 deletions src/ducks/settings/Import/ImportContents/ImportContentSuccess.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import React from 'react'

import { isQueryLoading, useQuery } from 'cozy-client'
import { Empty } from 'cozy-ui/transpiled/react'
import { useI18n } from 'cozy-ui/transpiled/react/I18n'
import Typography from 'cozy-ui/transpiled/react/Typography'

import successIllu from 'assets/icons/success-illu.svg'
import { buildAppSettingsQuery } from 'ducks/settings/queries'

const ImportContentSuccess = () => {
const { t } = useI18n()
const appSettingsQuery = buildAppSettingsQuery()
const { data: appSettings, ...appSettingsQueryResult } = useQuery(
appSettingsQuery.definition,
appSettingsQuery.options
)
const isLoadingAppSettings =
isQueryLoading(appSettingsQueryResult) || appSettingsQueryResult.hasMore

const savedTransactionsCount =
!isLoadingAppSettings &&
appSettings?.[0]?.lastImportSuccess?.savedTransactionsCount
Merkur39 marked this conversation as resolved.
Show resolved Hide resolved

const text = savedTransactionsCount ? (
<Typography component="span" className="u-mb-1 u-db u-spacellipsis">
{t('Settings.import.description.success', {
smart_count: savedTransactionsCount
})}
</Typography>
) : null

return (
<Empty
icon={successIllu}
title={t('Settings.import.title.success')}
className="u-p-1 u-h-100"
text={
<Typography component="span" className="u-mb-1 u-db u-spacellipsis">
{t('Settings.import.description.success')}
</Typography>
}
text={text}
Merkur39 marked this conversation as resolved.
Show resolved Hide resolved
data-testid="ImportContentSuccess"
/>
)
Expand Down
10 changes: 9 additions & 1 deletion src/ducks/settings/queries.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Q, fetchPolicies } from 'cozy-client'

import { FILES_DOCTYPE } from 'src/doctypes'
import { FILES_DOCTYPE, SETTINGS_DOCTYPE } from 'src/doctypes'

const defaultFetchPolicy = fetchPolicies.olderThan(30 * 1000)

Expand All @@ -19,3 +19,11 @@ export const buildFilesQueryByNameAndDirId = (name, dirId) => ({
fetchPolicy: defaultFetchPolicy
}
})

export const buildAppSettingsQuery = () => ({
definition: () => Q(SETTINGS_DOCTYPE),
options: {
as: `${SETTINGS_DOCTYPE}`,
fetchPolicy: defaultFetchPolicy
}
})
2 changes: 1 addition & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@
"description": {
"text": "Select the data to import\n(File format: .csv)",
"serviceInProgress": "Please wait a few moments, your data is being processed.",
"success": "Your data has been successfully imported.",
"success": "%{smart_count} operation imported. |||| %{smart_count} operations imported.",
"action": "Data to import"
},
"action": {
Expand Down
4 changes: 2 additions & 2 deletions src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,12 @@
"title": {
"text": "Importer mes données",
"serviceInProgress": "Traitement des données",
"success": "Import réussi"
"success": "Import terminé"
},
"description": {
"text": "Sélectionnez les données à importer\n(Format du fichier : .csv)",
"serviceInProgress": "Merci de patientez quelques instants, vos données sont en cours de traitement.",
"success": "Vos données ont été correctement importées.",
"success": "%{smart_count} opération importée. |||| %{smart_count} opérations importées.",
"action": "Données à importer"
},
"action": {
Expand Down