<?php
namespace JetApplicationModule\Test\REST;

use Jet\MVC_View;
use Jet\Form;
use Jet\UI;
use Jet\Tr;
use Jet\UI_button;

/**
 *
 * @var MVC_View $this
 * @var Form $form
 * @var Client $client
 */

$form = $this->getRaw( 'form' );
$client = $this->getRaw( 'client' );
?>
<style>
    h1 {
        background: #101010;
        color: #aaaaaa;
        padding: 4px;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    h3 {
        background: #b9b9b9;
        padding: 4px;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    h4 {
        background: #e9e9e9;
        padding: 4px;
        margin-top: 5px;
        margin-bottom: 5px;
    }
</style>
<div style="background: #0f0f0f;color: #c9c9c9;display: grid;align-items: center;grid-template-columns: 160px 1fr;">
	<div style="padding: 10px;"><img src="https://php-jet.net/images/logo-st.svg" style="width: 120px;height: auto"></div>
	<div><b><?= Tr::_( 'REST API Tests - client login' ) ?></b></div>
</div>
<div class="container-fluid">
	<div class="row">
		<div class="col-md-6 offset-md-3 col-sm-8 offset-sm-2">
			<div class="card" style="margin-top: 20px;margin-bottom: 20px;">
				<h5 class="card-header">
					<?= Tr::_( 'Sign In' ) ?>
				</h5>

				<div class="card-body">
					<?php
					echo $form->start();
					echo $form->getField( 'username' );
					echo $form->getField( 'password' );
					?>
					<div class="text-right">
						<?= UI::button( Tr::_( 'Sign In' ) )->setType( UI_button::TYPE_SUBMIT )->setClass( UI_button::CLASS_PRIMARY ); ?>
					</div>

					<?php
					echo $form->end();
					?>

				</div>
			</div>
		</div>
	</div>
	<?php if( $client ): ?>
		<div class="row">
			<div class="col-md-12">
				<h3><?= Tr::_( 'Request' ) ?></h3>
				<h4><?= Tr::_( 'Header' ) ?></h4>
				<pre><?= $client->request() ?></pre>
				<?php if( $client->requestBody() ): ?>
					<h4><?= Tr::_( 'Body' ) ?></h4>
					<pre><?= is_string( $client->requestBody() ) ? $client->requestBody() : print_r( $client->requestBody(), true ) ?></pre>
					<h4><?= Tr::_( 'Data' ) ?></h4>
					<pre><?= var_export( $client->requestData(), true ) ?></pre>
				<?php endif; ?>


				<h3><?= Tr::_( 'Response' ) ?></h3>
				<h4><?= Tr::_( 'Header' ) ?></h4>
				<pre><?= $client->responseHeader() ?></pre>
				<h4><?= Tr::_( 'Body' ) ?></h4>
				<pre><?= $client->responseBody() ?></pre>
				<h4><?= Tr::_( 'Data' ) ?></h4>
				<pre><?= var_export( $client->responseData(), true ) ?></pre>
			</div>
		</div>
	<?php endif; ?>
</div>


