Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
await client.stackClient.fetchJSON('POST', '/notifications', {
data: {
type: 'io.cozy.notifications',
attributes: {
category: 'transaction-greater',
title: 'Test notification',
message: 'This is a test notification message',
preferred_channels: ['mobile', 'mail'],
content: 'This is a test notification text content',
content_html: 'This is a test notification HTML content'
}
}
})
Alerter.success('Notification sent')
} catch (err) {
Alerter.error('Failed to send notification: ' + err)
}
}
const handleRename = async () => {
try {
await renameRecurrenceManually(
client,
bundle,
renameInputRef.current.value
)
dismissAction()
Alerter.success(t('Recurrence.rename.save-success'))
} catch (e) {
Alerter.error(t('Recurrence.rename.save-error'))
}
}
const startAndWaitService = async (client, serviceName) => {
const jobs = client.collection('io.cozy.jobs')
const { data: job } = await jobs.create('service', {
name: serviceName,
slug: 'banks'
})
const finalJob = await jobs.waitFor(job.id)
if (finalJob.state === 'errored') {
Alerter.error(`Job finished with error. Error is ${finalJob.error}`)
} else if (finalJob.state === 'done') {
Alerter.success(`Job finished successfully`)
} else {
Alerter.error(`Job finished with state ${finalJob.state}`)
}
return finalJob
}
async handleChooseFingerprint(fingerprintChoice) {
const t = this.props.t
try {
await this.savePin(this.state.chosenPin, fingerprintChoice)
} catch (e) {
Alerter.error(t('Pin.error-save'))
throw e
} finally {
this.setState({ saving: false })
}
Alerter.success(t('Pin.successfully-changed'))
this.props.onSaved()
}
onSuccess: () => {
router.push('/settings/accounts')
Alerter.success(t('AccountSettings.success'))
},
onError: err => {