export type Badge = {
    id: BadgeID;
    name: string;
    description: string;
    image: string;
    image_type: BadgeImageType;
    multiple: boolean;
    type: BadgeType;
    created_by: string;
}

export type Ownership = {
    user: string;
    granted_by: string;
    badge: BadgeID;
    reason: string;
    time: number;
}

export type BadgeID = number;
export type BadgeType = number
export type BadgeImageType = string;

export type UserBadge = Badge & Ownership & {
    granted_by_name: string;
    type_name: string;
};
export type BadgeDetails = Badge & {
    owners: OwnershipList;
    created_by_username: string;
    type_name: string;
    can_edit: boolean;
}
export type AllBadgesBadge = Badge & {
    granted: number;
    granted_times: number;
    type_name: string;
}

export type OwnershipList = Ownership[]

export type BadgeTypeDefinition = {
    id: BadgeType;
    name: string;
    frame: string;
    created_by: string;
    created_by_username: string;
    can_grant: PermissionScheme;
    can_create: PermissionScheme;
    badge_count: number;
    is_default: boolean;
    allowlist_can_create: string;
    allowlist_can_grant: string;
}

export type PermissionScheme = {
    everyone: boolean;
    roles: Record<string, boolean>;
    allow_list: Record<string, boolean>;
    block_list: Record<string, boolean>;
}

export type GetTypesResponse = {
    types: BadgeTypeDefinition[];
    can_create_type: boolean;
    can_edit_type: boolean;
}

export type TypeFormData = {
    name: string;
    everyoneCanCreate: boolean;
    everyoneCanGrant: boolean;
    allowlistCanCreate: string;
    allowlistCanGrant: string;
}

export type BadgeFormData = {
    name: string;
    description: string;
    image: string;
    badgeType: string;
    multiple: boolean;
}

export type CreateBadgeRequest = {
    name: string;
    description: string;
    image: string;
    type: string;
    multiple: boolean;
    channel_id?: string;
}

export type UpdateBadgeRequest = {
    id: string;
    name: string;
    description: string;
    image: string;
    type: string;
    multiple: boolean;
}

export type CreateTypeRequest = {
    name: string;
    everyone_can_create: boolean;
    everyone_can_grant: boolean;
    allowlist_can_create: string;
    allowlist_can_grant: string;
    channel_id?: string;
}

export type UpdateTypeRequest = {
    id: string;
    name: string;
    everyone_can_create: boolean;
    everyone_can_grant: boolean;
    allowlist_can_create: string;
    allowlist_can_grant: string;
}

export type GrantBadgeRequest = {
    badge_id: string;
    user_id: string;
    reason: string;
    notify_here: boolean;
    channel_id: string;
}

export type SubscriptionRequest = {
    type_id: string;
    channel_id: string;
}

export type RevokeOwnershipRequest = {
    badge_id: string;
    user_id: string;
    time: string;
}
