mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-10 08:17:59 -05:00
Edit activity and show visibility per activity
[frontend] edit activity completed [frontend] activity visibility available in activity summary component
This commit is contained in:
@@ -76,8 +76,6 @@ def create_response_with_tokens(response: Response, user: users_schema.User):
|
||||
if os.environ.get("FRONTEND_PROTOCOL") == "https":
|
||||
secure = True
|
||||
|
||||
print("secure", secure)
|
||||
|
||||
# Set the cookies with the tokens
|
||||
response.set_cookie(
|
||||
key="endurain_access_token",
|
||||
|
||||
@@ -17,6 +17,19 @@
|
||||
</router-link>
|
||||
</div>
|
||||
<h6>
|
||||
<!-- Display the visibility of the activity -->
|
||||
<span v-if="activity.visibility == 0">
|
||||
<font-awesome-icon :icon="['fas', 'globe']"/> {{ $t("activitySummary.visibilityPublic") }}
|
||||
</span>
|
||||
<span v-if="activity.visibility == 1">
|
||||
<font-awesome-icon :icon="['fas', 'users']" v-if="activity.visibility == 1" /> {{ $t("activitySummary.visibilityFollowers") }}
|
||||
</span>
|
||||
<span v-if="activity.visibility == 2">
|
||||
<font-awesome-icon :icon="['fas', 'lock']" v-if="activity.visibility == 2" /> {{ $t("activitySummary.visibilityPrivate") }}
|
||||
</span>
|
||||
<span> - </span>
|
||||
|
||||
<!-- Display the activity type -->
|
||||
<span v-if="activity.activity_type == 1 || activity.activity_type == 2">
|
||||
<font-awesome-icon :icon="['fas', 'person-running']" />
|
||||
</span>
|
||||
@@ -35,6 +48,8 @@
|
||||
<span v-else>
|
||||
<font-awesome-icon :icon="['fas', 'fa-dumbbell']" />
|
||||
</span>
|
||||
|
||||
<!-- Display the date and time -->
|
||||
<span class="ms-1">{{ formatDate(activity.start_time) }}</span> @
|
||||
<span>{{ formatTime(activity.start_time) }}</span>
|
||||
<!-- Conditionally display city and country -->
|
||||
@@ -106,6 +121,10 @@
|
||||
<h1 class="mt-3" v-if="sourceProp === 'activity'">
|
||||
{{ activity.name }}
|
||||
</h1>
|
||||
|
||||
<!-- Activity description -->
|
||||
<p v-if="activity.description">{{ activity.description }}</p>
|
||||
|
||||
<!-- Activity summary -->
|
||||
<div class="row d-flex mt-3">
|
||||
<div class="col">
|
||||
|
||||
@@ -36,7 +36,11 @@
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
// Importing the utils
|
||||
import { addToast } from '@/utils/toastUtils';
|
||||
// Importing the services
|
||||
import { activities } from '@/services/activitiesService';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -53,10 +57,36 @@ export default {
|
||||
const editActivityName = ref(props.activity.name);
|
||||
const editActivityVisibility = ref(props.activity.visibility);
|
||||
|
||||
async function submitEditActivityForm() {
|
||||
try {
|
||||
const data = {
|
||||
id: props.activity.id,
|
||||
name: editActivityName.value,
|
||||
description: editActivityDescription.value,
|
||||
visibility: editActivityVisibility.value,
|
||||
};
|
||||
|
||||
// Call the service to edit the activity
|
||||
await activities.editActivity(props.activity.id, data);
|
||||
|
||||
// Set activity new values
|
||||
props.activity.name = editActivityName.value;
|
||||
props.activity.description = editActivityDescription.value;
|
||||
props.activity.visibility = editActivityVisibility.value;
|
||||
|
||||
// show success toast
|
||||
addToast(t('gear.successGearEdited'), 'success', true);
|
||||
} catch (error) {
|
||||
// If there is an error, set the error message and show the error alert.
|
||||
addToast(t('generalItens.errorEditingInfo') + " - " + error.toString(), 'danger', true);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
editActivityDescription,
|
||||
editActivityName,
|
||||
editActivityVisibility,
|
||||
submitEditActivityForm,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
{
|
||||
"visibilityPublic": "Public",
|
||||
"visibilityFollowers": "Followers",
|
||||
"visibilityPrivate": "Private",
|
||||
"buttonDeleteActivity": "Delete activity",
|
||||
"buttonEditActivity": "Edit activity",
|
||||
"modalDeleteBody1": "Are you sure you want to delete activity ",
|
||||
|
||||
@@ -40,6 +40,9 @@ export const activities = {
|
||||
deleteGearFromActivity(activityId) {
|
||||
return fetchPutRequest(`activities/${activityId}/deletegear`);
|
||||
},
|
||||
editActivity(activityId, data) {
|
||||
return fetchPutRequest(`activities/edit`, data);
|
||||
},
|
||||
deleteActivity(activityId) {
|
||||
return fetchDeleteRequest(`activities/${activityId}/delete`);
|
||||
}
|
||||
|
||||
@@ -178,8 +178,6 @@ import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
// Importing the utils
|
||||
import { addToast } from '@/utils/toastUtils';
|
||||
// Import the stores
|
||||
import { useAuthStore } from '@/stores/authStore';
|
||||
// Importing the components
|
||||
import NoItemsFoundComponent from '@/components/GeneralComponents/NoItemsFoundComponents.vue';
|
||||
import LoadingComponent from '@/components/GeneralComponents/LoadingComponent.vue';
|
||||
|
||||
Reference in New Issue
Block a user