forked from UKSOURCE/ipv6
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
import type { SubmissionStatus } from "@/types/admin-submission";
|
|
import { Schema, model, models } from "mongoose";
|
|
|
|
export type SummitRequestSource = "registration" | "feedback";
|
|
|
|
export type PaymentStatus =
|
|
| "not_required"
|
|
| "payment_pending"
|
|
| "paid"
|
|
| "payment_failed"
|
|
| "payment_cancelled";
|
|
|
|
export interface ISummitRequest {
|
|
publicId: string;
|
|
submittedAt: string;
|
|
displayDate: string;
|
|
fullName: string;
|
|
jobTitle: string;
|
|
company: string;
|
|
segment: string;
|
|
email: string;
|
|
phone: string;
|
|
status: SubmissionStatus;
|
|
notes: string;
|
|
source?: SummitRequestSource;
|
|
paymentStatus: PaymentStatus;
|
|
paypalOrderId?: string;
|
|
paypalCaptureId?: string;
|
|
paymentAmount?: number;
|
|
paymentCurrency?: string;
|
|
paymentCompletedAt?: Date;
|
|
}
|
|
|
|
const summitRequestSchema = new Schema<ISummitRequest>(
|
|
{
|
|
publicId: { type: String, required: true, unique: true, index: true },
|
|
submittedAt: { type: String, required: true, index: true },
|
|
displayDate: { type: String, required: true },
|
|
fullName: { type: String, required: true },
|
|
jobTitle: { type: String, default: "" },
|
|
company: { type: String, default: "" },
|
|
segment: { type: String, required: true },
|
|
email: { type: String, default: "" },
|
|
phone: { type: String, default: "" },
|
|
status: {
|
|
type: String,
|
|
enum: ["pending", "approved", "rejected"],
|
|
default: "pending",
|
|
index: true,
|
|
},
|
|
notes: { type: String, default: "" },
|
|
source: { type: String, enum: ["registration", "feedback"] },
|
|
paymentStatus: {
|
|
type: String,
|
|
enum: ["not_required", "payment_pending", "paid", "payment_failed", "payment_cancelled"],
|
|
default: "not_required",
|
|
index: true,
|
|
},
|
|
paypalOrderId: { type: String, sparse: true, index: true },
|
|
paypalCaptureId: { type: String },
|
|
paymentAmount: { type: Number, default: 120 },
|
|
paymentCurrency: { type: String, default: "USD" },
|
|
paymentCompletedAt: { type: Date },
|
|
},
|
|
{ timestamps: true },
|
|
);
|
|
|
|
const SummitRequest = models.SummitRequest ?? model<ISummitRequest>("SummitRequest", summitRequestSchema, "summit_requests");
|
|
|
|
export default SummitRequest;
|