Skip to content

Commit

Permalink
feat/chore: update imports struct; fixes #1055;
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Feb 28, 2023
1 parent 8abcc5e commit 47de950
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 69 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
<!--
====================
This is an example .svelte
component file, to give guidance on
the structure that is employed across the project
and how it should be layed-out.
====================
<COPY-THIS-FILE-INTO-YOUR-NEXT-COMPONENT>
====================
-->

<!-- ===============
COMPONENT JS (w/ TS)
=================-->

<script lang="ts">
import { sessionStore } from "$lib/store/session";
import { userBetarenaSettings } from "$lib/store/user-settings";
//#region ➤ [MAIN] Package Imports
//#region ➤ [MAIN] Package Imports
// IMPORTS GO HERE
import { FIXTURE_FULL_TIME_OPT, FIXTURE_LIVE_TIME_OPT } from "$lib/models/sportmonks";
//#region ➤ Svelte/SvelteKit Imports
// IMPORTS GO HERE
import { onMount } from "svelte";
//#endregion ➤ Svelte/SvelteKit Imports
//#region ➤ Project Custom Imports
// IMPORTS GO HERE
// (imports here)
import { sessionStore } from "$lib/store/session";
//
import { userBetarenaSettings } from "$lib/store/user-settings";
//#endregion ➤ Project Custom Imports
//#region ➤ Firebase Imports
Expand All @@ -34,8 +27,7 @@ COMPONENT JS (w/ TS)
//#region ➤ Types Imports
// IMPORTS GO HERE
import type { LS2_C_Fixture } from "betarena-types/types/livescores-v2";
import { onMount } from "svelte";
//#endregion ➤ Types Imports
//#endregion ➤ Types Imports
//#region ➤ Assets Imports
import one_red_card from './assets/1_red_card.svg';
Expand Down Expand Up @@ -374,7 +366,8 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style
<!--
[ℹ] fixture scores BOX SHOW/HIDE
-->
{#if (FIXTURE_D?.teams?.away?.score && FIXTURE_D?.teams?.home?.score) || ['FT', 'FT_PEN', 'AET', 'LIVE', 'HT'].includes(FIXTURE_D?.status)}
{#if (FIXTURE_D?.teams?.away?.score && FIXTURE_D?.teams?.home?.score)
|| [...FIXTURE_FULL_TIME_OPT, ...FIXTURE_LIVE_TIME_OPT].includes(FIXTURE_D?.status)}
<div
class="
column-space-center
Expand Down
130 changes: 81 additions & 49 deletions src/lib/components/page/home/livescores-v2/Livescores_Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,44 @@ COMPONENT JS (w/ TS)
=================-->

<script lang="ts">
import type { B_LS2_D, LS2_C_Fixture, LS2_C_League } from 'betarena-types/types/livescores-v2';
import LivescoresFixtureRow from './Livescores_Fixture_Row.svelte';
//#region ➤ [MAIN] Package Imports
//#region ➤ [MAIN] Package Imports
// IMPORTS GO HERE
//#region ➤ Svelte/SvelteKit Imports
// IMPORTS GO HERE
import { page } from '$app/stores';
//#endregion ➤ Svelte/SvelteKit Imports
//#region ➤ Project Custom Imports
// IMPORTS GO HERE
import { get } from '$lib/api/utils';
import WidgetTitle from '$lib/components/Widget-Title.svelte';
// IMPORTS GO HERE
import { sessionStore } from '$lib/store/session';
// IMPORTS GO HERE
import { dlog, LV2_W_T_STY, LV2_W_T_TAG, LV2_W_T_TOG } from '$lib/utils/debug';
// IMPORTS GO HERE
import { platfrom_lang_ssr } from '$lib/utils/platform-functions';
//#endregion ➤ Project Custom Imports
//#region ➤ Firebase Imports
// IMPORTS GO HERE
//#endregion ➤ Firebase Imports
//#region ➤ Types Imports
// IMPORTS GO HERE
import type { B_LS2_D, B_LS2_T, LS2_C_Fixture, LS2_C_League } from 'betarena-types/types/livescores-v2';
//#endregion ➤ Types Imports
import LivescoresTopRow from './Livescores_Top_Row.svelte';
import LoaderRow from './loaders/Loader_Row.svelte';
//#region ➤ Assets Imports
// IMPORTS GO HERE
//#endregion ➤ Assets Imports
import WidgetTitle from '$lib/components/Widget-Title.svelte';
import LivescoresFixtureRow from './Livescores_Fixture_Row.svelte';
import LivescoresTopRow from './Livescores_Top_Row.svelte';
import LoaderRow from './loaders/Loader_Row.svelte';
//#endregion ➤ [MAIN] Package Imports
//#region ➤ [VARIABLES]
Expand All @@ -28,6 +50,7 @@ COMPONENT JS (w/ TS)
// ~~~~~~~~~~~~~~~~~~~~~
export let WIDGET_DATA: B_LS2_D
export let WIDGET_T_DATA: B_LS2_T
const WIDGET_TITLE = 'Livescores'
const today = new Date()
Expand Down Expand Up @@ -198,9 +221,11 @@ COMPONENT JS (w/ TS)
dlog(`${LV2_W_T_TAG} updateLiveInfo (trigger)`, LV2_W_T_TOG, LV2_W_T_STY)
numOfFixturesLive = 0
liveLeaguesIds = []
for await (const [date, fixturesArr] of fixturesGroupByDateMap) {
for await (const fixture of fixturesArr) {
for (let [date, fixturesArr] of fixturesGroupByDateMap) {
console.log(fixturesArr.length)
for (let fixture of fixturesArr) {
if (fixture?.status == 'LIVE') {
dlog(`${LV2_W_T_TAG} updateLiveInfo | fixture?.id ${fixture?.id} - ${numOfFixturesLive}`, LV2_W_T_TOG, LV2_W_T_STY)
numOfFixturesLive++
liveLeaguesIds.push(fixture?.league_id)
}
Expand Down Expand Up @@ -255,13 +280,13 @@ COMPONENT JS (w/ TS)
* Proceeds to update data accordingly
*/
$: if ($sessionStore?.livescore_now) {
console.log('CHANGED!')
console.log($sessionStore?.livescore_now)
// console.log('CHANGED!')
// console.log($sessionStore?.livescore_now)
injectLivescoreData()
updateLiveInfo()
}
// [🐞]
// [🐞] [DEV-ONLY]
$: {
// dlog(`${LV2_W_T_TAG} nonEmptyLeaguesIds: ${nonEmptyLeaguesIds}`, LV2_W_T_TOG, LV2_W_T_STY)
// dlog(`${LV2_W_T_TAG} numOfFixtures: ${nonEmptyLeaguesIds}`, LV2_W_T_TOG, LV2_W_T_STY)
Expand Down Expand Up @@ -328,26 +353,29 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style
<!--
[ℹ] league info (box)
-->
<div
class="
row-space-start
league-group
">
<img
src="https://betarena.com/images/flags/{league?.iso2}.svg"
alt=""
class="m-r-24"
width="24"
height="18"
/>
<p
<a
href="{league?.urls[server_side_language]}">
<div
class="
s-16
w-500
row-space-start
league-group
">
{league?.league_name}
</p>
</div>
<img
src="https://betarena.com/images/flags/{league?.iso2}.svg"
alt=""
class="m-r-24"
width="24"
height="18"
/>
<p
class="
s-16
w-500
">
{league?.league_name}
</p>
</div>
</a>
<!--
[ℹ] fixtures (of league) (box)
-->
Expand All @@ -372,29 +400,33 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style
<!--
[ℹ] league info (box)
-->
<div
class="
row-space-start
league-group
"
class:display-none={$sessionStore.livescoreFixtureView == 'live' && !liveLeaguesIds.includes(league?.id)}>
<img
src="https://betarena.com/images/flags/{league?.iso2}.svg"
alt=""
class="m-r-24"
width="24"
height="18"
/>
<p
<a
href="{league?.urls[server_side_language]}">
<div
class="
s-16
w-500
">
{league?.league_name}
</p>
</div>
row-space-start
league-group
"
class:display-none={$sessionStore.livescoreFixtureView == 'live' && !liveLeaguesIds.includes(league?.id)}>
<img
src="https://betarena.com/images/flags/{league?.iso2}.svg"
alt=""
class="m-r-24"
width="24"
height="18"
/>
<p
class="
s-16
w-500
">
{league?.league_name}
</p>
</div>
</a>
<!--
[ℹ] fixtures (of league) (box)
FIXME: using "today" does not work, as fixtures at 23:45 (start) won't show in 15 (next day)
-->
{#each fixturesGroupByDateMap.get(today.toISOString().slice(0, 10)) as fixture}
{#if fixture?.league_id == league?.id && fixture?.status === 'LIVE'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COMPONENT JS (w/ TS)
//#region ➤ Svelte/SvelteKit Imports
// IMPORTS GO HERE
import { page } from '$app/stores';
//#endregion ➤ Svelte/SvelteKit Imports
//#region ➤ Project Custom Imports
Expand All @@ -21,15 +22,15 @@ COMPONENT JS (w/ TS)
//#endregion ➤ Firebase Imports
//#region ➤ Types Imports
import type { B_LS2_D } from 'betarena-types/types/livescores-v2';
import type { B_LS2_D, B_LS2_T } from 'betarena-types/types/livescores-v2';
//#endregion ➤ Types Imports
import SeoBox from '$lib/components/SEO-Box.svelte';
import LivescoresLoader from './Livescores_Loader.svelte';
import LivescoresMain from './Livescores_Main.svelte';
//#region ➤ Assets Imports
//#endregion ➤ Assets Imports
//#endregion ➤ Assets Imports
//#endregion ➤ [MAIN] Package Imports
Expand All @@ -39,6 +40,7 @@ COMPONENT JS (w/ TS)
// COMPONENT VARIABLES
// ~~~~~~~~~~~~~~~~~~~~~
let WIDGET_T_DATA: B_LS2_T = $page.data?.LIVESCORES_V2_T_DATA
let WIDGET_DATA: B_LS2_D
let NO_WIDGET_DATA: boolean = true // [ℹ] default (true)
Expand Down Expand Up @@ -117,6 +119,7 @@ NOTE: [HINT] use (CTRL+SPACE) to select a (class) (id) style from the global (ap
-->
<LivescoresMain
{WIDGET_DATA}
{WIDGET_T_DATA}
/>
{:catch error}
<!--
Expand Down
3 changes: 3 additions & 0 deletions src/routes/[[lang=lang]]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function load({
`/api/cache/home/league_list?lang=${urlLang}`,
`/api/cache/home/leagues_table?lang=${urlLang}`,
`/api/cache/home/seo_block?lang=${urlLang}`,
`/api/cache/home/livescores-v2?lang=${urlLang}`,
// [ℹ] page validation check;
`/api/cache/_main_/pages_and_seo?url=${url.pathname}`,
// [ℹ] livescores
Expand All @@ -63,6 +64,7 @@ export async function load({
LEAGUE_LIST_WIDGET_DATA_SEO,
LEAGUES_TABLE_SCORES_SEO_DATA,
SEO_BLOCK_DATA,
LIVESCORES_V2_T_DATA,
VALID_URL,
LIVE_SCORES_DATA_DATA_SEO,
LIVE_SCORES_DATA_LEAGUES,
Expand Down Expand Up @@ -118,6 +120,7 @@ export async function load({
LEAGUE_LIST_WIDGET_DATA_SEO,
LEAGUES_TABLE_SCORES_SEO_DATA,
SEO_BLOCK_DATA,
LIVESCORES_V2_T_DATA,
LIVE_SCORES_DATA_DATA_SEO,
LIVE_SCORES_DATA_LEAGUES,
LIVE_SCORES_FOOTBALL_TRANSLATIONS,
Expand Down

0 comments on commit 47de950

Please sign in to comment.