Skip to content

Commit

Permalink
feat: add remember name
Browse files Browse the repository at this point in the history
  • Loading branch information
dewanakl committed Sep 19, 2024
1 parent 202ae93 commit 4a3591f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ <h2 class="font-esthetic mt-0 mb-3" style="font-size: 2.5rem;">Love Gift</h2>
<div class="d-flex justify-content-between align-items-center mt-2">
<p class="m-0 p-0" style="font-size: 0.95rem;">1234 5678 9101 112</p>
<!-- Ubah juga data-copy sesuai dengan no rekening -->
<button class="btn btn-outline-dark btn-sm rounded-4" data-copy="123456789101112" onclick="util.copy(this, 'Tersalin')">Salin</button>
<button class="btn btn-outline-dark btn-sm rounded-4" data-copy="123456789101112" onclick="util.copy(this, 'Tersalin')"><i class="fa-solid fa-copy me-1"></i>Salin</button>
</div>

<p class="mt-2 mb-0 p-0" style="font-size: 0.95rem;">Nama Wahyu Siapa</p>
Expand All @@ -429,7 +429,7 @@ <h2 class="font-esthetic mt-0 mb-3" style="font-size: 2.5rem;">Love Gift</h2>
<div class="d-flex justify-content-between align-items-center mt-2">
<p class="m-0 p-0" style="font-size: 0.95rem;">1234 5678 9101 112</p>
<!-- Ubah juga data-copy sesuai dengan no rekening -->
<button class="btn btn-outline-dark btn-sm rounded-4" data-copy="123456789101112" onclick="util.copy(this, 'Tersalin')">Salin</button>
<button class="btn btn-outline-dark btn-sm rounded-4" data-copy="123456789101112" onclick="util.copy(this, 'Tersalin')"><i class="fa-solid fa-copy me-1"></i>Salin</button>
</div>

<p class="mt-2 mb-0 p-0" style="font-size: 0.95rem;">Nama Riski Siapa</p>
Expand Down
4 changes: 2 additions & 2 deletions js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const card = (() => {
inner.classList.add('my-2');
inner.id = `inner-${id}`;
inner.innerHTML = `
<label for="form-inner-${id}" class="form-label">Reply</label>
<label for="form-inner-${id}" class="form-label"><i class="fa-solid fa-reply me-1"></i>Reply</label>
<textarea class="form-control shadow-sm rounded-4 mb-2" id="form-inner-${id}" placeholder="Type reply comment"></textarea>
<div class="d-flex flex-wrap justify-content-end align-items-center mb-0">
<button style="font-size: 0.8rem;" onclick="comment.cancel('${id}')" class="btn btn-sm btn-outline-${theme.isDarkMode('light', 'dark')} rounded-4 py-0 me-1">Cancel</button>
Expand All @@ -185,7 +185,7 @@ export const card = (() => {
inner.classList.add('my-2');
inner.id = `inner-${id}`;
inner.innerHTML = `
<label for="form-inner-${id}" class="form-label">Edit</label>
<label for="form-inner-${id}" class="form-label"><i class="fa-solid fa-pen me-1"></i>Edit</label>
${document.getElementById(id).getAttribute('data-parent') === 'true' && !session.isAdmin() ? `
<select class="form-select shadow-sm mb-2 rounded-4" id="form-inner-presence-${id}">
<option value="1" ${presence ? 'selected' : ''}>Datang</option>
Expand Down
15 changes: 8 additions & 7 deletions js/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,27 @@ export const comment = (() => {
const id = button.getAttribute('data-uuid');

const name = document.getElementById('form-name');
let nameValue = name.value;
let nameValue = storage('information').get('name') ?? name.value;

if (session.isAdmin()) {
nameValue = user.get('name');
}

if (nameValue.length == 0) {
alert('Please fill name');
alert('Silakan masukkan nama Anda.');
return;
}

if (!id && name && !session.isAdmin()) {
name.disabled = true;
}

const presence = document.getElementById('form-presence');
if (!id && presence && presence.value == "0") {
alert('Please select presence');
alert('Silakan pilih status kehadiran Anda.');
return;
}

if (!id && name && !session.isAdmin()) {
name.disabled = true;
}

if (presence && presence.value != "0") {
presence.disabled = true;
}
Expand All @@ -177,6 +177,7 @@ export const comment = (() => {
}

const btn = util.disableButton(button);
storage('information').set('name', nameValue);

const response = await request(HTTP_POST, '/api/comment')
.token(session.getToken())
Expand Down
2 changes: 1 addition & 1 deletion js/guest.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const guest = (() => {

const form = document.getElementById('form-name');
if (form) {
form.value = name;
form.value = storage('information').get('name') ?? name;
}
};

Expand Down

0 comments on commit 4a3591f

Please sign in to comment.