package com.alttd.altitudeweb.mappers;

import com.alttd.altitudeweb.database.web_db.forms.Appeal;
import com.alttd.altitudeweb.model.MinecraftAppealDto;
import org.springframework.stereotype.Service;

import java.time.Instant;
import java.util.UUID;

@Service
public class AppealDataMapper {
    public MinecraftAppealDto appealToMinecraftAppealDto(Appeal appeal) {
        MinecraftAppealDto minecraftAppealDto = new MinecraftAppealDto();
        minecraftAppealDto.setAppeal(appeal.reason());
        minecraftAppealDto.setUsername(appeal.username());
        minecraftAppealDto.setUuid(appeal.uuid());
        minecraftAppealDto.setEmail(appeal.email());
        return minecraftAppealDto;
    }

    public Appeal minecraftAppealDtoToAppeal(MinecraftAppealDto minecraftAppealDto) {
        return new Appeal(
                UUID.randomUUID(),
                minecraftAppealDto.getUuid(),
                minecraftAppealDto.getPunishmentType().toString(),
                minecraftAppealDto.getPunishmentId(),
                minecraftAppealDto.getUsername(),
                minecraftAppealDto.getAppeal(),
                Instant.now(),
                null,
                minecraftAppealDto.getEmail(),
                null
        );
    }
}
