import { eventId, userId } from "../database";
import { DataStructure } from "@/src/components/base/DataStructure";
import { EventSchema } from "./event";
import { UserSchema } from "./user";

export interface Registration {
    id: number;
    event_id: number;
    user_id: number;
    status: number;
    payment_attachment?: string;
}

export const RegistrationSchema: DataStructure[] = [
    {
        fieldId: "id",
        type: "number",
        displayName: "Registration ID",
        hideFromCRUD: true
    },
    {
        fieldId: "event_id",
        type: "reference",
        referenceId: eventId,
        referenceStructure: EventSchema,
        referenceAlias: "event",
        referenceParentAlias: "registrations",
        referenceDisplay: "event_name",
        displayName: "Event",
        required: true
    },
    {
        fieldId: "user_id",
        type: "reference",
        referenceId: userId,
        referenceStructure: UserSchema,
        referenceAlias: "user",
        referenceParentAlias: "registrations",
        referenceDisplay: "name",
        displayName: "User",
        required: true
    }, 
    {
        fieldId: "status",
        type: "number",
        displayName: "Status",
        required: true,
        options: [
            {
                label: "Pending",
                value: "1"
            },
            {
                label: "Accepted",
                value: "2"
            },
            {
                label: "Rejected",
                value: "3"
            }
        ],
        defaultValue: () => {
            return 1;
        }
    },
    {
        fieldId: "payment_method",
        type: "string",
        displayName: "Payment Method",
        length: 500,
        hint: "Sender's account number and name"
    },
    {
        fieldId: "payment_attachment",
        type: "file",
        displayName: "Payment Attachment",
        length: 500
    }
]