Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…frontend into develop
  • Loading branch information
Thobeats committed Jul 8, 2020
2 parents fcad20d + 6d2afe5 commit e4ffdda
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 92 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/Auth/LoginController.php
Expand Up @@ -81,6 +81,9 @@ public function authenticate(Request $request)
// store data to cookie
Cookie::queue('api_token', $response->data->user->api_token);
Cookie::queue('user_role', $response->data->user->local->user_role);
Cookie::queue('first_name', $response->data->user->local->first_name);
Cookie::queue('email', $response->data->user->local->email);
Cookie::queue('last_name', $response->data->user->local->last_name);
Cookie::queue('is_active', $data->is_active);
Cookie::queue('phone_number', $data->phone_number);
Cookie::queue('user_id', $response->data->user->_id);
Expand Down
116 changes: 54 additions & 62 deletions app/Http/Controllers/SettingsController.php
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use GuzzleHttp\Client;

use Illuminate\Support\Facades\Cookie;

class SettingsController extends Controller
Expand All @@ -14,112 +15,103 @@ class SettingsController extends Controller
public $user_id;

// Controller action to display settings page.
public function index() {
public function index()
{

// Setting header
$this->headers = [ 'headers' => ['x-access-token' => Cookie::get('api_token')] ];
$user_details = [];
Cookie::get('user_id') !== null ? $user_details['id'] = Cookie::get('user_id') : "Not set";

// Setting User_id
$this->user_id = Cookie::get('user_id');
Cookie::get('email') !== null ? $user_details['email'] = Cookie::get('email') : "Not set";

try{
$url = env('API_URL', 'https://dev.api.customerpay.me'). '/user' .'/' . $this->user_id ;
$client = new Client();
$user_detail_process = $client->request('GET', $url, $this->headers);
Cookie::get('first_name') !== null ? $user_details['first_name'] = Cookie::get('first_name') : "Not set";

if ( $user_detail_process->getStatusCode() == 200 ) {
Cookie::get('last_name') !== null ? $user_details['last_name'] = Cookie::get('last_name') : "Not set";

$res = json_decode($user_detail_process->getBody(), true);
return view('backend.settings.settings')->with('user_details', $res);
}
if ($user_detail_process->getStatusCode() == 500) {
Cookie::get('phone_number') !== null ? $user_details['phone_number'] = Cookie::get('phone_number') : "Not set";

return view('errors.500');
}
} catch(\Exception $e) {
return view('errors.500');
}
Cookie::get('is_active') !== null ? $user_details['is_active'] = Cookie::get('is_active') : "Not set";
return view('backend.settings.settings')->with("user_details", $user_details);
// Setting User_id
$this->user_id = Cookie::get('user_id');
}

// Controller action to update user details.
public function update(Request $request) {
public function update(Request $request)
{

// Setting header
$this->headers = [ 'headers' => ['x-access-token' => Cookie::get('api_token')] ];


// Setting User_id
$this->user_id = Cookie::get('user_id');

try{

try {
// check if all fields are available
if($request->all()) {

if ($request->all()) {
$control = $request->input('control', '');

if ($control == 'profile_update') {

$url = env('API_URL', 'https://api.customerpay.me'). '/user/update/' . $this->user_id ;
$url = env('API_URL', 'https://dev.api.customerpay.me') . '/store-admin/update';
$client = new Client();
$phone_number = intval($request->input('phone_number'));
$data = [
// "content" => [
"first_name" => $request->input('first_name'),
"last_name" => $request->input('last_name'),
"email" => $request->input('email')
// ]
"first_name" => $request->input('first_name'),
"last_name" => $request->input('last_name'),
"email" => $request->input('email'),
"phone_number" => $phone_number
];
// make an api call to update the user_details
$form_response_process = $client->request('PUT', $url, $this->headers, $data);

$this->headers = ['headers' => ['x-access-token' => Cookie::get('api_token')], 'form_params' => $data];
$form_response_process = $client->request('PUT', $url, $this->headers);
} elseif ($control == 'password_change') {

// $url = env('API_URL', 'https://api.customerpay.me'). '/reset-password';
$url = env('API_URL', 'https://api.customerpay.me'). '/user/update/' . $this->user_id ;
$url = env('API_URL', 'https://dev.api.customerpay.me/') . '/user/update/';
$client = new Client();
$data = [
// "content" => [
// 'current_password' => $request->input('current_password'),
"new_password" => $request->input('new_password')
// 'current_password' => $request->input('current_password'),
"new_password" => $request->input('new_password')
// ]
];
// make an api call to update the user_details
$form_response_process = $client->request('PUT', $url, $this->headers, $data);

} else {

return view('errors.404');
}

$url = env('API_URL', 'https://api.customerpay.me'). '/user/' . $this->user_id ;
$client = new Client();
$user_detail_res_pocess = $client->request('GET', $url, $this->headers);

if ( $user_detail_res_pocess->getStatusCode() == 200 ) {

$user_detail_res = json_decode($user_detail_res_pocess->getBody(), true);
$form_response = json_decode($form_response_process->getBody(), true);
return view('backend.settings.settings')->with([
'user_details' => $user_detail_res,
'form_response' => $form_response
]);
}
if ($user_detail_res_pocess->getStatusCode() == 500) {

if ($form_response_process->getStatusCode() == 500) {
return view('errors.500');
}
if ($user_detail_res_pocess->getStatusCode() == 400) {

$user_detail_res = json_decode($user_detail_res_pocess->getBody(), true);
$form_response = json_decode($form_response->getBody(), true);
return view('backend.settings.settings')->with([
'user_details' => $user_detail_res,
'form_response' => $form_response
]);
if ($form_response_process->getStatusCode() == 400) {
$response = json_decode($form_response_process->getBody(), true);
$message = $response->error->description;
return view('backend.settings.settings')->with("user_details", $message);
}
if ($form_response_process->getStatusCode() == 200) {
$user_detail_res = json_decode($form_response_process->getBody(), true);

$filtered_user_detail = $user_detail_res['data']['store_admin']['local'];
$user_details = [
"email" => $filtered_user_detail['email'],
"phone_number" => $filtered_user_detail['phone_number'],
"first_name" => $filtered_user_detail['first_name'],
"last_name" => $filtered_user_detail['last_name'],
"is_active" => Cookie::get('is_active')
];
Cookie::queue('phone_number', $filtered_user_detail['phone_number']);
Cookie::queue('first_name', $filtered_user_detail['first_name']);
Cookie::queue('email', $filtered_user_detail['email']);
Cookie::queue('last_name', $filtered_user_detail['last_name']);
$request->session()->flash('alert-class', 'alert-success');
$request->session()->flash('message', "Profile details updated successfully");
return redirect()->route('setting')->with("user_details", $user_details);
}
} else {
return redirect()->route('settings');
}
} catch(\Exception $e) {
} catch (\Exception $e) {
return view('errors.500');
}
}
Expand Down
18 changes: 18 additions & 0 deletions public/frontend/assets/css/faq.css
Expand Up @@ -296,4 +296,22 @@

a:hover{
text-decoration: none;
}

.dissapear {
display: none;
}

.appear {
display: block;
}

.nothing-box {
display: none;
justify-content: center;
padding: 5% 0;
}

.nothing-box-show {
display: flex;
}
2 changes: 1 addition & 1 deletion public/frontend/assets/css/header-footer.css
Expand Up @@ -235,7 +235,7 @@ a.mobile__nav__h1__link > img{
footer {
height: auto;
background-color: var(--primary-dark);
padding: 5% 0;
padding: 2% 0;
}

.footer_left {
Expand Down
Binary file added public/frontend/assets/images/help-me.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions public/frontend/assets/js/faq.js
@@ -0,0 +1,38 @@
//add event listener for button click
// let search = document.querySelector('.faq-top__btn').addEventListener('click', showFilterResults);
let userText = document.querySelector('#search-faq')
let faqCard = document.querySelectorAll('.card h2')

//add input event listener
userText.addEventListener('keyup', showFilterResults)

function showFilterResults(e) {
const faqItem = faqCard;
const filterText = e.target.value.toLowerCase();

//console.log(faqItem);
// console.log(filterText);
//console.log(e.target.value)

faqItem.forEach(function (item) {
if (item.innerText.toLowerCase().indexOf(filterText) !== -1) {
item.parentElement.parentElement.parentElement.classList.remove('dissapear');
item.parentElement.parentElement.parentElement.classList.add('appear');
} else {
item.parentElement.parentElement.parentElement.classList.remove('appear');
item.parentElement.parentElement.parentElement.classList.add('dissapear');
};
});

let visibles = document.querySelectorAll('.appear')

if (visibles.length == 0) {
document.querySelector('#faq__accordion').classList.add('dissapear');
document.querySelector('.nothing-box').style.display = 'flex'
} else {
document.querySelector('#faq__accordion').classList.remove('dissapear');
document.querySelector('.nothing-box').style.display = 'none'
}


};
16 changes: 8 additions & 8 deletions resources/views/backend/dashboard/analytics.blade.php
Expand Up @@ -76,12 +76,12 @@
<div class="media-body">
<span class="text-muted text-uppercase font-size-12 font-weight-bold">Today
Revenue</span>
<h2 class="mb-0">$2189</h2>
<h2 class="mb-0">$0</h2>
</div>
<div class="align-self-center">
<div id="today-revenue-chart" class="apex-charts"></div>
<span class="text-success font-weight-bold font-size-13"><i class='uil uil-arrow-up'></i>
10.21%</span>
0%</span>
</div>
</div>
</div>
Expand All @@ -95,12 +95,12 @@
<div class="media-body">
<span class="text-muted text-uppercase font-size-12 font-weight-bold">Product
Sold</span>
<h2 class="mb-0">1065</h2>
<h2 class="mb-0">0</h2>
</div>
<div class="align-self-center">
<div id="today-product-sold-chart" class="apex-charts"></div>
<span class="text-danger font-weight-bold font-size-13"><i class='uil uil-arrow-down'></i>
5.05%</span>
0%</span>
</div>
</div>
</div>
Expand All @@ -114,12 +114,12 @@
<div class="media-body">
<span class="text-muted text-uppercase font-size-12 font-weight-bold">New
Customers</span>
<h2 class="mb-0">11</h2>
<h2 class="mb-0">0</h2>
</div>
<div class="align-self-center">
<div id="today-new-customer-chart" class="apex-charts"></div>
<span class="text-success font-weight-bold font-size-13"><i class='uil uil-arrow-up'></i>
25.16%</span>
0%</span>
</div>
</div>
</div>
Expand All @@ -133,12 +133,12 @@
<div class="media-body">
<span class="text-muted text-uppercase font-size-12 font-weight-bold">New
Visitors</span>
<h2 class="mb-0">750</h2>
<h2 class="mb-0">0</h2>
</div>
<div class="align-self-center">
<div id="today-new-visitors-chart" class="apex-charts"></div>
<span class="text-danger font-weight-bold font-size-13"><i class='uil uil-arrow-down'></i>
5.05%</span>
0%</span>
</div>
</div>
</div>
Expand Down

0 comments on commit e4ffdda

Please sign in to comment.