package com.kbs.kbsintranett;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class TaskItem implements Serializable {
    private String id;
    private String title;
    private String description;
    private long dueDate;
    private String createdByEmail;
    private String createdByName;

    private Map<String, Boolean> assigneeStatus = new HashMap<>();

    private boolean notificationsEnabled = true;
    private boolean isFullyCompleted = false;

    public TaskItem(String title, String description, long dueDate) {
        this.id = UUID.randomUUID().toString();
        this.title = title;
        this.description = description;
        this.dueDate = dueDate;
        this.createdByEmail = UserManager.getInstance().getUserEmail();
        this.createdByName = UserManager.getInstance().getUserDisplayName();
    }

    // Getters
    public String getId() { return id; }
    public String getTitle() { return title; }
    public String getDescription() { return description; }
    public long getDueDate() { return dueDate; }
    public String getCreatedByEmail() { return createdByEmail; }
    public String getCreatedByName() { return createdByName; }
    public boolean isNotificationsEnabled() { return notificationsEnabled; }
    public boolean isFullyCompleted() { return isFullyCompleted; }

    // Setters (NYTT FOR REDIGERING)
    public void setTitle(String title) { this.title = title; }
    public void setDescription(String description) { this.description = description; }
    public void setDueDate(long dueDate) { this.dueDate = dueDate; }
    public void setNotificationsEnabled(boolean enabled) { this.notificationsEnabled = enabled; }
    public void setFullyCompleted(boolean fullyCompleted) { this.isFullyCompleted = fullyCompleted; }

    // Participant logikk
    public void addAssignee(String email) { assigneeStatus.put(email, false); }
    public void setParticipantStatus(String email, boolean done) { assigneeStatus.put(email, done); }
    public boolean getParticipantStatus(String email) { return assigneeStatus.getOrDefault(email, false); }
    public boolean isUserParticipant(String email) { return assigneeStatus.containsKey(email); }
    public Map<String, Boolean> getAssigneeStatus() { return assigneeStatus; }
}