150 lines
3.5 KiB
TypeScript
150 lines
3.5 KiB
TypeScript
import api from './api'
|
|
|
|
export interface RegisterCafeOwnerPayload {
|
|
full_name: string
|
|
phone_number: string
|
|
national_id: string
|
|
pan_number: string
|
|
}
|
|
|
|
export interface CafeOwnerResponse {
|
|
uuid: string
|
|
user_uuid: string
|
|
full_name: string
|
|
phone_number: string
|
|
national_id: string
|
|
pan_number: string
|
|
created_at: string
|
|
}
|
|
|
|
export async function registerCafeOwner(payload: RegisterCafeOwnerPayload): Promise<CafeOwnerResponse> {
|
|
const { data } = await api.post<CafeOwnerResponse>('/campaign/cafe-owners/', payload)
|
|
return data
|
|
}
|
|
|
|
export interface City {
|
|
uuid: string
|
|
city_name: string
|
|
}
|
|
|
|
export async function fetchCities(): Promise<City[]> {
|
|
const { data } = await api.get<City[]>('/campaign/cities/')
|
|
return data
|
|
}
|
|
|
|
export interface MatchEvent {
|
|
uuid: string
|
|
title: string
|
|
team_home: string
|
|
team_away: string
|
|
match_datetime: string
|
|
}
|
|
|
|
export async function fetchMatchEvents(): Promise<MatchEvent[]> {
|
|
const { data } = await api.get<MatchEvent[]>('/campaign/match-events/')
|
|
return data
|
|
}
|
|
|
|
export interface CafeFeature {
|
|
uuid: string
|
|
name: string
|
|
icon: string | null
|
|
}
|
|
|
|
export async function fetchCafeFeatures(): Promise<CafeFeature[]> {
|
|
const { data } = await api.get<CafeFeature[]>('/campaign/cafe-features/')
|
|
return data
|
|
}
|
|
|
|
export interface GeoPoint {
|
|
type: 'Point'
|
|
coordinates: [number, number]
|
|
}
|
|
|
|
export interface RegisterCafePayload {
|
|
owner_uuid: string
|
|
city_uuid: string
|
|
name: string
|
|
phone_number: string
|
|
location: GeoPoint
|
|
address: string
|
|
feature_uuids: string[]
|
|
}
|
|
|
|
export interface CafeResponse extends RegisterCafePayload {
|
|
uuid: string
|
|
created_at: string
|
|
}
|
|
|
|
export async function registerCafe(payload: RegisterCafePayload): Promise<CafeResponse> {
|
|
const { data } = await api.post<CafeResponse>('/campaign/cafes/', payload)
|
|
return data
|
|
}
|
|
|
|
export interface UpdateCafePayload {
|
|
city_uuid: string
|
|
name: string
|
|
phone_number: string
|
|
location: GeoPoint
|
|
address: string
|
|
feature_uuids: string[]
|
|
}
|
|
|
|
export async function updateCafe(cafeUuid: string, payload: UpdateCafePayload): Promise<CafeResponse> {
|
|
const { data } = await api.patch<CafeResponse>(`/campaign/cafes/${cafeUuid}/`, payload)
|
|
return data
|
|
}
|
|
|
|
export interface CafeMedia {
|
|
uuid: string
|
|
cafe_uuid: string
|
|
url: string
|
|
type: string
|
|
}
|
|
|
|
export interface MyCafe {
|
|
uuid: string
|
|
owner_uuid: string
|
|
name: string
|
|
phone_number: string
|
|
location: GeoPoint
|
|
address: string
|
|
is_approved: boolean
|
|
created_at: string
|
|
city: City
|
|
features: CafeFeature[]
|
|
media: CafeMedia[]
|
|
}
|
|
|
|
export async function fetchMyCafes(): Promise<MyCafe[]> {
|
|
// bare array, same as /campaign/cities/, /campaign/cafe-features/, etc. — NOT wrapped in { success, data }
|
|
const { data } = await api.get<MyCafe[]>('/campaign/cafes/my/')
|
|
return data
|
|
}
|
|
|
|
export interface CafeSchedule {
|
|
uuid: string
|
|
cafe_uuid: string
|
|
match_event: MatchEvent
|
|
total_tickets: number
|
|
ticket_price: string
|
|
remaining_tickets: number
|
|
description: string
|
|
}
|
|
|
|
export interface CreateCafeSchedulePayload {
|
|
match_event_uuid: string
|
|
total_tickets: number
|
|
ticket_price: string
|
|
description: string
|
|
}
|
|
|
|
export async function createCafeSchedule(cafeUuid: string, payload: CreateCafeSchedulePayload): Promise<CafeSchedule> {
|
|
const { data } = await api.post<CafeSchedule>(`/campaign/cafes/${cafeUuid}/schedules/`, payload)
|
|
return data
|
|
}
|
|
|
|
export async function fetchCafeSchedules(cafeUuid: string): Promise<CafeSchedule[]> {
|
|
const { data } = await api.get<CafeSchedule[]>(`/campaign/cafes/${cafeUuid}/schedules/`)
|
|
return data
|
|
}
|