unit View.UnitDetails;

interface

uses
  System.SysUtils, System.Classes, JS, Web, WEBLib.Graphics, WEBLib.Controls,
  WEBLib.Forms, WEBLib.Dialogs;

type
  TFViewUnitDetails = class(TWebForm)
  private
    FUnitId: string;
    procedure InitializeForm;
  public
    class function CreateForm(AElementID, UnitId: string): TWebForm;
  end;

var
  FViewUnitDetails: TFViewUnitDetails;

implementation

{$R *.dfm}


class function TFViewUnitDetails.CreateForm(AElementID, UnitId: string): TWebForm;

  procedure AfterCreate(AForm: TObject);
  begin
    with TFViewUnitDetails(AForm) do
    begin
      FUnitId := UnitId;
      InitializeForm; // kick off loading / UI binding here
    end;
  end;

begin
  Application.CreateForm(TFViewUnitDetails, AElementID, Result, @AfterCreate);
end;


procedure TFViewUnitDetails.InitializeForm;
begin
  // TODO:
  // - call your XData endpoint with FUnitId
  // - bind fields / populate controls
  // - handle spinner / errors as you do elsewhere
end;

end.