Commit 0b3d240c authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: daily reward — use correct column name last_daily_reward

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent bd053eda
......@@ -14,7 +14,7 @@ if (!$token) {
$method = $_SERVER['REQUEST_METHOD'];
if ($method === 'POST') {
$profileRes = supabase_rest('GET', 'profiles?select=id,coins,xp,level,daily_streak,last_daily_claim', [], $token);
$profileRes = supabase_rest('GET', 'profiles?select=id,coins,xp,level,daily_streak,last_daily_reward', [], $token);
if (empty($profileRes['data'])) {
http_response_code(400);
echo json_encode(['error' => 'profile not found']);
......@@ -22,7 +22,7 @@ if ($method === 'POST') {
}
$profile = $profileRes['data'][0];
$lastClaim = $profile['last_daily_claim'] ?? null;
$lastClaim = $profile['last_daily_reward'] ?? null;
$today = date('Y-m-d');
if ($lastClaim === $today) {
......@@ -55,7 +55,7 @@ if ($method === 'POST') {
'coins' => $newCoins,
'xp' => $newXp,
'daily_streak' => $streak,
'last_daily_claim' => $today,
'last_daily_reward' => $today,
];
// Check for level up
......
......@@ -101,7 +101,7 @@ document.addEventListener('DOMContentLoaded', async () => {
document.getElementById('streak-reward').textContent = '+' + (50 + streak * 10) + ' عملة';
});
const claimedToday = p.last_daily_claim === new Date().toISOString().slice(0, 10);
const claimedToday = p.last_daily_reward === new Date().toISOString().slice(0, 10);
const days = document.querySelectorAll('.streak-cal-day');
days.forEach((day, i) => {
const dayNum = i + 1;
......
Markdown is supported
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