test
This commit is contained in:
+39
-18
@@ -1,4 +1,9 @@
|
|||||||
import { gregorianToHijri, calculateMissedPrayers, getHijriAge, getHijriBirthDate } from "../utils/hijri.js";
|
import {
|
||||||
|
gregorianToHijri,
|
||||||
|
calculateMissedPrayers,
|
||||||
|
getHijriAge,
|
||||||
|
getHijriBirthDate,
|
||||||
|
} from "../utils/hijri.js";
|
||||||
|
|
||||||
const PRAYERS = [
|
const PRAYERS = [
|
||||||
{ id: "fajr", name: "SABAH", arabic: "Fecr" },
|
{ id: "fajr", name: "SABAH", arabic: "Fecr" },
|
||||||
@@ -10,7 +15,7 @@ const PRAYERS = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export function renderKaza(pb) {
|
export function renderKaza(pb) {
|
||||||
const pbBirthDate = pb.authStore.model?.birthDate;
|
const pbBirthDate = pb.authStore.model?.birthdate;
|
||||||
const pbGender = pb.authStore.model?.gender;
|
const pbGender = pb.authStore.model?.gender;
|
||||||
const profileS = localStorage.getItem("kaza_profile");
|
const profileS = localStorage.getItem("kaza_profile");
|
||||||
let profile = profileS ? JSON.parse(profileS) : null;
|
let profile = profileS ? JSON.parse(profileS) : null;
|
||||||
@@ -29,7 +34,9 @@ export function renderKaza(pb) {
|
|||||||
Hicri yaşını ve kalan kaza namazını takip et.
|
Hicri yaşını ve kalan kaza namazını takip et.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
${!birthDate ? `
|
${
|
||||||
|
!birthDate
|
||||||
|
? `
|
||||||
<div class="bg-slate-900/40 border border-white/10 p-6 rounded-2xl mb-6">
|
<div class="bg-slate-900/40 border border-white/10 p-6 rounded-2xl mb-6">
|
||||||
<h3 class="text-sm font-semibold text-slate-300 mb-4">Profil Bilgileri</h3>
|
<h3 class="text-sm font-semibold text-slate-300 mb-4">Profil Bilgileri</h3>
|
||||||
<form id="profileForm" class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
<form id="profileForm" class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||||
@@ -51,19 +58,22 @@ export function renderKaza(pb) {
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
` : `
|
`
|
||||||
|
: `
|
||||||
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 mb-6">
|
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 mb-6">
|
||||||
<div class="bg-slate-900/40 border border-white/10 p-3 rounded-2xl text-center">
|
<div class="bg-slate-900/40 border border-white/10 p-3 rounded-2xl text-center">
|
||||||
<p class="text-[10px] text-slate-400 mb-1">Hicri Doğum Tarihi</p>
|
<p class="text-[10px] text-slate-400 mb-1">Hicri Doğum Tarihi</p>
|
||||||
<p class="text-sm font-bold text-white" id="hijriBirthDateDisplay">-</p>
|
<p class="text-sm font-bold text-white" id="hijriBirthDateDisplay">-</p>
|
||||||
</div>
|
</div>
|
||||||
${PRAYERS.map((p) => `
|
${PRAYERS.map(
|
||||||
|
(p) => `
|
||||||
<div class="bg-slate-900/40 border border-white/10 p-3 rounded-2xl text-center">
|
<div class="bg-slate-900/40 border border-white/10 p-3 rounded-2xl text-center">
|
||||||
<p class="text-[10px] text-slate-400 mb-1">${p.name}</p>
|
<p class="text-[10px] text-slate-400 mb-1">${p.name}</p>
|
||||||
<p class="text-xs text-white">Kalan: <span id="remaining-${p.id}" class="font-bold text-emerald-300">-</span></p>
|
<p class="text-xs text-white">Kalan: <span id="remaining-${p.id}" class="font-bold text-emerald-300">-</span></p>
|
||||||
<p class="text-[10px] text-slate-500 mt-1">Toplam: <span id="total-${p.id}">-</span></p>
|
<p class="text-[10px] text-slate-500 mt-1">Toplam: <span id="total-${p.id}">-</span></p>
|
||||||
</div>
|
</div>
|
||||||
`).join("")}
|
`,
|
||||||
|
).join("")}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bg-slate-900/40 border border-white/10 p-4 rounded-2xl mb-6">
|
<div class="bg-slate-900/40 border border-white/10 p-4 rounded-2xl mb-6">
|
||||||
@@ -89,7 +99,7 @@ export function renderKaza(pb) {
|
|||||||
${PRAYERS.map((p) => {
|
${PRAYERS.map((p) => {
|
||||||
const todayKey = new Date().toISOString().split("T")[0];
|
const todayKey = new Date().toISOString().split("T")[0];
|
||||||
const alreadyDone = profile?.todayLogs?.some(
|
const alreadyDone = profile?.todayLogs?.some(
|
||||||
(l) => l.prayerId === p.id && l.date === todayKey
|
(l) => l.prayerId === p.id && l.date === todayKey,
|
||||||
);
|
);
|
||||||
return `
|
return `
|
||||||
<div class="bg-slate-900/40 border ${alreadyDone ? "border-emerald-500/50 bg-emerald-500/10" : "border-white/10"} rounded-2xl p-4 text-center transition-all">
|
<div class="bg-slate-900/40 border ${alreadyDone ? "border-emerald-500/50 bg-emerald-500/10" : "border-white/10"} rounded-2xl p-4 text-center transition-all">
|
||||||
@@ -106,7 +116,8 @@ export function renderKaza(pb) {
|
|||||||
<p class="text-xs text-slate-500">Yükleniyor...</p>
|
<p class="text-xs text-slate-500">Yükleniyor...</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`}
|
`
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@@ -185,7 +196,11 @@ export function renderKaza(pb) {
|
|||||||
await refreshKazaStats(container, pb, birthDate, gender, profile);
|
await refreshKazaStats(container, pb, birthDate, gender, profile);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Kaza eklenemedi:", err);
|
console.error("Kaza eklenemedi:", err);
|
||||||
showKazaMsg(msg, "Eklenemedi. PocketBase bağlantısını kontrol et.", false);
|
showKazaMsg(
|
||||||
|
msg,
|
||||||
|
"Eklenemedi. PocketBase bağlantısını kontrol et.",
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -223,7 +238,11 @@ export function renderKaza(pb) {
|
|||||||
await refreshKazaStats(container, pb, birthDate, gender, profile);
|
await refreshKazaStats(container, pb, birthDate, gender, profile);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Kaza çıkarılamadı:", err);
|
console.error("Kaza çıkarılamadı:", err);
|
||||||
showKazaMsg(msg, "Çıkarılamadı. PocketBase bağlantısını kontrol et.", false);
|
showKazaMsg(
|
||||||
|
msg,
|
||||||
|
"Çıkarılamadı. PocketBase bağlantısını kontrol et.",
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -261,7 +280,8 @@ async function refreshKazaStats(container, pb, birthDate, gender, profile) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
logs.forEach((l) => {
|
logs.forEach((l) => {
|
||||||
logsByPrayer[l.prayerId] = (logsByPrayer[l.prayerId] || 0) + (l.count || 1);
|
logsByPrayer[l.prayerId] =
|
||||||
|
(logsByPrayer[l.prayerId] || 0) + (l.count || 1);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Loglar yüklenemedi:", err);
|
console.error("Loglar yüklenemedi:", err);
|
||||||
@@ -287,18 +307,19 @@ async function refreshKazaStats(container, pb, birthDate, gender, profile) {
|
|||||||
|
|
||||||
const logsContainer = container.querySelector("#logsContainer");
|
const logsContainer = container.querySelector("#logsContainer");
|
||||||
if (logsContainer) {
|
if (logsContainer) {
|
||||||
logsContainer.innerHTML = logs
|
logsContainer.innerHTML =
|
||||||
.slice(0, 20)
|
logs
|
||||||
.map((log) => {
|
.slice(0, 20)
|
||||||
const prayer = PRAYERS.find((p) => p.id === log.prayerId);
|
.map((log) => {
|
||||||
return `
|
const prayer = PRAYERS.find((p) => p.id === log.prayerId);
|
||||||
|
return `
|
||||||
<div class="flex items-center justify-between bg-slate-900/20 border border-white/5 rounded-xl px-4 py-2">
|
<div class="flex items-center justify-between bg-slate-900/20 border border-white/5 rounded-xl px-4 py-2">
|
||||||
<span class="text-xs text-slate-300">${prayer?.name || log.prayerId} x${log.count} - ${log.date}</span>
|
<span class="text-xs text-slate-300">${prayer?.name || log.prayerId} x${log.count} - ${log.date}</span>
|
||||||
<span class="text-xs text-emerald-400">+${log.count}</span>
|
<span class="text-xs text-emerald-400">+${log.count}</span>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
.join("") || '<p class="text-xs text-slate-500">Henüz kayıt yok.</p>';
|
.join("") || '<p class="text-xs text-slate-500">Henüz kayıt yok.</p>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user