<?php

namespace Database\Seeders;

use App\Enums\FoodCategory;
use App\Enums\WeightUnit;
use App\Models\User;
use Illuminate\Database\Seeder;

class RefrigeratorItemSeeder extends Seeder
{
    public function run(): void
    {
        $user = User::first();

        if (! $user) {
            return;
        }

        $items = [
            ['name' => 'شیر', 'category' => FoodCategory::Dairy, 'quantity' => 1, 'unit' => WeightUnit::Liter, 'expiry_date' => now()->addDays(5)],
            ['name' => 'تخم مرغ', 'category' => FoodCategory::Dairy, 'quantity' => 12, 'unit' => WeightUnit::Piece, 'weight_grams' => 720, 'expiry_date' => now()->addDays(14)],
            ['name' => 'سینه مرغ', 'category' => FoodCategory::Meat, 'quantity' => 500, 'unit' => WeightUnit::Gram, 'expiry_date' => now()->addDays(3)],
            ['name' => 'گوجه فرنگی', 'category' => FoodCategory::Vegetables, 'quantity' => 4, 'unit' => WeightUnit::Piece, 'weight_grams' => 600, 'expiry_date' => now()->addDays(7)],
            ['name' => 'کاهو', 'category' => FoodCategory::Vegetables, 'quantity' => 1, 'unit' => WeightUnit::Piece, 'weight_grams' => 300, 'expiry_date' => now()->addDays(4)],
            ['name' => 'پنیر چدار', 'category' => FoodCategory::Dairy, 'quantity' => 200, 'unit' => WeightUnit::Gram, 'expiry_date' => now()->addDays(21)],
            ['name' => 'سیب', 'category' => FoodCategory::Fruits, 'quantity' => 6, 'unit' => WeightUnit::Piece, 'weight_grams' => 1200, 'expiry_date' => now()->addDays(10)],
            ['name' => 'برنج', 'category' => FoodCategory::Grains, 'quantity' => 1, 'unit' => WeightUnit::Kilogram, 'expiry_date' => now()->addMonths(6)],
            ['name' => 'آب پرتقال', 'category' => FoodCategory::Beverages, 'quantity' => 1, 'unit' => WeightUnit::Liter, 'expiry_date' => now()->addDays(10)],
            ['name' => 'سس گوجه', 'category' => FoodCategory::Condiments, 'quantity' => 1, 'unit' => WeightUnit::Piece, 'weight_grams' => 400, 'expiry_date' => now()->addMonths(3)],
        ];

        foreach ($items as $item) {
            $user->refrigeratorItems()->create(array_merge($item, [
                'added_at' => now(),
            ]));
        }
    }
}
