Skip to content

Commit

Permalink
fix: #940
Browse files Browse the repository at this point in the history
  • Loading branch information
migbash committed Feb 9, 2023
1 parent 764e80c commit 4b2e6d1
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 107 deletions.
189 changes: 91 additions & 98 deletions src/lib/components/fixtures_page/votes/Vote_Widget.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import VoteLoader from "./Vote_Loader.svelte";
import { FIXTURE_NO_VOTES_OPT } from '$lib/models/sportmonks';
import no_visual from './assets/no_visual.svg';
import no_visual_dark from './assets/no_visual_dark.svg';
Expand Down Expand Up @@ -144,7 +145,7 @@
// [ℹ] data validation check [#2]
const validation_check =
response.widget_featured_match_votes.length == 0
&& ["FT", "FT_PEN"].includes(HIST_FIXTURE_DATA?.status_j)
&& FIXTURE_NO_VOTES_OPT.includes(HIST_FIXTURE_DATA?.status_j)
;
no_widget_data =
Expand Down Expand Up @@ -676,10 +677,11 @@
-->

<!--
[ℹ] voting hint text -->
{#if
[ℹ] voting hint text
-->
{#if
!vote_casted
&& !["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
&& !FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
<p
class="
w-500
Expand All @@ -693,11 +695,11 @@
{/if}

<!--
[ℹ] voting results btn -->
[ℹ] voting results btn
-->
<div
id="btn-vote-container"
class="row-space-out">

class="row-space-out">
<!--
[ℹ] ODDS #1
-->
Expand All @@ -707,15 +709,14 @@
text-center
column
">

<button
class="
row-space-out
cast-vote-btn
m-b-12
"
class:active={fixture_data_vote_obj.fixture_vote == '1'}
disabled={vote_casted || ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
disabled={vote_casted || FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
on:click={() => cast_vote('1', FIXTURE_VOTES_DATA._1x2.home)}>
<p
class="
Expand Down Expand Up @@ -746,12 +747,11 @@
</span>
</p>
</button>

<!--
[ℹ] fixture-probability
-->
{#if !show_bet_site
&& !["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
&& !FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
<p
class="
w-400
Expand All @@ -771,7 +771,7 @@
{:else if
FIXTURE_VOTES_DATA?.match_votes != undefined
|| (FIXTURE_VOTES_DATA?.match_votes != undefined
&& ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status))}
&& FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status))}
<p
class="
large
Expand All @@ -793,7 +793,6 @@
</p>
{/if}
</div>

<!--
[ℹ] ODDS #X
-->
Expand All @@ -803,15 +802,14 @@
text-center
column
">

<button
class="
row-space-out
cast-vote-btn
m-b-12
"
class:active={fixture_data_vote_obj.fixture_vote == 'X'}
disabled={vote_casted || ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
disabled={vote_casted || FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
on:click={() => cast_vote('X', FIXTURE_VOTES_DATA._1x2.draw)}>
<p
class="
Expand Down Expand Up @@ -845,12 +843,11 @@
</span>
</p>
</button>

<!--
[ℹ] fixture-probability
-->
{#if !show_bet_site
&& !["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
&& !FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
<p
class="
w-400
Expand All @@ -867,10 +864,10 @@
-
{/if}
</p>
{:else if
{:else if
FIXTURE_VOTES_DATA?.match_votes != undefined
|| (FIXTURE_VOTES_DATA?.match_votes != undefined
&& ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status))}
&& FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status))}
<p
class="
large
Expand All @@ -892,7 +889,6 @@
</p>
{/if}
</div>

<!--
[ℹ] ODDS #2
-->
Expand All @@ -902,93 +898,90 @@
column
text-center
">

<button
<button
class="
row-space-out
cast-vote-btn
m-b-12
"
class:active={fixture_data_vote_obj.fixture_vote == '2'}
disabled={vote_casted || FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
on:click={() => cast_vote('2', FIXTURE_VOTES_DATA._1x2.away)}>
<p
class="
row-space-out
cast-vote-btn
m-b-12
"
class:active={fixture_data_vote_obj.fixture_vote == '2'}
disabled={vote_casted || ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
on:click={() => cast_vote('2', FIXTURE_VOTES_DATA._1x2.away)}>
<p
class="
w-500
medium
row-space-out
">
{#if mobileExclusive}
<span
class="color-grey">
2
</span>
{:else}
<img
src={FIXTURE_VOTES_DATA?.away_team_logo}
alt=""
width="28px"
height="28px"
/>
{/if}
w-500
medium
row-space-out
">
{#if mobileExclusive}
<span
class:active_p={fixture_data_vote_obj.fixture_vote == '2'}>
{#if FIXTURE_VOTES_DATA._1x2.away}
{FIXTURE_VOTES_DATA._1x2.away.toString()}
{:else}
-
{/if}
class="color-grey">
2
</span>
</p>
</button>

<!--
[ℹ] fixture-probability
-->
{#if !show_bet_site
&& !["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status)}
<p
class="
w-400
probablitiy-text
medium
">
{FIXTURE_VOTES_TRANSLATION?.probability}
{#if mobileExclusive}
<br />
{/if}
{#if FIXTURE_VOTES_DATA?.probabilities?.away != undefined}
{Math.round(parseFloat(FIXTURE_VOTES_DATA?.probabilities?.away.toString())).toFixed(2)}%
{:else}
<img
src={FIXTURE_VOTES_DATA?.away_team_logo}
alt=""
width="28px"
height="28px"
/>
{/if}
<span
class:active_p={fixture_data_vote_obj.fixture_vote == '2'}>
{#if FIXTURE_VOTES_DATA._1x2.away}
{FIXTURE_VOTES_DATA._1x2.away.toString()}
{:else}
-
{/if}
</p>
{:else if
FIXTURE_VOTES_DATA?.match_votes != undefined
|| (FIXTURE_VOTES_DATA?.match_votes != undefined
&& ["FT", "FT_PEN"].includes(FIXTURE_VOTES_DATA?.status))}
<p
</span>
</p>
</button>
<!--
[ℹ] fixture-probability
-->
{#if !show_bet_site
&& !FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status)}
<p
class="
w-400
probablitiy-text
medium
">
{FIXTURE_VOTES_TRANSLATION?.probability}
{#if mobileExclusive}
<br />
{/if}
{#if FIXTURE_VOTES_DATA?.probabilities?.away != undefined}
{Math.round(parseFloat(FIXTURE_VOTES_DATA?.probabilities?.away.toString())).toFixed(2)}%
{:else}
-
{/if}
</p>
{:else if
FIXTURE_VOTES_DATA?.match_votes != undefined
|| (FIXTURE_VOTES_DATA?.match_votes != undefined
&& FIXTURE_NO_VOTES_OPT.includes(FIXTURE_VOTES_DATA?.status))}
<p
class="
large
">
<span
class="
large
color-dark
w-500
">
<span
class="
color-dark
w-500
">
{((FIXTURE_VOTES_DATA.match_votes.vote_win_visitor / total_votes) * 100).toFixed(0)}%
</span>
<span
class="
color-grey
w-400
">
({FIXTURE_VOTES_DATA.match_votes.vote_win_visitor})
</span>
</p>
{/if}
{((FIXTURE_VOTES_DATA.match_votes.vote_win_visitor / total_votes) * 100).toFixed(0)}%
</span>
<span
class="
color-grey
w-400
">
({FIXTURE_VOTES_DATA.match_votes.vote_win_visitor})
</span>
</p>
{/if}
</div>

</div>

<!--
Expand Down
9 changes: 5 additions & 4 deletions src/lib/models/fixtures/votes/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type {
import type {
BETARENA_HASURA_historic_fixtures,
BETARENA_HASURA_scores_fixture_voting_translations,
BETARENA_HASURA_scores_general_translations,
BETARENA_HASURA_scores_fixture_voting_translations,
BETARENA_HASURA_scores_general_translations,
BETARENA_HASURA_widget_featured_match_votes,
FixtureVotesTranslations,
WidgetsNoDataAvailable
} from "$lib/models/hasura";
import type { FIXTURE_STATUS_TYPES } from "$lib/models/sportmonks";

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface REDIS_CACHE_SINGLE_votes_translation extends FixtureVotesTranslations, WidgetsNoDataAvailable {
Expand Down Expand Up @@ -42,7 +43,7 @@ export interface BETARENA_HASURA_votes_mutation {

export interface Fixture_Votes {
time?: string
status?: string
status?: FIXTURE_STATUS_TYPES
home_team_logo?: string
away_team_logo?: string
match_votes?: BETARENA_HASURA_widget_featured_match_votes
Expand Down
25 changes: 20 additions & 5 deletions src/lib/models/sportmonks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
export const FIXTURE_NOT_START_OPT: FIXTURE_STATUS_TYPES[] = [
"CANCL",
"POSTP",
"INT",
"NS",
"TBA",
"SUSP",
"INT",
"POSTP",
"CANCL"
"SUSP"
]
export const FIXTURE_NO_VOTES_OPT: FIXTURE_STATUS_TYPES[] = [
'FT',
'AET',
'FT_PEN',
'CANCL',
'POSTP',
'INT',
'ABAN',
'SUSP',
'AWARDED',
'WO'
]
export const FIXTURE_LIVE_TIME_OPT: FIXTURE_STATUS_TYPES[] = [
"LIVE",
Expand All @@ -19,7 +31,7 @@ export const FIXTURE_FULL_TIME_OPT: FIXTURE_STATUS_TYPES[] = [
"FT_PEN"
]

// [ℹ] https://docs.sportmonks.com/football/api-references/statussus-and-definitions
// DOC: https://docs.sportmonks.com/football/api-references/statussus-and-definitions
export type FIXTURE_STATUS_TYPES =
// [ℹ] GAME NOT STARTED
"NS" // The initial status of a game
Expand All @@ -28,6 +40,9 @@ export type FIXTURE_STATUS_TYPES =
| "INT" // The game has been interrupted. Can be due to bad weather
| "POSTP" // The game has been postponed
| "CANCL" // The game has been canceled
| "ABAN" // The game has been abandoned
| "AWARDED" // The game has been awarded
| "WO" // The game has been walk-over
// [ℹ] GAME IS LIVE
| "LIVE" // The game is currently inplay
| "HT" // The game currently is in half-time
Expand Down

0 comments on commit 4b2e6d1

Please sign in to comment.