import { z } from "zod"

const passwordSchema = z.string().min(6)



/* ============================= */
/* ADMIN AUTH                    */
/* ============================= */

export const AdminLoginSchema = z.object({
    email: z.email(),
    password: passwordSchema
})

export type AdminLoginInput = z.infer<typeof AdminLoginSchema>

export const AdminRegisterSchema = z.object({
    email: z.email(),
    password: z.string().min(6)
})

export const RefreshSchema = z.object({
    refreshToken: z.string()
})


/* ============================= */
/* SHOP USER (POS) AUTH         */
/* ============================= */

/** Étape 1 : login par email/password → retourne la liste des shops ou les tokens si un seul shop */
export const PosLoginSchema = z.object({
    email: z.email(),
    password: z.string().min(6)
})

export type PosLoginInput = z.infer<typeof PosLoginSchema>

/** Étape 2 (si multi-shop) : sélection du shop avec le sessionToken temporaire */
export const PosSelectShopSchema = z.object({
    sessionToken: z.string().min(1),
    shopId: z.string().uuid()
})

export type PosSelectShopInput = z.infer<typeof PosSelectShopSchema>

/** Switch de shop sans re-login (JWT shop-agnostic) */
export const PosSwitchShopSchema = z.object({
    shopId: z.string().uuid()
})

export type PosSwitchShopInput = z.infer<typeof PosSwitchShopSchema>


/* ============================= */
/* PASSWORD CHANGE               */
/* ============================= */

export const FirstLoginPasswordChangeSchema = z.object({
    newPassword: z.string().min(6)
})

export type FirstLoginPasswordChangeInput =
    z.infer<typeof FirstLoginPasswordChangeSchema>


export const ChangePasswordSchema = z.object({
    currentPassword: z.string().min(6),
    newPassword: z.string().min(6)
})

export type ChangePasswordInput =
    z.infer<typeof ChangePasswordSchema>