fix: don't require report_id/token on submit success
The deployed storage-free worker returns { ok: true } without
report_id/report_token, but the submit handler threw 'Your plan could
not be saved' whenever they were absent — showing an error even though
the email sent. Treat the worker's ok response as success and only
capture the tokens when the D1 worker provides them (restore link).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
src/App.vue
13
src/App.vue
@@ -1779,13 +1779,20 @@ function submitCapture(e) {
|
||||
return res.json()
|
||||
})
|
||||
.then(data => {
|
||||
if (!data || !data.report_id || !data.report_token) {
|
||||
// The HTTP res.ok check above already confirmed the worker accepted
|
||||
// the submission (email sent). report_id/report_token are only
|
||||
// returned by the D1-backed worker; capture them when present so the
|
||||
// email restore link works, but don't require them — the storage-free
|
||||
// worker sends the plan without persisting anything.
|
||||
if (data && data.ok === false) {
|
||||
throw new Error(currentLang === 'de'
|
||||
? 'Dein Plan konnte gerade nicht gespeichert werden. Bitte versuche es erneut.'
|
||||
: 'Your plan could not be saved just now. Please try again.')
|
||||
? 'Dein Plan konnte gerade nicht per E-Mail gesendet werden. Bitte versuche es erneut.'
|
||||
: 'Your plan could not be emailed just now. Please try again.')
|
||||
}
|
||||
if (data && data.report_id && data.report_token) {
|
||||
answers._report_id = String(data.report_id)
|
||||
answers._report_token = String(data.report_token)
|
||||
}
|
||||
saveState()
|
||||
showSuccess()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user