++ aggiunta la prenotazione negli eventi. con la lista degli utenti.
This commit is contained in:
@@ -42,9 +42,38 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
}),
|
||||
getters: {
|
||||
|
||||
findEventBooked: (mystate: ICalendarState) => (myevent: IEvents, isconfirmed: boolean) => {
|
||||
updatearrBookingEvent: (mystate: ICalendarState) => (id_bookedevent: any, arrBookings: IBookedEvent[]) => {
|
||||
// Rimuovi quelli precedenti
|
||||
mystate.bookedevent = mystate.bookedevent.filter((rec: IBookedEvent) => rec.id_bookedevent !== id_bookedevent)
|
||||
|
||||
if (arrBookings) {
|
||||
// Aggiorna quelli appena arrivati:
|
||||
mystate.bookedevent = [...mystate.bookedevent, ...arrBookings]
|
||||
}
|
||||
|
||||
console.log('BOOKEDEV: ', mystate.bookedevent)
|
||||
|
||||
},
|
||||
|
||||
findEventBooked: (mystate: ICalendarState) => (id: any, isconfirmed: boolean) => {
|
||||
const userStore = useUserStore()
|
||||
return mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === myevent._id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
return mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
},
|
||||
|
||||
findAllBookedByIdEvent: (mystate: ICalendarState) => (id_bookedevent: any) => {
|
||||
const arr = mystate.bookedevent.filter((rec: IBookedEvent) => (rec.id_bookedevent === id_bookedevent) && rec.booked)
|
||||
if (arr)
|
||||
return arr
|
||||
else
|
||||
return []
|
||||
},
|
||||
|
||||
|
||||
isPartecipero: (mystate: ICalendarState) => (id: any, table: string) => {
|
||||
const userStore = useUserStore()
|
||||
const isconfirmed = true
|
||||
const mybooked = mystate.bookedevent.find((bookedevent) => (bookedevent.id_bookedevent === id) && (bookedevent.userId === userStore.my._id) && ((isconfirmed && bookedevent.booked) || (!isconfirmed)))
|
||||
return !!mybooked
|
||||
},
|
||||
|
||||
getNumParticipants: (mystate: ICalendarState) => (myevent: IEvents, showall: boolean, tipo = 0): number => {
|
||||
@@ -103,7 +132,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
},
|
||||
actions: {
|
||||
|
||||
getOperatorByUsername (username: string): IOperators | undefined {
|
||||
getOperatorByUsername(username: string): IOperators | undefined {
|
||||
const ctrec = this.operators.find((rec: IOperators) => rec.username === username)
|
||||
return ctrec
|
||||
},
|
||||
@@ -125,6 +154,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
return {
|
||||
_id: bookevent._id,
|
||||
id_bookedevent: bookevent.id_bookedevent,
|
||||
username: bookevent.username,
|
||||
infoevent: bookevent.infoevent,
|
||||
numpeople: bookevent.numpeople,
|
||||
numpeopleLunch: bookevent.numpeopleLunch,
|
||||
@@ -170,7 +200,7 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
|
||||
},
|
||||
|
||||
async CancelEvent({ id }: {id: string}) {
|
||||
async CancelEvent({ id }: { id: string }) {
|
||||
const globalStore = useGlobalStore()
|
||||
return globalStore.DeleteRec({ table: costanti.TABEVENTS, id })
|
||||
},
|
||||
@@ -183,7 +213,8 @@ export const useCalendarStore = defineStore('CalendarStore', {
|
||||
return (this.intervalRange.max - this.intervalRange.min) * (1 / this.intervalRangeStep)
|
||||
},
|
||||
|
||||
async CancelBookingEvent({ ideventbook, notify }: {ideventbook: string, notify: string}) {
|
||||
|
||||
async CancelBookingEvent({ ideventbook, notify }: { ideventbook: string, notify: string }) {
|
||||
console.log('CALSTORE: CancelBookingEvent', ideventbook, notify)
|
||||
|
||||
return Api.SendReq('/booking/' + ideventbook + '/' + notify + '/' + process.env.APP_ID, 'DELETE', null)
|
||||
|
||||
Reference in New Issue
Block a user