From 25352a43327ef62c6626d267c476cd52daa438c4 Mon Sep 17 00:00:00 2001
From: hanafathiyah <hanafathiyah9b21@gmail.com>
Date: Fri, 2 Dec 2022 07:21:39 +0700
Subject: [PATCH] create something

---
 Controller/PremiumSongsController.php | 21 +++------------------
 View/Pages/PremiumSongs.php           | 14 +++-----------
 2 files changed, 6 insertions(+), 29 deletions(-)

diff --git a/Controller/PremiumSongsController.php b/Controller/PremiumSongsController.php
index e49df91..d2e66e3 100644
--- a/Controller/PremiumSongsController.php
+++ b/Controller/PremiumSongsController.php
@@ -17,22 +17,9 @@ class PremiumSongsController
     {
         //data ada
         $user_id = $req->auth ? $req->auth->user_id : -1;
-        $page = $req->getQuery("page") ?
-            ($req->getQuery("page") > 0 ? $req->getQuery("page") : SubsciberController::DEFAULT_PAGE)
-            : SubsciberController::DEFAULT_PAGE;
         $limit = $req->getQuery("limit") ?
             ($req->getQuery("limit") > 0 ? $req->getQuery("limit") : SubsciberController::DEFAULT_LIMIT)
             : SubsciberController::DEFAULT_LIMIT;
-        $data = SubsciberController::fetchSubscriptions($page, $limit, $user_id, $req->db);
-        if ($data === false) {
-            // return $res->json([
-            //   "status"=>"failed",
-            //   "message"=>"fetch operations failed",
-            //   "data"=>[],
-            //   "errors"=>curl_error($ch)
-            // ]);      
-            return $res->redirect("/", 500);
-        }
 
         //   $data = json_decode($output,true)["data"];
         //fetch max page
@@ -44,17 +31,15 @@ class PremiumSongsController
         $headers = [
             "X-API-KEY" => $rest_key
         ];
-        $output  = $fetcher->get("/singers/max-page", $param, $headers);
+        $output  = $fetcher->get("/songs", $param, $headers);
         $total_page = 1;
         if ($output) {
             $total_page = json_decode($output, true)["data"];
         }
+        $data = $output;
         return $res->view("Pages/PremiumSongs", [
-            "singers" => $data,
-            "page" => $page,
+            "songs" => $data,
             "limit" => $limit,
-            "next_page" => $page < $total_page ? $page + 1 : null,
-            "prev_page" => $page > 1 ? $page - 1 : null,
             "auth" => $req->auth,
         ]);
         // return $res->json([
diff --git a/View/Pages/PremiumSongs.php b/View/Pages/PremiumSongs.php
index 65ce21b..3f65a07 100644
--- a/View/Pages/PremiumSongs.php
+++ b/View/Pages/PremiumSongs.php
@@ -31,11 +31,11 @@ $this->layout("Templates/PageTemplate", [
     </thead>
     <tbody>
         <?php
-        foreach ($singers as $number => $singer) {
+        foreach ($songs as $number => $song) {
         ?>
             <tr>
                 <td><?= (10 * ($page - 1)) + ($number + 1) ?></td>
-                <td><?= $singer["name"] ?></td>
+                <td><?= $song["title"] ?></td>
                 <?php if (isset($auth)) { ?>
                     <td>
                         <div>
@@ -49,12 +49,4 @@ $this->layout("Templates/PageTemplate", [
         }
         ?>
     </tbody>
-</table>
-
-<?php
-$this->component("Component/Pagination", [
-    "page_number" => $page,
-    "next_page" => isset($next_page) && !is_null($next_page) ? "/premium?page=$next_page&limit=$limit" : null,
-    "prev_page" => isset($prev_page) && !is_null($prev_page) ? "/premium?page=$prev_page&limit=$limit" : null,
-])
-?>
\ No newline at end of file
+</table>
\ No newline at end of file
-- 
GitLab