Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/kkuko/profile/components/ItemModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function ItemModal({ itemsData, profileData, onClose }: ItemModal
const itemOptionUI = (key: string, value: number) => (
<div key={key} className="bg-gray-50 dark:bg-gray-700 rounded px-3 py-2">
<span className="text-sm text-gray-600 dark:text-gray-400">{getOptionName(key)}: </span>
<span className="font-semibold text-gray-900 dark:text-gray-100">{value > 0 ? '+' : ''}{formatNumber(value * 1000)}{key[0] === 'g' ? '%p' : ''}</span>
<span className="font-semibold text-gray-900 dark:text-gray-100">{value > 0 ? '+' : ''}{formatNumber(value * (key[0] === 'g' ? 100000 : 1000))}{key[0] === 'g' ? '%p' : ''}</span>
</div>
)

Expand Down
6 changes: 3 additions & 3 deletions app/kkuko/profile/utils/profileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const extractColorFromLabel = (description: string, isDarkTheme: boolean)
};

export const formatNumber = (num: number): string => {
return (num / 10).toString();
return (num / 1000).toString();
};

export const calculateTotalOptions = (itemsData: ItemInfo[]) => {
Expand All @@ -32,13 +32,13 @@ export const calculateTotalOptions = (itemsData: ItemInfo[]) => {
const relevantOptions = Date.now() >= item.options.date ? item.options.after : item.options.before;
Object.entries(relevantOptions).forEach(([key, value]) => {
if (value !== undefined && typeof value === 'number' && !isNaN(value)) {
totals[key] = (totals[key] || 0) + Number(value) * 1000;
totals[key] = (totals[key] || 0) + Number(value) * (key[0] === 'g' ? 100000 : 1000);
}
});
} else {
Object.entries(item.options).forEach(([key, value]) => {
if (value !== undefined && typeof value === 'number' && !isNaN(value)) {
totals[key] = (totals[key] || 0) + Number(value) * 1000;
totals[key] = (totals[key] || 0) + Number(value) * (key[0] === 'g' ? 100000 : 1000);
}
});
}
Expand Down
5 changes: 3 additions & 2 deletions app/kkuko/shared/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import axiosRetry from "axios-retry";
import type { Mode, ItemInfo } from "@/types/kkuko.types";

axiosRetry(axios, {
retries: 5,
Expand All @@ -17,7 +18,7 @@ const client = axios.create({
});

export async function fetchModes() {
return await client.get('/mode')
return await client.get<{data: Mode[], status: number}>('/mode')
}

export async function fetchTotalUsers() {
Expand All @@ -31,7 +32,7 @@ export async function fetchProfile(query: string, type: 'nick' | 'id') {
}

export async function fetchItems(itemsIds: string) {
return await client.get(`/item?query=${encodeURIComponent(itemsIds)}`);
return await client.get<{data: ItemInfo[], status: number}>(`/item?query=${encodeURIComponent(itemsIds)}`);
}

export async function fetchExpRank(userId: string) {
Expand Down
Loading