diff --git a/app/Livewire/Branch.php b/app/Livewire/Branch.php
index 8fc28f2..85613f5 100644
--- a/app/Livewire/Branch.php
+++ b/app/Livewire/Branch.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,45 @@ class Branch extends Component
public function loadBranches()
{
- $this->branches = collect(json_decode(file_get_contents(storage_path('app/branches.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/getbranches');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']); this gets the data
+ // Properly use collect to handle the response data
+ $this->branches = collect($response->json()['data'])
+ ->map(function ($branches) {
+ //returns null
+ return [
+ 'station_uuid' => $branches['station_uuid'],
+ 'station_code' => $branches['code'],
+ 'station_name' => $branches['description'],
+ 'branch' => $branches['city'],
+ 'created_at' => $branches['created_at'],
+ 'created_by' => $branches['created_by'],
+ 'modified_by' => $branches['modified_by'],
+ 'date_modified' => $branches['modified_at'], // ✅ correct spelling
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load branches.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/Buttons/CreateUser.php b/app/Livewire/Buttons/CreateUser.php
index c748bad..a04ebb9 100644
--- a/app/Livewire/Buttons/CreateUser.php
+++ b/app/Livewire/Buttons/CreateUser.php
@@ -2,22 +2,85 @@
namespace App\Livewire\Buttons;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Component;
class CreateUser extends Component
{
- public $username, $first_name, $last_name, $email, $status = 'active', $role = 'admin', $default_password;
+ public $username;
+ public $firstname;
+ public $lastname;
+ public $email;
+ public $status = 'active';
+ public $role = 'admin';
+ public $default_password = '';
public function generatePassword()
{
- $this->default_password = bin2hex(random_bytes(4));
+ try {
+ // Get the access token from the session
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ // Make the request to generate the password
+ $response = Http::withToken($token)
+ ->post(config('services.backend_api.url') . '/api/cms/generatePassword');
+
+ // Check if the request was successful
+ if ($response->successful()) {
+ // Retrieve the password from the response
+ $this->default_password = $response->json()['data']['password'];
+ } else {
+ $this->addError('users', 'Failed to generate password.');
+ }
+ } catch (\Exception $e) {
+ // Handle any exceptions that occur during the request
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function submit()
{
- return redirect()->to('/main/user-management');
+
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)->post(config('services.backend_api.url') . '/api/cms/admin', [
+ 'username' => $this->username,
+ 'firstname' => $this->firstname,
+ 'lastname' => $this->lastname,
+ 'email' => $this->email,
+ 'status' => $this->status,
+ 'role' => $this->role,
+ 'password' => $this->default_password,
+ ]);
+
+ //handle backend response
+ if ($response->status() === 422) {
+ $errors = $response->json('data');
+ foreach ($errors as $field => $messages) {
+ $this->addError($field, $messages[0]);
+ }
+ return;
+ }
+
+ if ($response->successful()) {
+ session()->flash('success', 'User created successfully.');
+ return redirect('/main/user-management');
+ } else {
+ $this->addError('users', 'Failed to create user.');
+ }
}
-
+
public function cancel()
{
return redirect()->to('/main/user-management');
@@ -28,5 +91,3 @@ class CreateUser extends Component
return view('livewire.buttons.create-user');
}
}
-
-
diff --git a/app/Livewire/CardMember.php b/app/Livewire/CardMember.php
index 2c1c957..ce0fcc5 100644
--- a/app/Livewire/CardMember.php
+++ b/app/Livewire/CardMember.php
@@ -33,7 +33,9 @@ class CardMember extends Component
// dd($response->json());
if ($response->successful()) {
// Properly use collect to handle the response data
- $this->cardMembers = collect($response->json()['data'])->map(function ($cardMembers) {
+ $this->cardMembers = collect($response->json()['data'])
+ ->filter(function ($cardMembers) {return $cardMembers['is_locked'] == 0;})
+ ->map(function ($cardMembers) {
return [
'lcard_uuid' => $cardMembers['lcard_uuid'],
'card_number' => $cardMembers['card_number'],
@@ -46,7 +48,7 @@ class CardMember extends Component
});
} else {
- $this->addError('users', 'Failed to load users.');
+ $this->addError('users', 'Failed to load card members.');
}
} catch (\Exception $e) {
$this->addError('users', 'Error: ' . $e->getMessage());
diff --git a/app/Livewire/CardType.php b/app/Livewire/CardType.php
index 8f6f265..0f6ea77 100644
--- a/app/Livewire/CardType.php
+++ b/app/Livewire/CardType.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,8 +19,41 @@ class CardType extends Component
public function loadCardTypes()
{
- // Load card types from JSON file
- $this->cardTypes = collect(json_decode(file_get_contents(storage_path('app/card-types.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/cardType');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->cardTypes = collect($response->json()['data'])
+ ->map(function ($cardTypes) {
+
+ return [
+ 'cardtype_uuid' => $cardTypes['cardtype_uuid'],
+ 'code' => $cardTypes['code'],
+ 'name' => $cardTypes['name'],
+
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load top-up.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/Components/Table.php b/app/Livewire/Components/Table.php
index 594c33b..e9dde99 100644
--- a/app/Livewire/Components/Table.php
+++ b/app/Livewire/Components/Table.php
@@ -4,6 +4,8 @@ namespace App\Livewire\Components;
use Livewire\Component;
use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
class Table extends Component
{
@@ -24,7 +26,12 @@ class Table extends Component
public $sortDirection = 'asc';
public bool $hasSearch = true;
- public $rowKey = 'id';
+ //Update and Delete endpoints
+ public $updateEndpoint = '';
+ public $deleteEndpoint = '';
+
+ // Data identifier
+ public $rowKey = 'id';
public $startDate;
public $endDate;
@@ -39,34 +46,61 @@ class Table extends Component
public $modalMode = 'view';
public $modalData = [];
-public function mount($columns, $rows, $addRoute = null, $rowKey = 'id')
-{
- $this->columns = $columns;
- $this->rows = collect($rows)->map(function ($row) {
- return is_array($row) ? $row : (array) $row;
- })->values()->all();
- $this->addRoute = $addRoute;
- $this->rowKey = $rowKey;
- Log::info("Initial rows count: " . count($this->rows));
-}
+ public function mount($columns, $rows, $addRoute = null, $rowKey = 'id')
+ {
+ $this->columns = $columns;
+ $this->rows = collect($rows)->map(function ($row) {
+ return is_array($row) ? $row : (array) $row;
+ })->values()->all();
+ $this->addRoute = $addRoute;
+ $this->rowKey = $rowKey;
+ // Log::info("Initial rows count: " . count($this->rows));
+ }
-public function viewRow($id)
-{
- $this->modalData = collect($this->rows)->firstWhere($this->rowKey, $id) ?? [];
- $this->modalMode = 'view';
- $this->showModal = true;
-}
+ public function viewRow($id)
+ {
+ $this->modalData = collect($this->rows)->firstWhere($this->rowKey, $id) ?? [];
+ $this->modalMode = 'view';
+ $this->showModal = true;
+ }
+
-
public function editRow($id)
{
- $this->modalData = collect($this->rows)->firstWhere('id', $id) ?? [];
+ $this->modalData = collect($this->rows)->firstWhere($this->rowKey, $id) ?? [];
$this->modalMode = 'edit';
$this->showModal = true;
}
+public function saveRow()
+{
+ $token = Session::get('user')['access_token'] ?? null;
+
+ $url = rtrim(config('services.backend_api.url'), '/') . '/' . $this->updateEndpoint . '/' . $this->modalData[$this->rowKey];
+
+ try {
+ $response = Http::withToken($token)->put($url, $this->modalData);
+
+ if ($response->successful()) {
+ $this->closeModal();
+ $this->fetchData();
+ } else {
+ $errors = $response->json('errors') ?? [];
+
+ foreach ($errors as $field => $messages) {
+ $this->addError("modalData.$field", is_array($messages) ? $messages[0] : $messages);
+ }
+ }
+ } catch (\Exception $e) {
+ logger()->error('SaveRow error: ' . $e->getMessage());
+ $this->addError('modalData', 'Something went wrong. Please try again.');
+ }
+}
+
+
+
public function closeModal()
{
$this->showModal = false;
@@ -212,4 +246,4 @@ public function viewRow($id)
'renderKey' => $this->renderKey,
]);
}
-}
\ No newline at end of file
+}
diff --git a/app/Livewire/Header.php b/app/Livewire/Header.php
index 8b04c02..73400d3 100644
--- a/app/Livewire/Header.php
+++ b/app/Livewire/Header.php
@@ -3,14 +3,17 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Session;
class Header extends Component
{
- public function selectPage($page)
+ public $user;
+ public function mount()
{
- $this->dispatch('navigate-to-page', page: $page);
+ $this->user = Session::get('user');
}
+
public function render()
{
return view('livewire.header.header');
diff --git a/app/Livewire/LockedAccount.php b/app/Livewire/LockedAccount.php
index 516d8c1..11b380d 100644
--- a/app/Livewire/LockedAccount.php
+++ b/app/Livewire/LockedAccount.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Session;
+use Illuminate\Support\Facades\Http;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,48 @@ class LockedAccount extends Component
public function loadLockedAccounts()
{
- $this->lockedAccounts = collect(json_decode(file_get_contents(storage_path('app/locked-accounts.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/member?_locked=1');
+
+
+
+
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->lockedAccounts = collect($response->json()['data'])
+
+ ->filter(function ($lockedAccounts) {return (int) $lockedAccounts['is_locked'] == 1;})
+ ->map(function ($lockedAccounts) {
+
+ return [
+ 'lcard_uuid' => $lockedAccounts['lcard_uuid'],
+ 'card_number' => $lockedAccounts['card_number'],
+ 'firstname' => $lockedAccounts['firstname'],
+ 'lastname' => $lockedAccounts['lastname'],
+ 'birthdate' => $lockedAccounts['birthdate'],
+ 'cardtype_id' => $lockedAccounts['card_type'],
+ 'status' => $lockedAccounts['status'],
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load locked accounts.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/LoginForm.php b/app/Livewire/LoginForm.php
index 9dbd7e4..0c01af7 100644
--- a/app/Livewire/LoginForm.php
+++ b/app/Livewire/LoginForm.php
@@ -24,9 +24,10 @@ class LoginForm extends Component
'password' => $this->password,
]);
- $json = $response->json();
- // dd($json);
+ $json = $response->json();
+
+ // dd($json);
if ($response->successful()) {
if ($json['code'] === 200) {
@@ -46,7 +47,7 @@ class LoginForm extends Component
$this->addError('username', $message);
}
} catch (\Exception $e) {
- $this->addError('username', 'An error occurred: ' . $e->getMessage());
+ $this->addError('username', 'An error : ' . $e->getMessage());
}
}
diff --git a/app/Livewire/MobileUsageReport.php b/app/Livewire/MobileUsageReport.php
index c613852..31b33b0 100644
--- a/app/Livewire/MobileUsageReport.php
+++ b/app/Livewire/MobileUsageReport.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,46 @@ class MobileUsageReport extends Component
public function loadMobileUsageReport()
{
- $this->mobileUsageReport = collect(json_decode(file_get_contents(storage_path('app/mobile-usage.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/reportMobileUsage');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->mobileUsageReport = collect($response->json()['data'])
+ ->map(function ($mobileUsageReport) {
+
+ // dd($this->mobileUsageReport);
+
+ return [
+ 'mba_id' => $mobileUsageReport['mba_id'],
+ 'date' => $mobileUsageReport['date'],
+ 'active' => $mobileUsageReport['active'],
+ 'inactive' => $mobileUsageReport['inactive'],
+ 'locked' => $mobileUsageReport['locked'],
+
+ ];
+
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load mobile usage report.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/PhotoSlider.php b/app/Livewire/PhotoSlider.php
index 626fc42..c6a7db3 100644
--- a/app/Livewire/PhotoSlider.php
+++ b/app/Livewire/PhotoSlider.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,37 @@ class PhotoSlider extends Component
public function loadPhotoSliders()
{
- $this->photoSliders = collect(json_decode(file_get_contents(storage_path('app/photo-sliders.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/photoSlider');
+
+ // dd($response->json());
+ if ($response->successful()) {
+ // Properly use collect to handle the response data
+ $this->photoSliders = collect($response->json()['data'])
+ ->map(function ($photoSliders) {
+ return [
+ 'photoslider_uuid' => $photoSliders['photoslider_uuid'],
+ 'title' => $photoSliders['title'],
+ 'promotion_id' => $photoSliders['type'],
+ 'date_start' => $photoSliders['date_start'],
+ 'date_end' => $photoSliders['date_end'],
+ ];
+ });
+
+ } else {
+ $this->addError('users', 'Failed to load photo sliders.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/Promotion.php b/app/Livewire/Promotion.php
index 2123d6f..88035c8 100644
--- a/app/Livewire/Promotion.php
+++ b/app/Livewire/Promotion.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,40 @@ class Promotion extends Component
public function loadPromotions()
{
- $this->promotions = collect(json_decode(file_get_contents(storage_path('app/promotions.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/promotion');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // Properly use collect to handle the response data
+ $this->promotions = collect($response->json()['data'])
+ ->map(function ($promotions) {
+
+ return [
+ 'promotion_uuid' => $promotions['promotion_uuid'],
+ 'title' => $promotions['title'],
+ 'type' => $promotions['promo_type']['name'],
+ 'date_start' => $promotions['date_start'],
+ 'date_end' => $promotions['date_end'],
+ 'status' => $promotions['status'],
+ ];
+ });
+
+ } else {
+ $this->addError('users', 'Failed to load promotions.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/Station.php b/app/Livewire/Station.php
index f01033a..89a2887 100644
--- a/app/Livewire/Station.php
+++ b/app/Livewire/Station.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,45 @@ class Station extends Component
public function loadStations()
{
- $this->stations = collect(json_decode(file_get_contents(storage_path('app/stations.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/getStations');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']); this gets the data
+ // Properly use collect to handle the response data
+ $this->stations = collect($response->json()['data'])
+ ->map(function ($stations) {
+ //returns null
+ return [
+ 'station_uuid' => $stations['station_uuid'],
+ 'station_code' => $stations['code'],
+ 'station_name' => $stations['description'],
+ 'branch' => $stations['city'],
+ 'created_at' => $stations['created_at'],
+ 'created_by' => $stations['created_by'],
+ 'modified_by' => $stations['modified_by'],
+ 'date_modified' => $stations['modified_at'], // ✅ correct spelling
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load stations.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/StationRatingReport.php b/app/Livewire/StationRatingReport.php
index af5b919..36165f2 100644
--- a/app/Livewire/StationRatingReport.php
+++ b/app/Livewire/StationRatingReport.php
@@ -4,6 +4,8 @@ namespace App\Livewire;
use Livewire\Component;
use Livewire\Attributes\Layout; // Required for layout declaration
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
class StationRatingReport extends Component
@@ -17,7 +19,47 @@ class StationRatingReport extends Component
public function loadStationRating()
{
- $this->stationRating = collect(json_decode(file_get_contents(storage_path('app/station-rating.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/reportStationRatings');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->stationRating = collect($response->json()['data'])
+ ->map(function ($stationRating) {
+
+ // dd($this->stationRating);
+
+ return [
+ 'rating_uuid' => $stationRating['rating_uuid'],
+ 'date' => $stationRating['date'],
+ 'card_number' => $stationRating['card_number'],
+ 'invoice' => $stationRating['invoice'],
+ 'station' => $stationRating['station'],
+ 'rating' => $stationRating['rate'],
+
+ ];
+
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load top-up.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/TermsAndPrivacy.php b/app/Livewire/TermsAndPrivacy.php
index c77d0d6..1b03938 100644
--- a/app/Livewire/TermsAndPrivacy.php
+++ b/app/Livewire/TermsAndPrivacy.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,8 +19,42 @@ class TermsAndPrivacy extends Component
public function loadTermsAndPrivacy()
{
- // Load card types from JSON file
- $this->termsAndPrivacy = collect(json_decode(file_get_contents(storage_path('app/terms-privacy.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/TermsAndPrivacy');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->termsAndPrivacy = collect($response->json()['data'])
+ ->map(function ($termsAndPrivacy) {
+
+ return [
+ 'tp_uuid' => $termsAndPrivacy['tp_uuid'],
+ 'title' => $termsAndPrivacy['title'],
+ 'details' => $termsAndPrivacy['details'],
+ 'type' => $termsAndPrivacy['type'],
+
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load terms and privacy.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/app/Livewire/TopUp.php b/app/Livewire/TopUp.php
index 3da35cb..713a6af 100644
--- a/app/Livewire/TopUp.php
+++ b/app/Livewire/TopUp.php
@@ -3,6 +3,8 @@
namespace App\Livewire;
use Livewire\Component;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Session;
use Livewire\Attributes\Layout; // Required for layout declaration
#[Layout('layouts.dashboard')] // Attribute syntax for Laravel 11
@@ -17,7 +19,42 @@ class TopUp extends Component
public function loadTopUp()
{
- $this->topUp = collect(json_decode(file_get_contents(storage_path('app/top-up.json')), true));
+ try {
+ $token = Session::get('user')['access_token'] ?? null;
+
+ if (!$token) {
+ $this->addError('users', 'No access token found.');
+ return;
+ }
+
+ $response = Http::withToken($token)
+ ->get(config('services.backend_api.url') . '/api/cms/topUp');
+
+ // dd($response->json());
+ if ($response->successful()) {
+
+ // dd($response->json()['data']);
+ // Properly use collect to handle the response data
+ $this->topUp = collect($response->json()['data'])
+ ->map(function ($topUp) {
+
+ return [
+ 'topup_uuid' => $topUp['topup_uuid'],
+ 'fee_code' => $topUp['fee_code'],
+ 'name' => $topUp['name'],
+ 'amount' => $topUp['amount'],
+ 'type' => $topUp['type'],
+ ];
+ });
+
+ // dd($this->loadLockedAccounts());
+
+ } else {
+ $this->addError('users', 'Failed to load top-up.');
+ }
+ } catch (\Exception $e) {
+ $this->addError('users', 'Error: ' . $e->getMessage());
+ }
}
public function render()
diff --git a/config/services.php b/config/services.php
index 53e35bf..d7783e9 100644
--- a/config/services.php
+++ b/config/services.php
@@ -37,6 +37,6 @@ return [
'backend_api' => [
'url' => env('BACKEND_API_URL'),
-],
+ ],
];
diff --git a/resources/views/livewire/about-us/card-type.blade.php b/resources/views/livewire/about-us/card-type.blade.php
index e8ba704..81b2c25 100644
--- a/resources/views/livewire/about-us/card-type.blade.php
+++ b/resources/views/livewire/about-us/card-type.blade.php
@@ -3,12 +3,13 @@
@include('livewire.about-us.top-nav.card-type')