import { z } from 'zod';

export const ssoCallbackSchema = z.object({
  oktaSub: z.string().min(1, 'Okta sub is required'),
  email: z.string().email('Valid email is required'),
  employeeId: z.string().optional(), // Made optional
  firstName: z.string().optional(),
  lastName: z.string().optional(),
  displayName: z.string().optional(),
  department: z.string().optional(),
  designation: z.string().optional(),
  phone: z.string().optional(),
  reportingManagerId: z.string().uuid().optional(),
});

export const refreshTokenSchema = z.object({
  refreshToken: z.string().min(1, 'Refresh token is required').optional(),
});

export const tokenExchangeSchema = z.object({
  code: z.string().min(1, 'Authorization code is required'),
  redirectUri: z.string().url('Valid redirect URI is required'),
});

export const passwordLoginSchema = z.object({
  username: z.string().email('Valid email/username is required').or(z.string().min(1, 'Username is required')),
  password: z.string().min(1, 'Password is required'),
});

export const validateSSOCallback = (data: any) => {
  return ssoCallbackSchema.parse(data);
};

export const validateRefreshToken = (data: any) => {
  return refreshTokenSchema.parse(data);
};

export const validateTokenExchange = (data: any) => {
  return tokenExchangeSchema.parse(data);
};

export const validatePasswordLogin = (data: any) => {
  return passwordLoginSchema.parse(data);
};
