Adds profile edit page

main
Yasen Pramatarov 2024-09-08 01:36:57 +03:00
parent 189d30bad5
commit 06a534c2da
4 changed files with 103 additions and 4 deletions

View File

@ -1,12 +1,20 @@
<?php
$action = $_REQUEST['action'] ?? '';
require '../app/classes/user.php';
$userObject = new User($dbWeb);
$userDetails = $userObject->getUserDetails($user);
include '../app/templates/profile.php';
switch ($action) {
case 'edit':
include '../app/templates/profile-edit.php';
break;
default:
include '../app/templates/profile.php';
}
?>

View File

@ -0,0 +1,74 @@
<!-- user profile -->
<div class="card text-center w-50 mx-auto">
<p class="h4 card-header">Profile of <?= $userDetails[0]['username'] ?></p>
<div class="card-body">
<div class="row">
<p class="border rounded bg-light mb-4"><small>edit the profile fields</small></p>
<div class="col-md-4">
<div class="border" style="width: 200px; height: 200px;"><img src="" alt="avatar" /></div>
</div>
<div class="col-md-8">
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="username" class="form-label"><small>username:</small></label>
<span class="text-danger" style="margin-right: -12px;">*</span>
</div>
<div class="col-md-8 text-start bg-light">
<input class="form-control" type="text" name="username" value="<?= $userDetails[0]['username'] ?>" required />
</div>
</div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="name" class="form-label"><small>name:</small></label>
</div>
<div class="col-md-8 text-start bg-light">
<input class="form-control" type="text" name="name" value="<?= $userDetails[0]['name'] ?>" />
</div>
</div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="email" class="form-label"><small>email:</small></label>
</div>
<div class="col-md-8 text-start bg-light">
<input class="form-control" type="text" name="email" value="<?= $userDetails[0]['email'] ?>" />
</div>
</div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="bio" class="form-label"><small>bio:</small></label>
</div>
<div class="col-md-8 text-start bg-light">
<textarea class="form-control" name="bio" rows="10"><?= $userDetails[0]['bio'] ?? '' ?></textarea>
</div>
</div>
<div class="row mb-3">
<div class="col-md-4 text-end">
<label for="rights" class="form-label"><small>rights:</small></label>
</div>
<div class="col-md-8 text-start bg-light">
<input class="form-control" type="text" name="rights" value="<?= $userDetails[0]['rights'] ?? '' ?>" />
</div>
</div>
</div>
<p>
<a href="<?= $app_root ?>?page=profile" class="btn btn-primary">Cancel</a>
<a href="<?= $app_root ?>?page=profile&action=edit" class="btn btn-danger">Save</a>
</p>
</div>
</div>
</div>
<!-- /user profile -->

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-md-4">
<div class="border" style="width:150px; height: 250px;"><img src="" alt="avatar" /></div>
<div class="border" style="width:200px; height: 200px;"><img src="" alt="avatar" /></div>
</div>
<div class="col-md-8">
@ -45,7 +45,7 @@
<label class="form-label"><small>bio:</small></label>
</div>
<div class="col-md-8 text-start bg-light">
<?= $userDetails[0]['bio'] ?? '' ?>
<textarea class="scroll-box" rows="10"><?= $userDetails[0]['bio'] ?? '' ?></textarea>
</div>
</div>
@ -58,9 +58,12 @@
</div>
</div>
<p><a href="<?= $app_root ?>?page=profile&action=edit" class="btn btn-primary">edit</a></p>
</div>
<p>
<a href="<?= $app_root ?>?page=profile&action=edit" class="btn btn-primary">Edit</a>
</p>
</div>
</div>

View File

@ -157,3 +157,17 @@
.sidebar-content a {
text-decoration: none;
}
/* profile */
.scroll-box {
width: 100%;
height: 250px;
padding: 10px;
border: 0;
background-color: #f8f9fa;
white-space: pre-wrap;
overflow-y: scroll;
resize: none;
font-family: inherit;
font-size: 14px;
}