<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class TaskController extends Controller
{
    public function index()
    {
        // just load the Blade file
        return view('app.main.task');
    }

    public function fetch(Request $request)
    {
        // Example: fetch tasks from DB later
        // Right now return dummy JSON to match your JS
        return response()->json([
            'code' => 200,
            'data' => [
                [
                    'link' => url('/task/1'),
                    'img' => asset('static/home/images/task1.png'),
                    'title' => 'First Task',
                    'content' => 'Complete your profile to earn rewards',
                    'createTime' => now()->toDateTimeString(),
                ],
                [
                    'link' => url('/task/2'),
                    'img' => asset('static/home/images/task2.png'),
                    'title' => 'Second Task',
                    'content' => 'Invite 1 friend to unlock bonus',
                    'createTime' => now()->toDateTimeString(),
                ]
            ]
        ]);
    }
}
