format hp untk order tanggal done
This commit is contained in:
parent
e85df46673
commit
082b4d5adb
@ -338,7 +338,11 @@ function renderCartSummary() {
|
||||
|
||||
<!-- Tanggal -->
|
||||
<div class="col-12 col-md-2">
|
||||
<input type="text" class="form-control form-control-sm tanggal-input" id="tanggal-${item.id}-${i}" readonly placeholder="Pilih Tanggal">
|
||||
<input type="text"
|
||||
class="form-control form-control-sm tanggal-input"
|
||||
id="${item?.apakah_someday ? `tgl_someday-${item.id}-${i}`: `tanggal-${item.id}-${i}`}"
|
||||
readonly
|
||||
placeholder="Pilih Tanggal">
|
||||
</div>
|
||||
|
||||
<!-- Karbohidrat -->
|
||||
@ -468,10 +472,7 @@ function renderCartSummary() {
|
||||
|
||||
container.insertAdjacentHTML('beforeend', itemHTML);
|
||||
pesananList.forEach((p, i) => {
|
||||
const input = document.querySelector(`#tanggal-${item.id}-${i}`);
|
||||
if (input) {
|
||||
initFlatpickrTersedia(item, i); // baru panggil kalau element beneran ada
|
||||
}
|
||||
initFlatpickrTersedia(item, i);
|
||||
});
|
||||
|
||||
});
|
||||
@ -822,21 +823,27 @@ function initFlatpickrTersedia(item, i) {
|
||||
}
|
||||
|
||||
|
||||
flatpickr(`#tanggal-${item.id}-${i}`, {
|
||||
dateFormat: "Y-m-d",
|
||||
minDate: minTanggal,
|
||||
altInput: true,
|
||||
defaultDate: item.pesanan[i]?.tgl || null,
|
||||
disable: item?.apakah_someday ? [] : [
|
||||
function(date) {
|
||||
const ymd = date.toISOString().split("T")[0];
|
||||
return !availableDates.includes(ymd); // disable jika bukan tanggal yg tersedia
|
||||
const id = item?.apakah_someday
|
||||
? `#tgl_someday-${item.id}-${i}`
|
||||
: `#tanggal-${item.id}-${i}`;
|
||||
console.log(id);
|
||||
|
||||
const config = item?.apakah_someday
|
||||
? {
|
||||
disableMobile: true,
|
||||
minDate: minTanggal,
|
||||
onChange: (selectedDates, dateStr) =>
|
||||
onTanggalChange(item.id, i, dateStr)
|
||||
}
|
||||
],
|
||||
onChange: function(selectedDates, dateStr) {
|
||||
onTanggalChange(item.id, i, dateStr);
|
||||
}
|
||||
});
|
||||
: {
|
||||
dateFormat: "Y-m-d",
|
||||
enable: availableDates,
|
||||
defaultDate: item.pesanan[i]?.tgl || null,
|
||||
onChange: (selectedDates, dateStr) =>
|
||||
onTanggalChange(item.id, i, dateStr)
|
||||
};
|
||||
|
||||
flatpickr(id, config);
|
||||
}
|
||||
|
||||
function increment(itemId, index) {
|
||||
@ -848,7 +855,6 @@ function increment(itemId, index) {
|
||||
function decrement(itemId, index) {
|
||||
const input = document.getElementById(`jumlah-${itemId}-${index}`);
|
||||
let current = parseInt(input.value || "0");
|
||||
console.log(current);
|
||||
|
||||
if (current > 1) {
|
||||
input.value = current - 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user