mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-26 00:09:38 +02:00
commit
e0162ff69a
1 changed files with 20 additions and 2 deletions
|
@ -279,6 +279,9 @@ export const actions: Actions = {
|
||||||
formDataToSend.append('latitude', latitude || '');
|
formDataToSend.append('latitude', latitude || '');
|
||||||
formDataToSend.append('longitude', longitude || '');
|
formDataToSend.append('longitude', longitude || '');
|
||||||
formDataToSend.append('is_public', is_public.toString());
|
formDataToSend.append('is_public', is_public.toString());
|
||||||
|
|
||||||
|
let csrfToken = await fetchCSRFToken();
|
||||||
|
|
||||||
if (activity_types) {
|
if (activity_types) {
|
||||||
// Filter out empty and duplicate activity types, then trim each activity type
|
// Filter out empty and duplicate activity types, then trim each activity type
|
||||||
const cleanedActivityTypes = Array.from(
|
const cleanedActivityTypes = Array.from(
|
||||||
|
@ -293,6 +296,23 @@ export const actions: Actions = {
|
||||||
cleanedActivityTypes.forEach((activity_type) => {
|
cleanedActivityTypes.forEach((activity_type) => {
|
||||||
formDataToSend.append('activity_types', activity_type);
|
formDataToSend.append('activity_types', activity_type);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
let res = await fetch(`${serverEndpoint}/api/adventures/${adventureId}/`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: {
|
||||||
|
Cookie: `${event.cookies.get('auth')}`,
|
||||||
|
'X-CSRFToken': csrfToken,
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ activity_types: [] })
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
const errorBody = await res.json();
|
||||||
|
return {
|
||||||
|
status: res.status,
|
||||||
|
body: { error: errorBody }
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
formDataToSend.append('rating', rating ? rating.toString() : '');
|
formDataToSend.append('rating', rating ? rating.toString() : '');
|
||||||
formDataToSend.append('link', link || '');
|
formDataToSend.append('link', link || '');
|
||||||
|
@ -335,8 +355,6 @@ export const actions: Actions = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const csrfToken = await fetchCSRFToken();
|
|
||||||
|
|
||||||
if (!csrfToken) {
|
if (!csrfToken) {
|
||||||
return {
|
return {
|
||||||
status: 500,
|
status: 500,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue