| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <div>
- <v-container fluid class="inner-container">
- <v-row>
- <!-- Bloc événements -->
- <v-col cols="12" md="7">
- <v-card>
- <v-tabs v-model="tab" class="tabs-title">
- <v-tab value="future">{{ $t('futur_event') }}</v-tab>
- <v-tab value="past">{{ $t('past_event') }}</v-tab>
- </v-tabs>
- <v-btn color="primary" to="freemium/events/new" class="ml-5 mt-5">{{
- $t('add_event')
- }}</v-btn>
- <v-tabs-window v-model="tab">
- <v-tabs-window-item value="future">
- <UiLoadingPanel
- v-if="statusUpcomingEvents == FETCHING_STATUS.PENDING"
- />
- <span v-if="upcomingEvents?.items.length == 0" class="no_event">
- {{ $t('no_future_event') }}
- </span>
- <UiEventList
- v-if="
- statusUpcomingEvents == FETCHING_STATUS.SUCCESS &&
- upcomingEvents?.items
- "
- :events="upcomingEvents.items"
- :pagination="upcomingEvents.pagination"
- @load="loadUpcomingEvents"
- @edit="editEvent"
- />
- </v-tabs-window-item>
- <v-tabs-window-item value="past">
- <UiLoadingPanel
- v-if="statusPastEvents == FETCHING_STATUS.PENDING"
- />
- <span v-if="pastEvents?.items.length == 0" class="no_event">
- {{ $t('no_past_event') }}
- </span>
- <UiEventList
- v-if="
- statusPastEvents == FETCHING_STATUS.SUCCESS &&
- pastEvents?.items
- "
- :events="pastEvents.items"
- :pagination="pastEvents.pagination"
- @load="loadPastEvents"
- @edit="editEvent"
- />
- </v-tabs-window-item>
- </v-tabs-window>
- </v-card>
- </v-col>
- <!-- Bloc structure -->
- <v-col cols="12" md="5">
- <v-card
- v-if="statusOrganization == FETCHING_STATUS.SUCCESS"
- class="pa-5"
- >
- <v-card-title class="text-h6">
- <v-icon icon="fa fa-hotel" class="text-button icon-hotel" />
- <span class="organization_title">{{
- $t('my_organization')
- }}</span>
- </v-card-title>
- <v-card-text>
- <div>
- <strong>{{ $t('name') }} :</strong> {{ organization?.name }}
- </div>
- <div>
- <strong>{{ $t('email') }} :</strong> {{ organization?.email }}
- </div>
- </v-card-text>
- </v-card>
- <v-btn block class="mb-2 btn btn_edit_orga" to="freemium/organization">
- <i class="fa fa-pen mr-2" />{{ $t('edit_organization') }}
- </v-btn>
- <v-btn block class="text-black btn btn_trial" @click="startTrial">
- <span
- ><v-icon icon="fa fa-ticket" /> {{ $t('try_premium_light')
- }}<br />
- {{ $t('30_days_free') }}</span
- >
- </v-btn>
- </v-col>
- </v-row>
- </v-container>
- <LayoutDialogTrialAlreadyDid
- :show="showDialogTrialAlReadyDid"
- @close-dialog="showDialogTrialAlReadyDid = false"
- />
- </div>
- </template>
- <script setup lang="ts">
- import Query from '~/services/data/Query'
- import { type Ref, ref } from 'vue'
- import { useEntityFetch } from '~/composables/data/useEntityFetch'
- import Organization from '~/models/Freemium/Organization'
- import Event from '~/models/Freemium/Event'
- import OrderBy from '~/services/data/Filters/OrderBy'
- import {
- FETCHING_STATUS,
- ORDER_BY_DIRECTION,
- TIME_STRATEGY,
- } from '~/types/enum/data'
- import PageFilter from '~/services/data/Filters/PageFilter'
- import TimeFilter from '~/services/data/Filters/TimeFilter'
- import Country from '~/models/Core/Country'
- import DateUtils from '~/services/utils/dateUtils'
- import UrlUtils from '~/services/utils/urlUtils'
- import { useApiLegacyRequestService } from '~/composables/data/useApiLegacyRequestService'
- import { useAdminUrl } from '~/composables/utils/useAdminUrl'
- definePageMeta({
- name: 'freemium_dashboard_page',
- })
- //Ref Définition
- const { fetch, fetchCollection } = useEntityFetch()
- const { apiRequestService } = useApiLegacyRequestService()
- const { makeAdminUrl } = useAdminUrl()
- const tab = ref(null)
- const upcomingPage = ref(1)
- const pastPage = ref(1)
- const showDialogTrialAlReadyDid: Ref<boolean> = ref(false)
- //Fetch
- const { data: organization, status: statusOrganization } = fetch(Organization)
- const {
- data: upcomingEvents,
- status: statusUpcomingEvents,
- refresh: refreshUpcomingEvents,
- } = fetchEvents()
- const {
- data: pastEvents,
- status: statusPastEvents,
- refresh: refreshPastEvents,
- } = fetchEvents(true)
- /**
- * Charge une page des événements à venir
- * @param pageNumber
- */
- function loadUpcomingEvents(pageNumber: number) {
- upcomingPage.value = pageNumber
- refreshUpcomingEvents()
- }
- /**
- * Cahrge une page des événements passées
- * @param pageNumber
- */
- function loadPastEvents(pageNumber: number) {
- pastPage.value = pageNumber
- refreshPastEvents()
- }
- /**
- * Redirige vers la page d'édition d'un événement
- * @param eventId
- */
- function editEvent(eventId: number) {
- navigateTo(UrlUtils.join('freemium/events', eventId))
- }
- /**
- * Récupère la liste des événements
- * @param past
- */
- function fetchEvents(past: boolean = false) {
- const today = computed(() => DateUtils.formatIsoShortDate(new Date()))
- const query = new Query(
- new OrderBy(
- 'datetimeStart',
- past ? ORDER_BY_DIRECTION.DESC : ORDER_BY_DIRECTION.ASC,
- ),
- new PageFilter(past ? pastPage : upcomingPage, ref(5)),
- new TimeFilter(
- 'datetimeStart',
- today,
- past ? TIME_STRATEGY.BEFORE : TIME_STRATEGY.AFTER,
- ),
- )
- return fetchCollection(Event, null, query)
- }
- /**
- * Action lorsque l'on souhaite démarrer l'essai
- */
- async function startTrial() {
- try {
- await apiRequestService.get('/trial/is_available')
- await navigateTo(makeAdminUrl('trial'), {
- external: true,
- })
- } catch (error) {
- showDialogTrialAlReadyDid.value = true
- }
- }
- /**
- * Nettoyage du store
- */
- onUnmounted(() => {
- useRepo(Organization).flush()
- useRepo(Event).flush()
- useRepo(Country).flush()
- })
- </script>
- <style scoped lang="scss">
- .tabs-title {
- margin-top: 20px;
- padding-left: 20px;
- background-color: rgb(var(--v-theme-neutral));
- .v-tab--selected {
- color: rgb(var(--v-theme-on-neutral--clickable));
- }
- }
- .v-card {
- margin-bottom: 16px;
- color: rgb(var(--v-theme-on-primary-alt));
- }
- .v-card-text {
- div {
- line-height: 2;
- }
- }
- .organization_title {
- font-weight: 500;
- }
- .icon-hotel {
- margin: 0 5px 4px 0;
- }
- .btn {
- border: 1px solid;
- cursor: pointer;
- }
- .inner-container {
- margin: 0 auto;
- padding: 30px;
- }
- .btn_trial {
- height: 55px;
- background-color: rgb(var(--v-theme-x-create-btn));
- color: #000;
- span {
- text-align: center;
- line-height: 1.2; /* optionnel : pour resserrer ou espacer */
- }
- .v-icon {
- transform: rotate(135deg); /* angle en degrés */
- font-size: 16px;
- padding-right: 5px;
- margin: 0 5px 4px 0;
- }
- }
- .btn_edit_orga {
- color: rgb(var(--v-theme-on-primary-alt)) !important;
- }
- .no_event {
- padding: 25px;
- font-size: 16px;
- display: block;
- }
- </style>
|