| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import BaseProvider from '~/services/data/BaseProvider'
- import Address from "~/components/Ui/Search/Address.vue";
- class PublicEventsProvider extends BaseProvider {
- protected normalize (e: any) : PublicEvent {
- e.address = {
- type: '',
- latitude: e.latitude,
- longitude: e.longitude,
- streetAddress: e.streetAddress,
- postalCode: e.postalCode,
- addressCity: e.addressCity,
- country: ''
- } as Address
- // s.categories = s.categories.split()
- return e
- }
- async getBy (
- name: string | null = null,
- organizationId: number | null = null,
- dateMin: string | null = null,
- dateMax: string | null = null,
- city: string | null = null
- ): Promise<Array<PublicEvent>> {
- const query = new URLSearchParams();
- if (name !== null) {
- query.append('name', name)
- }
- if (organizationId !== null) {
- query.append('organizationId', String(organizationId))
- }
- if (dateMin !== null) {
- query.append('dateStart[after]', dateMin)
- }
- if (dateMax !== null) {
- query.append('dateEnd[before]', dateMax)
- }
- if (city !== null) {
- query.append('city', city)
- }
- let url = `/api/public/events`
- if (query) {
- url += `?{query}`
- }
- return await this.get(url).then((res) => {
- console.log(res)
- return res['hydra:member'].map((s: any) => { return this.normalize(s) })
- })
- }
- async getById (eventUuid: number): Promise<PublicEvent> {
- return await this.get(
- `/api/public/events/${eventUuid}`
- ).then((s) => {
- return this.normalize(s)
- })
- }
- }
- export default PublicEventsProvider
|