import 'dart:math' as math show Random;

import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/analytics/models/device_energy_data_model.dart';
import 'package:syncrow_web/pages/analytics/models/energy_data_model.dart';
import 'package:syncrow_web/pages/analytics/params/get_energy_consumption_per_device_param.dart';
import 'package:syncrow_web/pages/analytics/services/energy_consumption_per_device/energy_consumption_per_device_service.dart';

class FakeEnergyConsumptionPerDeviceService
    implements EnergyConsumptionPerDeviceService {
  @override
  Future<List<DeviceEnergyDataModel>> load(
    GetEnergyConsumptionPerDeviceParam param,
  ) {
    final random = math.Random();
    return Future.delayed(const Duration(milliseconds: 500), () {
      return [
        (Colors.redAccent, 1),
        (Colors.lightBlueAccent, 2),
        (Colors.purpleAccent, 3),
      ].map((e) {
        final (color, index) = e;
        return DeviceEnergyDataModel(
          color: color,
          energy: List.generate(30, (i) => i)
              .map(
                (index) => EnergyDataModel(
                  date: DateTime(2025, 1, index + 1),
                  value: random.nextInt(100) + (index * 100),
                ),
              )
              .toList(),
          deviceName: 'Device $index',
          deviceId: 'device_$index',
        );
      }).toList();
    });
  }
}
