Skip to content

Commit

Permalink
trx item not finish
Browse files Browse the repository at this point in the history
  • Loading branch information
AndikaHilmiHamdani committed May 20, 2022
1 parent f87e4fe commit cbd956f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 40 deletions.
71 changes: 35 additions & 36 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

@extends('layouts.app')

@section('content')
Expand All @@ -19,53 +18,53 @@
</div>
</div>

<!-- menu -->
<div class="absolute" style="left:10px;top: 125px;">
<div class="grid grid-cols-6 gap-4">
<div class="row-start-1 col-end-1">
<p class="text-xl text-gray-400">Nasi Goreng</p>
</div>
<div class="row-start-1 col-end-2">
<button><img class="w-full h-5" src="img/minus.png" /></button>
</div>
<div class="quantity row-start-1 col-end-3">
<p class="text-xl text-gray-400">1</p>
</div>
<div class="row-start-1 col-end-4">
<button><img class="w-full h-5" src="img/plus.png" /></button>
<!-- bayar -->
<form action="/checkout" method="post">
@csrf
@method('POST')
<div class="absolute" style="width: 417px; height: 86px; left: 50px; top: 728px;">
<button id="bayar" class="flex items-center justify-center px-44 pt-6 pb-8 bg-green-500 rounded-2xl" style="width: 300px; height: 50px;">
<p class="text-2xl font-bold text-white">Bayar</p>
</button>
</div>
<!-- menu -->
<div class="absolute" id="clicked_menu" style="left:10px;top: 125px;">
<div class="grid grid-cols-6 gap-4">
<div class="row-start-1 col-end-1">
<input id="nama_menu" name="id_menu[]" class="text-xl text-gray-400" readonly />
</div>
<div class="row-start-1 col-end-2">
<button type="button"><img class="w-full h-5" src="img/minus.png" id="minus" /></button>
</div>
<div class="quantity row-start-1 col-end-3">
<input class="text-xl text-gray-400" id="quantity" name="quantity[]" readonly/>
</div>
<div class="row-start-1 col-end-4">
<button type="button"><img class="w-full h-5" src="img/plus.png" id="plus" /></button>
</div>
<div class="row-start-1 col-end-5" style="width: 75px;">
<p class="text-sm text-green-500" id="totalPrice"></p>
</div>
</div>
<div class="row-start-1 col-end-5" style="width: 75px;">
<p class="text-sm text-green-500">Rp. 20.000</p>
<div class="py-2">
<div class="w-96 border-t border-gray-500" style="top:75px"></div>
</div>

</div>
<div class="py-2">
<div class="w-96 border-t border-gray-500" style="top:75px"></div>
</div>
</div>

<!-- <input class="text-xl text-gray-400" id="nama_menu" name="menu[].nama_menu" value="{{$menu[0]->nama_menu}}" readonly></input>
<input class="text-sm text-green-500" id="totalPrice" name="menu[].price" value="{{$menu[0]->price}}" readonly></input>
<input id="inputnama_menu" name="id_menu[]" class="text-xl text-gray-400" readonly />
<input name="quantity[]" value="2" /> -->
</form>
<!-- catatan -->
<div class="inline-flex space-x-2.5 items-center justify-end w-36 h-10 absolute" style="left: 47px; top: 430px;">
<button class="w-10 h-10"><img src="img/catatan.png" alt=""></button>
<p class="text-2xl text-green-500">Catatan</p>
</div>

<!-- bayar -->
<form action="/checkout" method="post">
@csrf
@method('POST')
<div class="absolute" style="width: 417px; height: 86px; left: 50px; top: 728px;">
<button id="bayar" class="flex items-center justify-center px-44 pt-6 pb-8 bg-green-500 rounded-2xl" style="width: 300px; height: 50px;" >
<p class="text-2xl font-bold text-white">Bayar</p>
</button>
</div>

<input name="id_menu[]" value="1" />
<input name="id_menu[]" value="2" />
<input name="quantity[]" value="1" />
<input name="quantity[]" value="2" />
</form>


</div>

</div>
Expand Down
56 changes: 52 additions & 4 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

<div class="kategori mx-4 mt-2">
<div class="inline-flex bg-white bg-opacity-50 border rounded-lg border-black ml-4" style="width: 750px; height: 35px; margin: left 10px;">
@foreach ($kategori as $kategori)
@foreach ($kategori as $kategori)
<a href="?id_kategori={{$kategori->id_kategori}}">
<p class="text-2xl mx-4 mt-2 {{$current_kategori==$kategori->id_kategori?'active:underline text-green-500':null}}">{{$kategori->nama_kategori}}</p>
</a>
@endforeach
@endforeach
</div>
</div>
</div>
Expand All @@ -33,7 +33,7 @@
<div class="inline-flex flex-col space-y-2.5 items-start">


<div class="group relative inline-flex items-center justify-center w-full h-64 pb-0.5 bg-gray-300">
<div class="group relative inline-flex items-center justify-center w-full h-64 pb-0.5 bg-gray-300" id="menu" onclick="clickMenu({{$item->id_menu}})">
@role('manajer')
<div class="absolute w-full h-full bg-gray-700/90 hidden group-hover:flex justify-center items-center gap-4">
<a class="inline " href="{{route('menu.edit', $item->id_menu)}}">
Expand Down Expand Up @@ -74,4 +74,52 @@
</div>
</body>

</html>
</html>
<script>
var result = <?php echo $menu->values()->toJson() ?>;
var clicked_menu
let plus = document.getElementById('plus')
let minus = document.getElementById('minus')
let count = 1
clickMenu = (str) => {
console.log("clicked")
console.log(str)
clicked_menu = document.getElementById('clicked_menu')
if (str == "") {
nama_menu = document.getElementById('nama_menu').innerHTML = ""
} else {
//looping result nama_menu
var menu = result.find(item => item.id_menu == str)
document.getElementById('nama_menu').value = menu.id_menu
document.getElementById('totalPrice').innerHTML = menu.price
document.getElementById('quantity').value = count
}
//count total price
plus.addEventListener("click", () => {
if ( count == 0||count > 0) {
count++
document.getElementById('quantity').value = count
var totprice = document.getElementById('totalPrice').innerHTML = menu.price * count
} else if (count < 0) {
console.log("jumlah tidak sesuai")
}
})
minus.addEventListener("click", () => {
if (count > 0) {
count--
document.getElementById('quantity').value = count
var totprice = document.getElementById('totalPrice').innerHTML = menu.price * count
} else {
console.log("jumlah tidak sesuai")
}
})
}
</script>

0 comments on commit cbd956f

Please sign in to comment.