package de.effigenix.domain.inventory;

public sealed interface StorageLocationError {

    String code();
    String message();

    record NameAlreadyExists(String name) implements StorageLocationError {
        @Override public String code() { return "STORAGE_LOCATION_NAME_EXISTS"; }
        @Override public String message() { return "Storage location name already exists: " + name; }
    }

    record InvalidName(String reason) implements StorageLocationError {
        @Override public String code() { return "INVALID_STORAGE_LOCATION_NAME"; }
        @Override public String message() { return "Invalid storage location name: " + reason; }
    }

    record InvalidTemperatureRange(String reason) implements StorageLocationError {
        @Override public String code() { return "INVALID_TEMPERATURE_RANGE"; }
        @Override public String message() { return "Invalid temperature range: " + reason; }
    }

    record InvalidStorageType(String value) implements StorageLocationError {
        @Override public String code() { return "INVALID_STORAGE_TYPE"; }
        @Override public String message() { return "Invalid storage type: " + value; }
    }

    record StorageLocationNotFound(String id) implements StorageLocationError {
        @Override public String code() { return "STORAGE_LOCATION_NOT_FOUND"; }
        @Override public String message() { return "Storage location not found: " + id; }
    }

    record StockExistsAtLocation(String locationId) implements StorageLocationError {
        @Override public String code() { return "STOCK_EXISTS_AT_LOCATION"; }
        @Override public String message() { return "Cannot deactivate: stock exists at location " + locationId; }
    }

    record AlreadyActive() implements StorageLocationError {
        @Override public String code() { return "ALREADY_ACTIVE"; }
        @Override public String message() { return "Storage location is already active"; }
    }

    record AlreadyInactive() implements StorageLocationError {
        @Override public String code() { return "ALREADY_INACTIVE"; }
        @Override public String message() { return "Storage location is already inactive"; }
    }

    record Unauthorized(String message) implements StorageLocationError {
        @Override public String code() { return "UNAUTHORIZED"; }
    }

    record RepositoryFailure(String message) implements StorageLocationError {
        @Override public String code() { return "REPOSITORY_ERROR"; }
    }
}
