refactor(clickTtPlayerRegistrationService, memberController): improve error handling and diagnostics
- Updated error response structure in memberController to include detailed information instead of a trace array, enhancing clarity for the client. - Enhanced ClickTtPlayerRegistrationService to capture and return detailed information about the selected search result and last submission attempt, improving error diagnostics. - Modified frontend to format and display the new detailed error information, providing better context for users during registration failures.
This commit is contained in:
@@ -675,10 +675,10 @@ export default {
|
||||
this.clickTtPendingMemberIds = [...this.clickTtPendingMemberIds, member.id];
|
||||
try {
|
||||
const response = await apiClient.post(`/clubmembers/clicktt-registration/${this.currentClub}/${member.id}`);
|
||||
const traceDetails = this.formatClickTtTrace(response.data?.trace);
|
||||
const detailsText = this.formatClickTtDetails(response.data?.details);
|
||||
if (response.data?.success) {
|
||||
member.clickTtApplicationSubmitted = true;
|
||||
const successDetails = [response.data.finalUrl || '', traceDetails].filter(Boolean).join('\n\n');
|
||||
const successDetails = [response.data.finalUrl || '', detailsText].filter(Boolean).join('\n\n');
|
||||
await this.showInfo(
|
||||
'Click-TT-Antrag',
|
||||
getSafeMessage(response.data.message, 'Der Click-TT-Antrag wurde erfolgreich eingereicht.'),
|
||||
@@ -689,7 +689,7 @@ export default {
|
||||
await this.showInfo(
|
||||
'Click-TT-Antrag',
|
||||
getSafeMessage(response.data?.error, 'Der Click-TT-Antrag konnte nicht eingereicht werden.'),
|
||||
traceDetails,
|
||||
detailsText,
|
||||
'error'
|
||||
);
|
||||
}
|
||||
@@ -699,33 +699,47 @@ export default {
|
||||
await this.showInfo(
|
||||
'Click-TT-Antrag',
|
||||
errorMessage,
|
||||
this.formatClickTtTrace(error?.response?.data?.trace),
|
||||
this.formatClickTtDetails(error?.response?.data?.details),
|
||||
'error'
|
||||
);
|
||||
} finally {
|
||||
this.clickTtPendingMemberIds = this.clickTtPendingMemberIds.filter(id => id !== member.id);
|
||||
}
|
||||
},
|
||||
formatClickTtTrace(trace) {
|
||||
if (!Array.isArray(trace) || trace.length === 0) {
|
||||
formatClickTtDetails(details) {
|
||||
if (!details) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return trace
|
||||
.slice(-12)
|
||||
.map((entry) => {
|
||||
const type = entry?.type || 'trace';
|
||||
const parts = [type];
|
||||
const parts = [];
|
||||
const selected = details.selectedSearchResult;
|
||||
const lastSubmit = details.lastSubmitResult;
|
||||
|
||||
if (entry?.name) parts.push(entry.name);
|
||||
if (entry?.label) parts.push(`label=${entry.label}`);
|
||||
if (entry?.status) parts.push(`status=${entry.status}`);
|
||||
if (entry?.url) parts.push(`url=${entry.url}`);
|
||||
if (entry?.message) parts.push(`message=${entry.message}`);
|
||||
if (selected?.name || selected?.birthDate || selected?.href) {
|
||||
parts.push([
|
||||
'Ausgewaehlter Suchtreffer:',
|
||||
selected?.name ? `Name: ${selected.name}` : '',
|
||||
selected?.birthDate ? `Geburtsdatum: ${selected.birthDate}` : '',
|
||||
selected?.href ? `Link: ${selected.href}` : ''
|
||||
].filter(Boolean).join('\n'));
|
||||
}
|
||||
|
||||
return parts.join(' | ');
|
||||
})
|
||||
.join('\n');
|
||||
if (lastSubmit?.action || lastSubmit?.applicant || lastSubmit?.pageText) {
|
||||
parts.push([
|
||||
'Ergebnis letzter Submit:',
|
||||
lastSubmit?.action ? `Aktion: ${lastSubmit.action}` : '',
|
||||
lastSubmit?.applicant
|
||||
? `Antrag fuer: ${[
|
||||
lastSubmit.applicant.lastName,
|
||||
lastSubmit.applicant.firstName
|
||||
].filter(Boolean).join(', ')}${lastSubmit.applicant.birthDate ? ` (${lastSubmit.applicant.birthDate})` : ''}`
|
||||
: '',
|
||||
lastSubmit?.url ? `URL: ${lastSubmit.url}` : '',
|
||||
lastSubmit?.pageText ? `Seitenstatus: ${lastSubmit.pageText}` : ''
|
||||
].filter(Boolean).join('\n'));
|
||||
}
|
||||
|
||||
return parts.join('\n\n');
|
||||
},
|
||||
toggleNewMember() {
|
||||
this.memberFormIsOpen = !this.memberFormIsOpen;
|
||||
|
||||
Reference in New Issue
Block a user