using Content.Shared.Cargo.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using System.Text;
namespace Content.Shared.Cargo
{
[DataDefinition, NetSerializable, Serializable]
public sealed partial class CargoOrderData
{
///
/// Price when the order was added.
///
[DataField]
public int Price;
///
/// A unique (arbitrary) ID which identifies this order.
///
[DataField]
public int OrderId { get; private set; }
///
/// Prototype Id for the item to be created
///
[DataField]
public string ProductId { get; private set; }
///
/// Prototype Name
///
[DataField]
public string ProductName { get; private set; }
///
/// The number of items in the order. Not readonly, as it might change
/// due to caps on the amount of orders that can be placed.
///
[DataField]
public int OrderQuantity;
///
/// How many instances of this order that we've already dispatched
///
[DataField]
public int NumDispatched = 0;
[DataField]
public string Requester { get; private set; }
// public String RequesterRank; // TODO Figure out how to get Character ID card data
// public int RequesterId;
[DataField]
public string Reason { get; private set; }
public bool Approved;
[DataField]
public string? Approver;
///
/// Which account to deduct funds from when ordering
///
[DataField]
public ProtoId Account;
public CargoOrderData(int orderId, string productId, string productName, int price, int amount, string requester, string reason, ProtoId account)
{
OrderId = orderId;
ProductId = productId;
ProductName = productName;
Price = price;
OrderQuantity = amount;
Requester = requester;
Reason = reason;
Account = account;
}
public void SetApproverData(string? approver)
{
Approver = approver;
}
public void SetApproverData(string? fullName, string? jobTitle)
{
var sb = new StringBuilder();
if (!string.IsNullOrWhiteSpace(fullName))
{
sb.Append($"{fullName} ");
}
if (!string.IsNullOrWhiteSpace(jobTitle))
{
sb.Append($"({jobTitle})");
}
Approver = sb.ToString();
}
}
}