<?php
if (!defined('ABSPATH')) {
    exit;
}
$user = wp_get_current_user();
?>
<div class="chama-account-page-wrapper">
    <div class="chama-form-wrapper">
    <div class="chama-form-header">&#x1F512; Edit your account</div>
    <div class="chama-form-content">

	<?php
// show any error messages after form submission
chama_show_error_messages();?>

<?php 
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if(isset($_GET['account-updated']) && $_GET['account-updated'] == 'true') {
	 ?>
			<div class="chama-alert chama-alert-success">
				<span><?php esc_html_e('Account updated successfully', 'chama'); ?></span>
			</div>
		<?php } ?>
    <form id="chama-edit-account-form" class="chama-form" action="" method="POST">

				<p>
					<label for="chama_username"><?php esc_html_e('Username' , 'chama');?></label>
					<input name="chama_username" id="chama_username" class="required" type="text" value="<?php echo esc_attr($user->user_login) ?>" required data-msg="Please enter your username" readonly />
				</p>
				<p>
					<label for="chama_email"><?php esc_html_e('Email' , 'chama');?></label>
					<input name="chama_email" id="chama_email" class="required" type="email" value="<?php echo esc_attr($user->user_email) ?>" required data-msg="Please enter your email" data-msg-email="Enter a valid email"/>
				</p>
				<p>
					<label for="chama_display_name"><?php esc_html_e('Display name publicly as' , 'chama');?></label>
					<input name="chama_display_name" id="chama_display_name" class="required" type="text" value="<?php echo esc_attr($user->display_name) ?>" required data-msg="Please enter your name" />
				</p>
				<p>
					<label for="chama_first_name"><?php esc_html_e('First Name' , 'chama');?></label>
					<input name="chama_first_name" id="chama_first_name"  type="text" value="<?php echo esc_attr($user->first_name) ?>"  />
				</p>
				<p>
					<label for="chama_last_name"><?php esc_html_e('Last Name' , 'chama');?></label>
					<input name="chama_last_name" id="chama_last_name"  type="text" value="<?php echo esc_attr($user->last_name) ?>"   />
				</p>

				
				<p>
                    <input type="hidden" name="chama_action" value="edit-account"/>
                    <input type="hidden" name="chama_edit_account_nonce" value="<?php echo esc_attr(wp_create_nonce('chama-edit-account-nonce')); ?>"/>
                    <input type="submit" class="chama-button chama-account-submit" value="<?php esc_attr_e('Update' , 'chama');?>"/>
				</p>

		</form>

		</div>

</div>
</div>