Skip to content

Commit b442e1d

Browse files
committed
fix: ajustar erro de data expirada
1 parent f54be46 commit b442e1d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default {
22
claim: {
3-
enabled: false,
3+
enabled: true,
44
disabledMessage: 'Resgates estão desabilitados. Obrigado por participar!'
55
}
66
}

src/services/claim.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
import { DateTime } from 'luxon'
21
import { parseResponseResult } from '../common/parseResponseResult'
32
import config from '../config'
43
import { ClaimRequestResult, RequestResult, Token, UserClaim } from '../types'
54
import { getDatabaseTokenByCode, updateDatabaseToken } from './token'
65
import { getDatabaseUserById, updateDatabaseUser } from './user'
76

87
function isExpired(expireAt: string) {
9-
const now = DateTime.now().setZone('America/Sao_Paulo')
10-
const expirationDate = DateTime.fromISO(expireAt, {
11-
zone: 'America/Sao_Paulo'
12-
})
8+
const now = new Date()
9+
const expirationDate = new Date(expireAt)
1310
return expireAt && now > expirationDate
1411
}
1512

@@ -92,7 +89,9 @@ export default async function claimService(
9289
tag: string
9390
): Promise<RequestResult | ClaimRequestResult> {
9491
try {
95-
console.log(`[CLAIM-SERVICE] User ${userId} (${tag}) is trying to claim ${code}`)
92+
console.log(
93+
`[CLAIM-SERVICE] User ${userId} (${tag}) is trying to claim ${code}`
94+
)
9695

9796
if (!config.claim.enabled) {
9897
return parseResponseResult('error', config.claim.disabledMessage, 422)
@@ -175,7 +174,9 @@ export default async function claimService(
175174
)
176175
}
177176

178-
console.log(`[CLAIM-SERVICE] Claim completed for ${userId} (${tag}) and token ${code}`)
177+
console.log(
178+
`[CLAIM-SERVICE] Claim completed for ${userId} (${tag}) and token ${code}`
179+
)
179180

180181
return {
181182
status: 'success',

src/services/rank.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ function mapCompactUsers(users: User[]) {
3636
return users.map(({ userId, score, tag, tokens }) => ({
3737
userId,
3838
score,
39-
tag
40-
// claims: tokens.length
39+
tag,
40+
claims: tokens.length
4141
}))
4242
}
4343

0 commit comments

Comments
 (0)