mirror of
https://github.com/System-End/scraps.git
synced 2026-04-19 19:45:14 +00:00
update tut card and bonus
This commit is contained in:
parent
32fd592d1f
commit
4a7fcc9928
2 changed files with 26 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Elysia } from 'elysia'
|
||||
import { eq, inArray, sql } from 'drizzle-orm'
|
||||
import { eq, inArray, sql, and } from 'drizzle-orm'
|
||||
import { getUserFromSession, checkUserEligibility } from '../lib/auth'
|
||||
import { db } from '../db'
|
||||
import { usersTable, userBonusesTable } from '../schemas/users'
|
||||
|
|
@ -49,6 +49,25 @@ user.post('/complete-tutorial', async ({ headers }) => {
|
|||
return { success: true, alreadyCompleted: true }
|
||||
}
|
||||
|
||||
// Check for existing tutorial bonus to prevent duplicates
|
||||
const existingBonus = await db
|
||||
.select({ id: userBonusesTable.id })
|
||||
.from(userBonusesTable)
|
||||
.where(and(
|
||||
eq(userBonusesTable.userId, userData.id),
|
||||
eq(userBonusesTable.reason, 'tutorial_completion')
|
||||
))
|
||||
.limit(1)
|
||||
|
||||
if (existingBonus.length > 0) {
|
||||
// Mark tutorial as completed but don't award bonus again
|
||||
await db
|
||||
.update(usersTable)
|
||||
.set({ tutorialCompleted: true, updatedAt: new Date() })
|
||||
.where(eq(usersTable.id, userData.id))
|
||||
return { success: true, alreadyCompleted: true }
|
||||
}
|
||||
|
||||
await db
|
||||
.update(usersTable)
|
||||
.set({ tutorialCompleted: true, updatedAt: new Date() })
|
||||
|
|
@ -56,7 +75,7 @@ user.post('/complete-tutorial', async ({ headers }) => {
|
|||
|
||||
await db.insert(userBonusesTable).values({
|
||||
userId: userData.id,
|
||||
type: 'tutorial_bonus',
|
||||
reason: 'tutorial_completion',
|
||||
amount: 10
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -229,9 +229,12 @@
|
|||
if (highlight === 'navbar' || highlight === 'dashboard' || highlight === 'shop' || highlight === 'refinery' || highlight === 'leaderboard' || highlight === 'scraps-counter') {
|
||||
return 'bottom'
|
||||
}
|
||||
if (highlight === 'new-project-button' || highlight === 'create-project-modal' || highlight === 'submit-button') {
|
||||
if (highlight === 'create-project-modal' || highlight === 'submit-button') {
|
||||
return 'left'
|
||||
}
|
||||
if (highlight === 'new-project-button') {
|
||||
return 'right'
|
||||
}
|
||||
return 'center'
|
||||
})
|
||||
|
||||
|
|
@ -357,7 +360,7 @@
|
|||
<!-- Tutorial card -->
|
||||
<div
|
||||
data-tutorial-card
|
||||
class="bg-white rounded-2xl w-full max-w-lg border-4 border-black pointer-events-auto {currentStepData.highlight === 'create-project-modal' ? 'z-[300]' : ''} {cardOffset ? 'fixed' : 'relative mx-4'} {!cardOffset && cardPosition === 'bottom' ? 'mt-auto mb-8' : !cardOffset && cardPosition === 'bottom-center' ? 'mt-auto mb-8' : !cardOffset && cardPosition === 'top' ? 'mb-auto mt-8' : !cardOffset && cardPosition === 'left' ? 'mr-auto ml-8' : ''}"
|
||||
class="bg-white rounded-2xl w-full max-w-lg border-4 border-black pointer-events-auto {currentStepData.highlight === 'create-project-modal' ? 'z-[300]' : ''} {cardOffset ? 'fixed' : 'relative mx-4'} {!cardOffset && cardPosition === 'bottom' ? 'mt-auto mb-8' : !cardOffset && cardPosition === 'bottom-center' ? 'mt-auto mb-8' : !cardOffset && cardPosition === 'top' ? 'mb-auto mt-8' : !cardOffset && cardPosition === 'left' ? 'mr-auto ml-8' : !cardOffset && cardPosition === 'right' ? 'ml-auto mr-8' : ''}"
|
||||
style={cardOffset ? `left: ${cardOffset.x}px; top: ${cardOffset.y}px;` : ''}
|
||||
>
|
||||
<!-- Drag handle -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue