import { isObject } from '../../utils/types'
import { Category, isCategory } from '../../assets/category'

type AnnouncementResponse = {
    id: number,
    user_id: number,
    name: string,
    category: Category,
    best_by: number,
    address: string,
    longtitude: number,
    latitude: number,
    description: string,
    src: string | null,
    metro: string,
    trashId: number | null,
    booked_by: number
}

const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => isObject(obj, {
    'id': 'number',
    'user_id': 'number',
    'name': 'string',
    'category': isCategory,
    'best_by': 'number',
    'address': 'string',
    'longtitude': 'number',
    'latitude': 'number',
    'description': 'string',
    'src': 'string?',
    'metro': 'string',
    'trashId': 'number?',
    'booked_by': 'number'
})

type Announcement = {
    id: number,
    userId: number,
    name: string,
    category: Category,
    bestBy: number,
    address: string,
    lng: number,
    lat: number,
    description: string | null,
    src: string | null,
    metro: string,
    trashId: number | null,
    bookedBy: number
}

export type {
    Announcement,
    AnnouncementResponse,
}

export {
    isAnnouncementResponse,
}
