-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backup): Display last backup status
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
|
||
import { useI18n } from 'cozy-ui/transpiled/react' | ||
|
||
import Typography from 'cozy-ui/transpiled/react/Typography' | ||
import { useBackupData } from '../hooks/useBackupData' | ||
|
||
const LastBackupStatus = () => { | ||
const { t } = useI18n() | ||
|
||
const { backupInfo } = useBackupData() | ||
|
||
if (!backupInfo || !backupInfo.lastBackup) return null | ||
|
||
const { | ||
lastBackup: { | ||
status, | ||
errorMessage, | ||
backedUpMediaCount, | ||
totalMediasToBackupCount | ||
} | ||
} = backupInfo | ||
|
||
let lastBackupDescription | ||
|
||
if (status === 'success' && totalMediasToBackupCount > 0) { | ||
if (backedUpMediaCount === totalMediasToBackupCount) { | ||
lastBackupDescription = t('Backup.LastBackupStatus.success', { | ||
smart_count: totalMediasToBackupCount | ||
}) | ||
} else { | ||
lastBackupDescription = t('Backup.LastBackupStatus.partialSuccess', { | ||
smart_count: totalMediasToBackupCount, | ||
backedUpMediaCount | ||
}) | ||
} | ||
} else if (status === 'error') { | ||
lastBackupDescription = errorMessage | ||
} else { | ||
return null | ||
} | ||
|
||
return ( | ||
<Typography className="u-mt-1-half" align="center"> | ||
{t('Backup.LastBackupStatus.lastBackup')} {lastBackupDescription} | ||
</Typography> | ||
) | ||
} | ||
|
||
export default LastBackupStatus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters