Skip to content

Commit

Permalink
Merge pull request #235 from wanderlust-group-project-1/adminstyles
Browse files Browse the repository at this point in the history
admin-complaints-resolve
  • Loading branch information
Sandali-Upekha authored Apr 27, 2024
2 parents a1569dd + 2e2c048 commit 6254c13
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 122 deletions.
32 changes: 22 additions & 10 deletions app/controllers/API/Complaints.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
<?php
<?php

class Complaints{
class Complaints
{
use Controller;

public function index(){

public function index()
{

$this->view('rental/complaints');
}

public function cancelComplaint(string $a = '', string $b = '', string $c = ''):void {
public function cancelComplaint(string $a = '', string $b = '', string $c = ''): void
{

$complaint = new RentReturnComplaintModel;
$complaint->cancelComplaint($a);

$response = new JSONResponse;
$response->statusCode(200)->data(['complaint_id' => $a])->send();
}

$complaint = new RentReturnComplaintModel;
$complaint->cancelComplaint($a);
public function resolveComplaint(string $a = ''): void
{

$response = new JSONResponse;
$response->statusCode(200)->data(['complaint_id' => $a])->send();
$complaint = new RentComplaintModel;
$complaint->resolveComplaint($a);

$response = new JSONResponse;
$response->statusCode(200)->success(true)->data(['complaint_id' => $a])->send();
}
}
}
55 changes: 35 additions & 20 deletions app/models/RentComplaint.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
<?php
class RentComplaintModel {
use Model;

protected string $table = 'rent_complaint';

protected array $allowedColumns = [
'rent_id',
'title',
'description',
'status'
];

public function createComplaint($data) {
$data = array_filter($data, function ($key) {
return in_array($key, $this->allowedColumns);
}, ARRAY_FILTER_USE_KEY);
class RentComplaintModel
{
use Model;

protected string $table = 'rent_return_complaints';

protected array $allowedColumns = [
'rent_id',
'title',
'description',
'status'
];

public function createComplaint($data)
{
$data = array_filter($data, function ($key) {
return in_array($key, $this->allowedColumns);
}, ARRAY_FILTER_USE_KEY);

$this->insert($data);
}

$this->insert($data);
}
public function resolveComplaint($id)
{

// $data = array_filter($data, function ($key) {
// return in_array($key, $this->allowedColumns);
// }, ARRAY_FILTER_USE_KEY);
//$table
$this->update($id, ['status' => 'resolved']);
}
public function getComplaints(array $data) {
return $this->where($data);
}
Expand All @@ -33,6 +44,10 @@ public function getComplaintsByCustomer(array $data) {
return $this->query($q->getQuery(), $q->getData());
}

}

?>

public function getComplaints(array $data)
{
return $this->where($data);
}
}
32 changes: 31 additions & 1 deletion app/views/admin/complains.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ function getComplaints(status, user = "customer") {




$(document).on('click', '#cancel-complaint-confirm', function() {
var complaintId = $(this).attr('data-id');
$.ajax({
Expand All @@ -203,6 +202,37 @@ function getComplaints(status, user = "customer") {
}
});
});





$(document).on('click', '#resolve-complaint', function() {
var complaintId = $(this).closest('.complaint').attr('data-id');
$('#resolve-complaint-confirm').attr('data-id', complaintId);
$('#resolve-complaint-modal').css('display', 'block');
});

$(document).on('click', '#resolve-complaint-confirm', function() {
var complaintId = $(this).attr('data-id');
$.ajax({
headers: {
'Authorization': 'Bearer ' + getCookie('jwt_auth_token')
},
url: '<?= ROOT_DIR ?>/api/complaints/resolveComplaint/' + complaintId,
type: 'GET',
success: function(response) {
console.log(response);
var id = response.data.complaint_id;
$('#complaint-card[data-id="' + id + '"]').remove();
$('#cancel-complaint-modal').css('display', 'none');
getComplaints('pending');
},
error: function(err) {
console.log(err);
}
});
});
</script>


Expand Down
14 changes: 13 additions & 1 deletion app/views/admin/components/complainlist.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<?php if ($complaint->status == 'pending') {
?>
<div class="flex-d-c">
<button class="btn-text-red" id="cancel-complaint"><i class="fa fa-check" aria-hidden="true"></i> Resolve</button>
<button class="btn-text-red" id="resolve-complaint"><i class="fa fa-check" aria-hidden="true"></i> Resolve</button>


<!-- <button class="btn-text-red" id="cancel-rented" hidden>Cancel</button> -->
Expand Down Expand Up @@ -105,6 +105,18 @@
</div>
</div>

<div id="resolve-complaint-modal" class="modal">
<div class="modal-content">
<span class="close">&times;</span>
<h2>Resolve Complaint</h2>
<p>Are you sure you want to resolve this complaint?</p>
<div class="flex-d gap-3 mt-3">
<button class="btn btn-primary" id="resolve-complaint-confirm">Yes</button>
<button class="btn btn-danger modal-close" id="resolve-complaint-cancel">No</button>
</div>
</div>
</div>

<style>

</style>
4 changes: 2 additions & 2 deletions app/views/admin/customer.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@


<div class="table-container">
<table class="data-table">
<table class="data-table table-custom">
<thead>
<tr>
<th>Name</th>
<th>Number</th>
<th>Address</th>
<th> Address</th>
<th>Action</th>
</tr>
</thead>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/guides.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


<div class="table-container">
<table class="data-table">
<table class="data-table table-custom">
<thead>
<tr>
<th>Name</th>
Expand Down
Loading

0 comments on commit 6254c13

Please sign in to comment.