/**
 * The services layer is organized as follows:
 *
 * - `services/utils.ts`: Core API utilities that handle authentication,
 *   request formatting, and common CRUD operations.
 *
 * - `services/[table]/query.ts`: Table-specific API methods that use the core utilities
 *   to interact with specific API endpoints. Each table has its own query file with
 *   specialized methods for that data type (e.g., courses, users, etc.).
 *
 * - `services/[table]/mock.ts`: Mock implementations of the same methods found in query.ts.
 *   These files serve as drop-in replacements for development or testing purposes.
 *
 * ## Mock Implementation
 *
 * The mock.ts files implement the EXACT SAME interface as their query.ts counterparts.
 * This means:
 *
 * - All method signatures are identical (same names, parameters, and return types)
 * - All exported types and interfaces are identical
 * - The mock implementations return realistic data structures that match what the API would return
 *
 * This allows for easy switching between real API calls and mock data by simply changing imports.
 */

// Mock data for students
export const students = [
  {
    id: 1,
    user_id: 201,
    name: "John Doe",
    email: "john.doe@example.com",
    avatar: "/user-avatar.png",
    contact_number: "+1-234-567-8910",
    created_at: "2024-01-15T08:00:00Z",
    updated_at: "2024-04-10T14:30:00Z",
  },
  {
    id: 2,
    user_id: 202,
    name: "Jane Smith",
    email: "jane.smith@example.com",
    avatar: "/placeholder.svg?key=jsq8k",
    contact_number: "+1-234-567-8911",
    created_at: "2024-01-20T09:15:00Z",
    updated_at: "2024-04-12T11:45:00Z",
  },
  {
    id: 3,
    user_id: 203,
    name: "David Johnson",
    email: "david.johnson@example.com",
    avatar: "/placeholder.svg?key=iotbj",
    contact_number: "+1-234-567-8912",
    created_at: "2024-01-25T10:30:00Z",
    updated_at: "2024-04-15T16:20:00Z",
  },
]

export const getStudentById = (id: number) => {
  return students.find((student) => student.id === id)
}

export const getStudentByUserId = (userId: number) => {
  return students.find((student) => student.user_id === userId)
}

export const createStudent = (studentData: any) => {
  const newStudent = {
    id: students.length + 1,
    ...studentData,
    created_at: new Date().toISOString(),
    updated_at: new Date().toISOString(),
  }
  students.push(newStudent)
  return newStudent
}

export default {
  students,
  getStudentById,
  getStudentByUserId,
  createStudent,
}
