diff --git a/src/components/SceneryView/SceneryTopList.vue b/src/components/SceneryView/SceneryTopList.vue index 9db4645..8a50b0d 100644 --- a/src/components/SceneryView/SceneryTopList.vue +++ b/src/components/SceneryView/SceneryTopList.vue @@ -28,22 +28,8 @@
Ups, coś poszło nie tak...
- - @@ -65,24 +62,17 @@ import { useI18n } from 'vue-i18n'; import { useApiStore } from '../../store/apiStore'; import { Station, ActiveScenery, Status } from '../../typings/common'; import Loading from '../Global/Loading.vue'; -import { useMainStore } from '../../store/mainStore'; +import { humanizeDuration } from '../../composables/time'; -interface DispatcherTopCount { +interface SceneryBestScoreItem { dispatcherName: string; dispatcherId: number; - count: number; -} - -interface LikesTopCount { - dispatcherName: string; - dispatcherId: number; - sumRate: number; + value: number; } const { t } = useI18n(); const apiStore = useApiStore(); -const mainStore = useMainStore(); defineOptions({ name: 'SceneryTopList' @@ -98,19 +88,18 @@ const props = defineProps({ } }); -const availableModes = ['likes', 'dispatchers'] as const; +const availableModes = ['dutyCount', 'dispatcherRating', 'dutyDuration'] as const; const availableScopes = ['name', 'hash'] as const; type ListMode = (typeof availableModes)[number]; type ListScope = (typeof availableScopes)[number]; -const currentListMode = ref('likes'); +const currentListMode = ref('dutyCount'); const currentListScope = ref('name'); const listState = ref(Status.Data.Loading); -const topLikesList = ref([]); -const topDispatchersList = ref([]); +const bestScoreList = ref([]); onActivated(() => { fetchTopDispatchersList(); @@ -132,10 +121,7 @@ async function fetchTopDispatchersList() { ? props.station?.name : apiStore.sceneryData.find((sc) => sc.name == props.station!.name)?.hash; - console.log(searchedStationValue); - - topDispatchersList.value = []; - topLikesList.value = []; + bestScoreList.value = []; if (!searchedStationValue) { listState.value = Status.Data.Loaded; @@ -145,16 +131,13 @@ async function fetchTopDispatchersList() { try { listState.value = Status.Data.Loading; - const response = await apiStore.client.get( - `api/getSceneryTop${currentListMode.value}By${currentListScope.value}?${currentListScope.value}=${searchedStationValue}&countLimit=40` - ); - - if (currentListMode.value == 'dispatchers') { - topDispatchersList.value = response as DispatcherTopCount[]; - } else { - topLikesList.value = response as LikesTopCount[]; - } + const response: SceneryBestScoreItem[] = await apiStore.client.get(`api/getSceneryBestScores`, { + [currentListScope.value]: searchedStationValue, + type: currentListMode.value, + currentLimit: 40 + }); + bestScoreList.value = response; listState.value = Status.Data.Loaded; } catch (error) { listState.value = Status.Data.Error; diff --git a/src/locales/en.json b/src/locales/en.json index 1ba5f83..49f20a0 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -597,14 +597,16 @@ "btn-hide-internal-routes": "Hide internal routes", "top-list": { "header": "RECORDS ON THE SCENERY (PL1)", - "mode-likes": "DISP. RATING", - "mode-dispatchers": "DUTY COUNT", + "mode-dispatcherRating": "DISP. RATING", + "mode-dutyCount": "DUTY COUNT", + "mode-dutyDuration": "DUTY DURATION", "scope-name": "GENERAL", "scope-hash": "CURRENT HASH", "place": "{n}. place", - "like-count": "Rating: {n}", - "dispatch-count": "No duties | 1 duty | Duties: {n}" + "dispatcher-rating": "Rating: {n}", + "duty-count": "No duties | 1 duty | Duties: {n}", + "duration": "Duration:" } }, "availability": { diff --git a/src/locales/pl.json b/src/locales/pl.json index bf39d52..fb8cb0f 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -583,14 +583,16 @@ "btn-hide-internal-routes": "Ukrywaj szlaki wewnętrzne", "top-list": { "header": "REKORDY NA SCENERII (PL1)", - "mode-likes": "OCENA DR", - "mode-dispatchers": "LICZBA DYŻURÓW", + "mode-dispatcherRating": "OCENA DR", + "mode-dutyCount": "DYŻURY", + "mode-dutyDuration": "CZAS DYŻURU", "scope-name": "OGÓLNIE", "scope-hash": "OBECNY HASH", "place": "{n}. miejsce", - "like-count": "Ocena: {n}", - "dispatch-count": "Brak dyżurów | 1 dyżur | Dyżury: {n}" + "dispatcher-rating": "Ocena: {n}", + "duty-count": "Brak dyżurów | 1 dyżur | Dyżury: {n}", + "duration": "Czas:" } }, "availability": {