fix i cheto sdelal
This commit is contained in:
@ -248,6 +248,36 @@ export type BonusTypesResponse = {
|
||||
bonuses: BonusType[];
|
||||
};
|
||||
|
||||
export interface DailyQuest {
|
||||
key: string;
|
||||
title: string;
|
||||
event?: string;
|
||||
target?: string;
|
||||
required: number;
|
||||
progress: number;
|
||||
reward: number;
|
||||
status: 'active' | 'completed' | 'claimed';
|
||||
claimed_at?: string;
|
||||
completed_at?: string;
|
||||
}
|
||||
|
||||
export interface DailyQuestsStatusResponse {
|
||||
ok: boolean;
|
||||
day: string;
|
||||
was_online_today: boolean;
|
||||
seconds_to_next: number;
|
||||
next_reset_at_utc: string;
|
||||
next_reset_at_local: string;
|
||||
quests: DailyQuest[];
|
||||
}
|
||||
|
||||
export interface DailyQuestClaimResponse {
|
||||
claimed: boolean;
|
||||
coins_added?: number;
|
||||
reason?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export async function fetchBonusTypes(): Promise<BonusType[]> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/bonuses/types`);
|
||||
|
||||
@ -575,6 +605,54 @@ export async function claimDaily(): Promise<DailyClaimResponse> {
|
||||
|
||||
// ===== Ежедневная награда ===== \\
|
||||
|
||||
// ===== Ежедневные квесты =====
|
||||
|
||||
export async function fetchDailyQuestsStatus(): Promise<DailyQuestsStatusResponse> {
|
||||
const { accessToken, clientToken } = getAuthTokens();
|
||||
|
||||
if (!accessToken || !clientToken) {
|
||||
throw new Error('Нет токенов авторизации');
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({ accessToken, clientToken });
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/users/daily-quests/status?${params.toString()}`,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Не удалось получить статус ежедневных квестов');
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
export async function claimDailyQuest(questKey: string): Promise<DailyQuestClaimResponse> {
|
||||
const { accessToken, clientToken } = getAuthTokens();
|
||||
|
||||
if (!accessToken || !clientToken) {
|
||||
throw new Error('Нет токенов авторизации');
|
||||
}
|
||||
|
||||
const params = new URLSearchParams({ accessToken, clientToken, quest_key: questKey });
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/users/daily-quests/claim?${params.toString()}`,
|
||||
{ method: 'POST' },
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
let msg = 'Не удалось забрать награду за квест';
|
||||
try {
|
||||
const err = await response.json();
|
||||
msg = err.message || err.detail || msg;
|
||||
} catch {}
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
// ===== Ежедневные квесты ===== \\
|
||||
|
||||
export async function fetchMe(): Promise<MeResponse> {
|
||||
const { accessToken, clientToken } = getAuthTokens();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user