Skip to content
Snippets Groups Projects
Commit 39998392 authored by Fawwaz Anugrah Wiradhika Dharmasatya's avatar Fawwaz Anugrah Wiradhika Dharmasatya
Browse files

fix:fix bug

parents 96071ac1 d5b5289b
No related merge requests found
......@@ -2,11 +2,8 @@
namespace Controller;
use Exception;
use Lib\Enums\Request\HttpStatus;
use Lib\Interfaces\Routing\IRequest;
use Lib\Interfaces\Routing\IResponse;
use Model\Relations\Subscription;
use Lib\Service\Api\FetchAPI;
use Service\Soap\SubscribeSoap;
......@@ -17,50 +14,38 @@ 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);
}
$singer_id = $req->getParam("/premium/:id", "id");
$soap = new SubscribeSoap();
// $data = json_decode($output,true)["data"];
if(!$soap->is_access_permitted($singer_id, $user_id)){
return $res->redirect("/premium");
}
//fetch max page
$fetcher = new FetchAPI(getenv("REST_API"));
$param = [
"page-size" => $limit,
];
$rest_key = getenv("REST_KEY");
$headers = [
"X-API-KEY" => $rest_key
"X-API-KEY: $rest_key"
];
$output = $fetcher->get("/singers/max-page", $param, $headers);
$total_page = 1;
if ($output) {
$total_page = json_decode($output, true)["data"];
$output = $fetcher->get("/singers/$singer_id/songs", [
"user_id" => $user_id,
"with_singer" => "1"
], $headers);
$obj = json_decode($output, true);
if($obj["status"] === "success"){
$data = $obj["data"]["songs"];
}else{
$data = [];
}
return $res->view("Pages/PremiumSongs", [
"singers" => $data,
"page" => $page,
"limit" => $limit,
"next_page" => $page < $total_page ? $page + 1 : null,
"prev_page" => $page > 1 ? $page - 1 : null,
"songs" => $data,
"auth" => $req->auth,
"singer" => $obj["data"]["singer"],
]);
// return $res->json([
// "status"=>"success",
// "message"=>"premium singers successfully fetched",
// "data"=>$data
// ]);
}
};
......@@ -16,7 +16,7 @@ class PremiumRouter
//dapetin list penyanyi permium
$route->route(HttpMethod::Get, "/premium", [SubsciberController::class, "getPremiumSinger"]);
$route->route(HttpMethod::Post, "/premium/subscribe", [SubsciberController::class, "subscribeSinger"]);
$route->route(HttpMethod::Get, "/premium/songs/:id", [PremiumSongsController::class, "getPremiumSongs"]);
$route->route(HttpMethod::Get, "/premium/:id", [PremiumSongsController::class, "getPremiumSongs"]);
return $route;
}
......
......@@ -24,37 +24,23 @@ $this->layout("Templates/PageTemplate", [
<th>No</th>
<th>Judul</th>
<th>Penyanyi</th>
<?php if (isset($auth)) { ?>
<th>Putar Lagu</th>
<?php } ?>
<th>Putar Lagu</th>
</tr>
</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>
<?php if (isset($auth)) { ?>
<td>
<div>
bambank
</div>
</td>
<!-- <input type="hidden" value="<?= $singer["singer_id"] ?>"> -->
<?php } ?>
<td><?= $number + 1 ?></td>
<td><?= $song["title"] ?></td>
<td><?= $singer["name"] ?> </td>
<td>
<a href="/premium/<?= $singer["id"] ?>/play/<?= $song["song_id"] ?>">Play</a>
</td>
</tr>
<?php
}
?>
</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
......@@ -92,58 +92,6 @@ $this->partial("Partials/Header");
</div>
</a>
</li>
<li <?= isset($page) && $page === "premium-songs" ? 'class="active"' : "" ?>>
<a href="/premium/songs">
<div class="navigation__icon">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 450.541 450.541" style="enable-background:new 0 0 450.541 450.541;" xml:space="preserve">
<path id="XMLID_171_" d="M84.003,62.628c-1.666,2.887-4.692,4.502-7.803,4.502c-1.526,0-3.073-0.39-4.491-1.208l-19.903-11.49
c-4.305-2.484-5.779-7.989-3.294-12.294c2.483-4.304,7.985-5.781,12.294-3.294l19.903,11.49
C85.014,52.818,86.488,58.323,84.003,62.628z M71.709,222.455l-19.903,11.49c-4.305,2.484-5.779,7.989-3.294,12.294
c1.667,2.888,4.691,4.502,7.803,4.502c1.526,0,3.073-0.39,4.491-1.208l19.903-11.49c4.305-2.484,5.779-7.989,3.294-12.294
C81.52,221.446,76.018,219.97,71.709,222.455z M62.149,144.188c0-4.971-4.029-9-9-9H30.166c-4.971,0-9,4.029-9,9s4.029,9,9,9h22.983
C58.12,153.188,62.149,149.158,62.149,144.188z M374.341,67.129c1.526,0,3.074-0.39,4.491-1.208l19.903-11.491
c4.305-2.485,5.779-7.989,3.294-12.294c-2.484-4.304-7.988-5.779-12.294-3.294l-19.903,11.491
c-4.305,2.485-5.779,7.989-3.294,12.294C368.205,65.515,371.229,67.129,374.341,67.129z M225.271,37.318c-4.971,0-9,4.029-9,9
s4.029,9,9,9c16.063,0,29.131,13.068,29.131,29.131c0,4.971,4.029,9,9,9s9-4.029,9-9C272.402,58.461,251.26,37.318,225.271,37.318z
M284.683,407.301c-0.854,18.946-15.87,33.787-34.185,33.787h-5.627c0.007,0.15,0.011,0.301,0.011,0.453c0,4.971-4.029,9-9,9
h-21.221c-4.971,0-9-4.029-9-9c0-0.152,0.004-0.303,0.012-0.453h-5.63c-18.315,0-33.331-14.841-34.186-33.787l-9.599-212.985
c-9.218-6.729-17.377-14.736-24.3-23.852c-1.189-1.565-1.833-3.478-1.833-5.443v-38.385c0-4.971,4.029-9,9-9h0.614V85.53
C139.74,38.369,178.109,0,225.271,0c47.161,0,85.53,38.369,85.53,85.53v32.105h0.613c4.971,0,9,4.029,9,9v38.385
c0,1.966-0.644,3.878-1.832,5.443c-6.921,9.112-15.081,17.12-24.301,23.851l-1.059,23.504c-0.224,4.965-4.407,8.793-9.396,8.586
c-4.965-0.224-8.81-4.431-8.586-9.396l0.813-18.045H174.487l3.505,77.786h15.304c4.971,0,9,4.029,9,9s-4.029,9-9,9h-14.492
l5.036,111.741c0.419,9.307,7.537,16.598,16.203,16.598h50.455c8.666,0,15.783-7.291,16.202-16.598
c0.224-4.966,4.436-8.807,9.396-8.586C281.063,398.129,284.906,402.335,284.683,407.301z M157.74,117.636h135.062V85.53
c0-37.236-30.294-67.53-67.53-67.53c-37.237,0-67.531,30.294-67.531,67.53V117.636z M168.532,180.963h113.477
c7.679-5.37,14.527-11.763,20.406-19.045v-26.046c-0.926,0.062-153.36,0.063-154.289,0v26.045
C154.007,169.202,160.855,175.595,168.532,180.963z M362.924,296.563c5.789,18.314-9.17,27.178-19.068,33.043
c-2.071,1.227-5.265,3.119-6.945,4.461c0.589,2.031,2.063,5.341,3.021,7.489c4.7,10.558,11.803,26.511-4.106,37.876
c-15.633,11.164-28.672-0.313-37.301-7.908c-1.807-1.59-4.593-4.042-6.389-5.226c-1.749,1.188-4.443,3.614-6.191,5.188
c-5.983,5.387-14.097,12.69-23.787,12.692c-4.218,0-8.731-1.383-13.501-4.907c-15.451-11.414-8.567-27.357-4.013-37.907
c0.956-2.214,2.429-5.627,3.005-7.707c-1.676-1.299-4.815-3.111-6.855-4.288c-0.172-0.101-0.339-0.202-0.502-0.305
c-9.286-5.363-24.567-14.324-18.421-32.739c6.077-18.205,23.362-16.586,34.798-15.519c2.409,0.225,6.106,0.566,8.266,0.472
c0.717-1.993,1.47-5.541,1.959-7.844c1.276-6.015,2.597-12.234,5.739-17.45c4.245-7.047,11.018-10.767,19.597-10.767
c0.08,0,0.16,0.001,0.24,0.001c19.21,0.151,23.015,17.1,25.531,28.315c0.527,2.35,1.341,5.974,2.099,7.985
c2.114,0.066,5.732-0.31,8.079-0.556C339.674,279.756,357.034,277.927,362.924,296.563z M345.761,301.988
c-1.111-3.511-2.111-4.554-15.688-3.124c-7.533,0.789-15.302,1.604-20.794-2.382c-5.468-3.976-7.183-11.615-8.842-19.004
c-2.878-12.823-4.188-14.229-8.109-14.259c-0.066,0.001-0.145-0.001-0.216-0.001c-3.526,0-4.832,0.857-7.612,13.955
c-1.569,7.391-3.192,15.032-8.672,19.012c-5.485,3.981-13.284,3.251-20.827,2.544c-3.712-0.347-6.51-0.53-8.643-0.53
c-5.384,0-6.527,1.169-7.414,3.826c-1.139,3.412-0.949,4.929,10.521,11.553c0.139,0.081,0.276,0.165,0.411,0.253
c6.464,3.729,13.234,7.638,15.328,14.092c2.084,6.4-1.027,13.607-4.036,20.577c-5.206,12.059-4.973,13.964-1.816,16.295
c2.971,2.196,4.397,2.454,14.543-6.681c5.615-5.056,11.418-10.28,18.202-10.28c6.754,0,12.634,5.175,18.319,10.179
c9.869,8.687,11.754,9.052,14.946,6.772c3.001-2.144,3.685-3.418-1.875-15.906c-3.072-6.896-6.249-14.028-4.148-20.485
c2.081-6.416,8.822-10.41,15.341-14.272C346.008,307.408,346.942,305.728,345.761,301.988z M221.31,228.856c-4.971,0-9,4.029-9,9
s4.029,9,9,9h7.923c4.971,0,9-4.029,9-9s-4.029-9-9-9H221.31z M398.735,233.946l-19.903-11.49c-4.309-2.486-9.811-1.01-12.294,3.294
c-2.485,4.305-1.011,9.81,3.294,12.294l19.903,11.49c1.418,0.818,2.965,1.208,4.491,1.208c3.11,0,6.137-1.615,7.803-4.502
C404.515,241.936,403.04,236.431,398.735,233.946z M420.375,135.188h-22.983c-4.971,0-9,4.029-9,9s4.029,9,9,9h22.983
c4.971,0,9-4.029,9-9S425.346,135.188,420.375,135.188z" fill="#4F514F" fill-opacity="1"/>
</svg>
</div>
<div class="navigation__content">
Premium Songs
</div>
</a>
</li>
<?php if (isset($auth) && $auth->is_admin) { ?>
<li <?= isset($page) && $page === "add-album" ? 'class="active"' : "" ?>>
<a href="/admin/add-album">
......
......@@ -19,7 +19,6 @@ function http(method, url, options) {
if (this.readyState === 4) {
let data = this.responseText;
if (this.getResponseHeader("Content-Type") === "application/json") {
console.log(data)
data = JSON.parse(data);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment