From c76202a5cf5f1c502aa77e47823c0979f5a8bf58 Mon Sep 17 00:00:00 2001 From: MigBash <20924663+migbash@users.noreply.github.com> Date: Wed, 1 Feb 2023 12:10:36 +0000 Subject: [PATCH] Enhance/translations and wallet issues and other (#1030) * issue #1006 #1021 * `update` .github/deploy script * issue #1019 * `renaming` * `aesthetic` `doc` * `update` for `docker:dev` + `package.json` scripts * `update` with `main` * `update` settings.json * issue #951 * issue #951 * issue #951 * issue #951 `redundant` code * issue #951 * issue #1028 * issue #951 `styles` update * `deepsource` JS-0128 --- .github/workflows/deploy.yml | 4 +- .github/workflows/docker-image.yml | 2 +- .vscode/settings.json | 9 +- Dockerfile | 2 +- Dockerfile.dev | 2 +- Makefile | 2 +- Procfile | 1 + WEBSITE-DEV-README.md => README-DEV.md | 0 package.json | 21 +- my-server.js => server-docker.js | 34 +- server-heroku.js | 93 ++ .../components/_main_/auth/Auth_Widget.svelte | 951 +++++++++-------- .../standings/Standings-Loader.svelte | 230 ++++ .../standings/Standings-Team-Row.svelte | 378 +++++++ .../standings/Standings-Widget.svelte | 994 ++++++++++++++++++ .../standings/assets/arrow-down.svg | 3 + .../standings/assets/arrow-up.svg | 3 + .../assets/no_featured_match_visual.svg | 5 + .../assets/no_featured_match_visual_dark.svg | 5 + .../standings/assets/no_visual.svg | 11 + .../standings/assets/no_visual_dark.svg | 11 + .../standings/assets/slider-left-dark.svg | 3 + .../standings/assets/slider-left.svg | 3 + .../standings/assets/slider-right-dark.svg | 3 + .../standings/assets/slider-right.svg | 3 + .../standings/assets/team-white.svg | 8 + .../fixtures_page/standings/assets/team.svg | 8 + .../loaders/desktop/Loader-Bottom.svelte | 17 + .../loaders/desktop/Loader-Head.svelte | 17 + .../loaders/desktop/Loader-Row-Left.svelte | 17 + .../loaders/desktop/Loader-Row-Right.svelte | 24 + .../loaders/desktop/Loader-ViewSel.svelte | 16 + .../loaders/mobile/Loader-Bottom.svelte | 17 + .../loaders/mobile/Loader-Head.svelte | 17 + .../loaders/mobile/Loader-Row-Left-M.svelte | 15 + .../loaders/mobile/Loader-Row-Right-M.svelte | 20 + .../loaders/mobile/Loader-Table-View.svelte | 17 + .../mobile/Loader-ViewSel-Right.svelte | 14 + .../loaders/mobile/Loader-ViewSel.svelte | 24 + src/lib/graphql/_main_/auth/query.ts | 33 + src/lib/models/_main_/auth/types.ts | 27 + src/lib/models/fixtures/scoreboard/types.ts | 1 + src/lib/models/hasura.ts | 29 + .../[sport]/[fixture=fixture]/+page.svelte | 103 +- .../[sport]/[fixture=fixture]/+page.ts | 37 +- .../[sport]/[fixture=fixture]/+page.svelte | 103 +- src/routes/[sport]/[fixture=fixture]/+page.ts | 37 +- src/routes/api/hasura/_main_/auth/+server.ts | 86 ++ .../api/hasura/fixtures/scoreboard/+server.ts | 1 + tsconfig.json | 2 +- 50 files changed, 2881 insertions(+), 582 deletions(-) create mode 100644 Procfile rename WEBSITE-DEV-README.md => README-DEV.md (100%) rename my-server.js => server-docker.js (68%) create mode 100644 server-heroku.js create mode 100644 src/lib/components/fixtures_page/standings/Standings-Loader.svelte create mode 100644 src/lib/components/fixtures_page/standings/Standings-Team-Row.svelte create mode 100644 src/lib/components/fixtures_page/standings/Standings-Widget.svelte create mode 100644 src/lib/components/fixtures_page/standings/assets/arrow-down.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/arrow-up.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/no_featured_match_visual.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/no_featured_match_visual_dark.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/no_visual.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/no_visual_dark.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/slider-left-dark.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/slider-left.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/slider-right-dark.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/slider-right.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/team-white.svg create mode 100644 src/lib/components/fixtures_page/standings/assets/team.svg create mode 100644 src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Bottom.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Head.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Left.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Right.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/desktop/Loader-ViewSel.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Bottom.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Head.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Left-M.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Right-M.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Table-View.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel-Right.svelte create mode 100644 src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel.svelte create mode 100644 src/lib/graphql/_main_/auth/query.ts create mode 100644 src/lib/models/_main_/auth/types.ts create mode 100644 src/routes/api/hasura/_main_/auth/+server.ts diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 924234705..3eb7c931d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,6 @@ jobs: # [ℹ] Navigate to target project directory cd web/scores # [ℹ] Update the directory with latests changes - git pull origin enhance/feature-docker-deploy + git pull origin main # [ℹ] Run target makefile command - make update-scores-web + make update-scores-web \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7b3b723bb..717f8cb15 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -38,4 +38,4 @@ jobs: - name: Build the Docker image run: | docker build . --file Dockerfile --tag my-image-name:$(date +%s) - # run: docker build --no-cache --progress=plain --tag scores-platform:$(date +%s) . + # run: docker build --no-cache --progress=plain --tag scores-platform:$(date +%s) . \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 14ac0e1d9..0f58ae0e4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,12 @@ { - // https://stackoverflow.com/questions/64365300/how-can-i-remove-unused-imports-declarations-from-the-entire-project-of-react-ty - // https://stackoverflow.com/questions/46722701/is-there-a-way-to-remove-unused-imports-and-declarations-from-angular-2 + // DOC: https://stackoverflow.com/questions/64365300/how-can-i-remove-unused-imports-declarations-from-the-entire-project-of-react-ty + // DOC: https://stackoverflow.com/questions/46722701/is-there-a-way-to-remove-unused-imports-and-declarations-from-angular-2 "editor.codeActionsOnSave": { "source.fixAll": true, - "source.organizeImports": true, - "source.sortMembers": true + "source.organizeImports": true, + "source.sortMembers": true }, + // NOTE: custom highlighter for data "todohighlight.keywords": [ { "text": "NOTE:", diff --git a/Dockerfile b/Dockerfile index f951f0eeb..d7cec60f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,4 +31,4 @@ COPY . . EXPOSE 5055 # CMD ["node", "./build"] -CMD ["npm", "start"] \ No newline at end of file +CMD ["npm", "run", "start:docker"] \ No newline at end of file diff --git a/Dockerfile.dev b/Dockerfile.dev index bcf5b397d..9bb063794 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -26,4 +26,4 @@ EXPOSE 5055 EXPOSE 24678 # CMD ["node", "./build"] -CMD ["npm", "run", "dev-docker"] \ No newline at end of file +CMD ["npm", "run", "dev:docker"] \ No newline at end of file diff --git a/Makefile b/Makefile index 3cc79c4b6..8f3961bc6 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ log-listen: update-scores-web: echo 'Updating PROD Scores Web container...' - git pull origin enhance/feature-docker-deploy + git pull origin main -docker rm $$(docker stop $$(docker ps -a -q --filter="name=scores_scores_web_1" --format="{{.ID}}")) -docker rmi $$(docker images -q scores_web) -docker rmi $$(docker images --filter "dangling=true" -q --no-trunc) diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..d0b35ca42 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm run start:heroku \ No newline at end of file diff --git a/WEBSITE-DEV-README.md b/README-DEV.md similarity index 100% rename from WEBSITE-DEV-README.md rename to README-DEV.md diff --git a/package.json b/package.json index 7fbcb38f7..2d4258c5a 100644 --- a/package.json +++ b/package.json @@ -7,20 +7,21 @@ "node": "16.17.0" }, "scripts": { + "check": "svelte-check --tsconfig ./tsconfig.json", + "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", + "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", + "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. .", "debug": "cross-env NODE_OPTIONS='--inspect' vite dev --host --port 3050", - "debug-preview": "cross-env NODE_OPTIONS='--inspect' vite preview --host --port 5000", - "debug-bull": "cross-env NODE_DEBUG='bull' vite preview --host --port 5000", + "debug:bull": "cross-env NODE_DEBUG='bull' vite preview --host --port 5000", + "debug:preview": "cross-env NODE_OPTIONS='--inspect' vite preview --host --port 5000", "dev": "vite dev --host --port 3050", - "dev-docker": "vite dev --host --port 5055", - "docker-dev-up": "docker-compose -f docker-compose.dev.yml up", - "build": "vite build", + "dev:docker": "vite dev --host --port 5055", + "dev:docker:up": "docker-compose -f docker-compose.dev.yml up", "staging": "npm run dev -- --mode staging", - "start": "node my-server.js", + "build": "vite build", "preview": "vite preview --host --port 5000", - "check": "svelte-check --tsconfig ./tsconfig.json", - "check:watch": "svelte-check --tsconfig ./tsconfig.json --watch", - "lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", - "format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ." + "start:docker": "node server-docker.js", + "start:heroku": "node server-heroku.js" }, "devDependencies": { "@sveltejs/adapter-node": "1.0.0-next.88", diff --git a/my-server.js b/server-docker.js similarity index 68% rename from my-server.js rename to server-docker.js index 63ae796c9..1fdd9501f 100644 --- a/my-server.js +++ b/server-docker.js @@ -1,14 +1,14 @@ -// [ℹ] https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server -// [ℹ] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import +// DOC: https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server +// DOC: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import import express from 'express'; import http from 'http'; import https from 'https'; import { handler } from './build/handler.js'; -// import sslRedirect from 'heroku-ssl-redirect'; -import compression from 'compression'; // https://expressjs.com/en/resources/middleware/compression.html +// DOC: https://expressjs.com/en/resources/middleware/compression.html +import compression from 'compression'; import * as sslify from 'express-sslify'; -import * as requestIp from 'request-ip'; // https://www.npmjs.com/package/request-ip +// DOC: https://www.npmjs.com/package/request-ip import fs from 'fs'; @@ -20,24 +20,11 @@ const options = { const app = express(); -/** - * [ℹ] add a route that lives separately from the SvelteKit app -*/ -// app.get('/healthcheck', (req, res) => { -// res.end('ok'); -// }); - -/** - * [ℹ] enable ssl redirect - * [ℹ] https://www.npmjs.com/package/heroku-ssl-redirect - * => does not seem to be working -*/ -// app.use(sslRedirect()); - /** * [ℹ] separate from SvelteKit endpoint in attempts to * [ℹ] identify clients (IP - address) */ +/** app.get('/getClientIP', (req, res) => { const ip = req.headers['x-forwarded-for'] || @@ -69,6 +56,7 @@ app.get('/getClientIP', (req, res) => { res.end() }) +*/ /** * [ℹ] [FORCE] https-redirect @@ -97,14 +85,6 @@ app.use(compression()) */ app.use(handler); -/** - * [ℹ] initialize app; - * [ℹ] https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-o -*/ -// app.listen(process.env.PORT, () => { -// console.log(`listening on port ${process.env.PORT}`); -// }); - // ~~~~~~~~~~~~~~~~~~~~~~ // APP SPIN-UP [PROD] [V2] // ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/server-heroku.js b/server-heroku.js new file mode 100644 index 000000000..5d6b33038 --- /dev/null +++ b/server-heroku.js @@ -0,0 +1,93 @@ +// DOC: https://github.com/sveltejs/kit/tree/master/packages/adapter-node#custom-server +// DOC: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import + +import express from 'express'; +import { handler } from './build/handler.js'; +// import sslRedirect from 'heroku-ssl-redirect'; +// DOC: https://expressjs.com/en/resources/middleware/compression.html +import compression from 'compression'; +import * as sslify from 'express-sslify'; +// DOC: https://www.npmjs.com/package/request-ip + +const app = express(); + +/** + * [ℹ] enable ssl redirect + * DOC: https://www.npmjs.com/package/heroku-ssl-redirect + * => does not seem to be working +*/ +// app.use(sslRedirect()); + +/** + * [ℹ] separate from SvelteKit endpoint in attempts to + * [ℹ] identify clients (IP - address) +*/ +/** +app.get('/getClientIP', (req, res, next) => { + + const ip = req.headers['x-forwarded-for'] || + req.socket.remoteAddress || + null; + console.log('ip', ip); + + const ip2 = req.ip + console.log('ip2', ip2); + + const ip3 = requestIp.getClientIp(req); + console.log('ip3', ip3); + + let ipAddr = req.headers["x-forwarded-for"]; + if (ipAddr){ + const list = ipAddr.split(","); + ipAddr = list[list.length-1]; + } else { + ipAddr = req.connection.remoteAddress; + } + + console.log('ipAddr', ipAddr); + + res.json( + { + "ip": ip.toString().replace(/,/g, '') + } + ); + + res.end() +}) +*/ + +/** + * [ℹ] [FORCE] https-redirect + * DOC: https://jaketrent.com/post/https-redirect-node-heroku + * DOC: https://webdva.github.io/how-to-force-express-https-tutorial + * [HEROKU] +*/ +app.use((req, res, next) => { + if (req.header('x-forwarded-proto') !== 'https') + res.redirect(`https://${req.header('host')}${req.url}`); + else + next(); +}); + +/** + * DOC: https://www.npmjs.com/package/express-sslify + * DOC: https://stackoverflow.com/questions/51234023/heroku-nodejs-redirect-http-to-http +*/ +app.use(sslify.HTTPS({ trustProtoHeader: true })) + +// [ℹ] compress all responses +app.use(compression()) + +/** + * [ℹ] let SvelteKit handle everything else, + * [ℹ] including serving prerendered pages and static assets +*/ +app.use(handler); + +/** + * [ℹ] initialize app; + * DOC: https://stackoverflow.com/questions/15693192/heroku-node-js-error-web-process-failed-to-bind-to-port-within-60-seconds-o +*/ +app.listen(process.env.PORT || 5000, () => { + console.log('listening on port 5000'); +}); \ No newline at end of file diff --git a/src/lib/components/_main_/auth/Auth_Widget.svelte b/src/lib/components/_main_/auth/Auth_Widget.svelte index 5551bcc92..ba439b902 100644 --- a/src/lib/components/_main_/auth/Auth_Widget.svelte +++ b/src/lib/components/_main_/auth/Auth_Widget.svelte @@ -16,6 +16,8 @@ COMPONENT JS (w/ TS) import { signInWithMoralis } from '@moralisweb3/client-firebase-evm-auth'; import { fetchSignInMethodsForEmail, GithubAuthProvider, GoogleAuthProvider, isSignInWithEmailLink, sendSignInLinkToEmail, signInWithCustomToken, signInWithEmailLink, signInWithPopup, type User } from "firebase/auth"; + import { get } from '$lib/api/utils'; + import type { REDIS_CACHE_SINGLE_auth_translation } from '$lib/models/_main_/auth/types'; import discord_icon from './assets/discord.svg'; import email_verify from './assets/email-verify.svg'; import error_icon from './assets/error-alert.svg'; @@ -76,11 +78,30 @@ COMPONENT JS (w/ TS) // COMPONENT METHODS // ~~~~~~~~~~~~~~~~~~~~~ - /* - function close_widget() { - dispatch('close_widget'); - } - */ + // [ℹ] MAIN WIDGET METHOD + async function widget_init (): Promise < REDIS_CACHE_SINGLE_auth_translation > { + + let server_side_language: string = 'en'; + if ($page.routeId != null + && !$page.error + ) { + if ($page.routeId.includes("[lang=lang]")) { + server_side_language = $page.params.lang; + } + else { + server_side_language = 'en'; + } + } + else { + server_side_language = 'en'; + } + + const response_auth: REDIS_CACHE_SINGLE_auth_translation = + await get(`/api/hasura/_main_/auth?lang=${server_side_language}`) + ; + + return response_auth + } async function login_with_google () { // DOC: https://firebase.google.com/docs/auth/web/google-signin @@ -441,6 +462,7 @@ COMPONENT JS (w/ TS) email_error_format = false } + // [🐞] // $: if (browser) { // console.log(provider('isCoinbaseWallet')) // } @@ -496,9 +518,18 @@ COMPONENT JS (w/ TS) if (dev) console.log(`🟢 ${walletType} identified`) // DOC: https://stackoverflow.com/questions/69377437/metamask-conflicting-with-coinbase-wallet // DOC: https://stackoverflow.com/questions/72613011/whenever-i-click-on-connect-metamask-button-why-it-connects-the-coinbase-wallet + // DOC: https://stackoverflow.com/questions/68023651/how-to-connect-to-either-metamask-or-coinbase-wallet + // DOC: https://github.com/MetaMask/metamask-extension/issues/13622 // NOTE: conflicting use of CoinBaseWallet & MetaMask // NOTE: setting MetaMask as main wallet - target_wallet.request({ method: 'eth_requestAccounts' }); + // NOTE: IMPORTANT causes issues with FireFox + // target_wallet.request({ method: 'eth_requestAccounts' }); + // NOTE: Not working + // window.ethereum.setSelectedProvider(target_wallet); + // window.ethereum.request({ + // method: 'wallet_requestPermissions', + // params: [{ eth_accounts: {}}] + // }); return [true, target_wallet] } else { @@ -569,192 +600,292 @@ COMPONENT JS (w/ TS) COMPONENT HTML =================--> - -{#if $sessionStore.auth_show} -
$sessionStore.auth_show = false} - in:fade - /> -{/if} - - -{#if success_auth} -
- Success Icon +{:then WIDGET_LAZY_LOAD_DATA} + + + {#if $sessionStore.auth_show} +
$sessionStore.auth_show = false} + in:fade /> -

- Success! User - {#if auth_type == 'login'} - logged in - {:else} - signed up + {/if} + + + {#if success_auth} +

+ Success Icon +

+ {#if auth_type == 'login'} + {WIDGET_LAZY_LOAD_DATA?.success_msg[0]} + {:else} + {WIDGET_LAZY_LOAD_DATA?.success_msg[1]} + {/if} +

+
+ {/if} + + + {#if error_auth} +
+ Error Icon +

+ {WIDGET_LAZY_LOAD_DATA?.err_msg[0]} +

+
+ {/if} + + + {#if $sessionStore.auth_show} +
+ + + {#if processing} +
+
+ Loader Vector +

+ Processing +

+
+
{/if} -

-
-{/if} - - -{#if error_auth} -
- Error Icon -

- Uh-oh! There has been an error -

-
-{/if} - - -{#if $sessionStore.auth_show} -
- - - {#if processing} -
+ + + {#if email_verify_process}
+ id="email-auth-verify-box"> + Loader Vector $sessionStore.auth_show = false} /> + +

- Processing + w-500 + color-black-2 + " + style="font-size: 20px;"> + {WIDGET_LAZY_LOAD_DATA?.verification} +

+ +

+ {WIDGET_LAZY_LOAD_DATA?.verify_email} +

+ + Email Vector + +

+ {WIDGET_LAZY_LOAD_DATA?.email_verify_sent[0]} +
+ + {email_input} + +
+ {WIDGET_LAZY_LOAD_DATA?.email_verify_sent[1]} +

+ +

window.open('mailto:')}> + {WIDGET_LAZY_LOAD_DATA?.inbox} +

+ +

+ {WIDGET_LAZY_LOAD_DATA?.no_email_verify[0]} + login_with_email_link()}> + {WIDGET_LAZY_LOAD_DATA?.no_email_verify[1]} +

-
- {/if} - - - {#if email_verify_process} -
- - close-svg $sessionStore.auth_show = false} - /> + {/if} - -

- Verification -

- -

- Please verify your email -

- - Email Vector - -

- An email has been sent to -
- - {email_input} - -
- Please verify your email to continue. -

- -

window.open('mailto:')}> - Go to my inbox -

- -

- Did not get the email? -

+ + close-svg $sessionStore.auth_show = false} + /> + + +

+ Check your email +

+ +

+ Please follow the link in your email +

+ + Email Vector + +

+ An email has been sent to +
+ + {email_input} + +
+ Please follow the link in your email to login. +

+ +

login_with_email_link()}> - Resend email - -

-
- {/if} - - - {#if email_sent_process} -
+ style="margin-top: 8px;" + on:click={() => window.open('mailto:')}> + Go to my inbox +

+ + {#if allow_resend} +

+ Did not get the email? + login_with_email_link()}> + Resend email + +

+ {:else} +

+ {countD_min}:{countD_sec} to resend option +

+ {/if} + +
+ {/if} + + + {#if auth_view} @@ -767,326 +898,234 @@ COMPONENT HTML /> -

- Check your email -

- -

- Please follow the link in your email -

- - Email Vector +

- An email has been sent to -
- - {email_input} - -
- Please follow the link in your email to login. + id="auth-head" + class=" + color-black-2 + w-500 + "> + {#if auth_type == 'login'} + {WIDGET_LAZY_LOAD_DATA?.login} + {:else} + {WIDGET_LAZY_LOAD_DATA?.sign_up} + {/if}

+

window.open('mailto:')}> - Go to my inbox + color-grey + "> + {#if auth_type == 'login'} + {WIDGET_LAZY_LOAD_DATA?.email_msg[0]} + {:else} + {WIDGET_LAZY_LOAD_DATA?.email_msg[1]} + {/if}

- - {#if allow_resend} -

- Did not get the email? - login_with_email_link()}> + + wrong_email_format()} + autocomplete="off" + class:error-email={email_error_format} + required + /> + + {#if email_error_format} +

+ {WIDGET_LAZY_LOAD_DATA?.err_msg[1]} +

+ {/if} + + +
- {/if} - - - {#if auth_view} - - close-svg $sessionStore.auth_show = false} - /> - - - - - -

- {#if auth_type == 'login'} - Login - {:else} - Sign Up - {/if} -

+ w-500 + "> + {WIDGET_LAZY_LOAD_DATA?.email_continue} +

+ + - -

- {#if auth_type == 'login'} - Enter your email address to login - {:else} - Enter your email address to sign up - {/if} -

-
login_with_email_link()}> - - wrong_email_format()} - autocomplete="off" - class:error-email={email_error_format} - required - /> - {#if email_error_format} +
+

- Wrong format + class=" + color-grey + "> + {WIDGET_LAZY_LOAD_DATA?.or}

- {/if} +
+
+
+ + + + + + +
+ +
+

- Email already in use + class=" + color-grey + "> + {#if auth_type == 'login'} + {WIDGET_LAZY_LOAD_DATA?.or_web3_login} + {:else} + {WIDGET_LAZY_LOAD_DATA?.or_web3_signup} + {/if}

- {/if} - --> - +
+
- - -
-
-

- Or -

-
-
-
- - - - - -
- - -
-

{#if auth_type == 'login'} - Or login with your crypto wallet + {WIDGET_LAZY_LOAD_DATA?.no_account} + auth_type = 'register'}> + {WIDGET_LAZY_LOAD_DATA?.register} + {:else} - Or sign up with your crypto wallet + {WIDGET_LAZY_LOAD_DATA?.account_exists} + auth_type = 'login'}> + {WIDGET_LAZY_LOAD_DATA?.login} + {/if}

-
-
- + {/if} - -

- {#if auth_type == 'login'} - Do not have an account? - auth_type = 'register'}> - Register - - {:else} - Already have an account? - auth_type = 'login'}> - Login - - {/if} -

- {/if} +
+ {/if} -
-{/if} + +{:catch error} + +{/await} + + + + +
+ + + {#if !tabletExclusive} + +
+ +
+ +
+ +
+ + {#each {length: showNum} as _, i} +
+
+ +
+
+ +
+
+ {/each} + + + + + {:else if tabletExclusive && !mobileExclusive} + +
+ +
+ +
+ +
+ + {#each {length: showNum} as _, i} +
+
+ +
+
+ +
+
+ {/each} + + + + + {:else if tabletExclusive && mobileExclusive} + +
+ + +
+ + + + {#each {length: showNum} as _, i} +
+
+ +
+
+ +
+
+ {/each} + +
+ +
+ + {/if} + +
+ + + diff --git a/src/lib/components/fixtures_page/standings/Standings-Team-Row.svelte b/src/lib/components/fixtures_page/standings/Standings-Team-Row.svelte new file mode 100644 index 000000000..67b84f62e --- /dev/null +++ b/src/lib/components/fixtures_page/standings/Standings-Team-Row.svelte @@ -0,0 +1,378 @@ + + + + + + + + + + + +
+ +
+

+ {position} +

+
+ + {#if viewportDesktop} +
+ +
+ {/if} + +
+

+ {team_name} +

+
+
+ + + + {#if (TABLEMOBILEVIEW == 1 + && !viewportDesktop) + || viewportDesktop} + +

+ {points} +

+ + + +

+ {games_played} +

+ + + +

+ {TEAM_DATA.won} +

+ + + +

+ {TEAM_DATA.draw} +

+ + + +

+ {TEAM_DATA.lost} +

+ + + +

+ {TEAM_DATA.gs} +

+ + + +

+ {TEAM_DATA.ga} +

+ + {/if} + + {#if (TABLEMOBILEVIEW == 2 + && !viewportDesktop) + || viewportDesktop} + +
+ {#each recent_form as form} +
+ {/each} +
+ + {/if} + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/Standings-Widget.svelte b/src/lib/components/fixtures_page/standings/Standings-Widget.svelte new file mode 100644 index 000000000..2be81c441 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/Standings-Widget.svelte @@ -0,0 +1,994 @@ + + + + + + + +{#if toggleCTA} +
closeAllDropdowns()} + /> +{/if} + +
+ + + +
+

{STANDINGS_T.translations.standings}

+ {#if STANDINGS_DATA != undefined + && STANDINGS_DATA?.seasons.length != 0} + {#if !STANDINGS_DATA.seasons[0].group} + {#each STANDINGS_DATA.seasons[0].total as team} +

{team.team_name}

+ {/each} + {:else} + {#each STANDINGS_DATA.seasons[0].group_standings as group} +

{group.group_name}

+ {#each group.total as team} +

{team.team_name}

+ {/each} + {/each} + {/if} + + {/if} + +
+ + + + {#if no_widget_data + && seasonCheck + && !loaded} + +

+ {STANDINGS_T?.translations.standings} +

+ +
+ + no_visual_dark + +
+

+ {STANDINGS_T.no_data_t.no_info}

+

+ {STANDINGS_T.no_data_t.no_info_desc} +

+
+
+ {/if} + + + {#if !no_widget_data + && !refresh + && browser + && $userBetarenaSettings.country_bookmaker + && seasonCheck + && !diasbleDev} + + + + + {#await widgetInit()} + + + {:then data} + +

+ {STANDINGS_T.translations.standings} +

+
+ +
+ +
+
selectTableView('total')} + class:activeOpt={selectedOpt == 'total'} + class:total_view_only={only_total_view_league_ids.includes(STANDINGS_DATA?.league_id)}> +

+ {STANDINGS_T.translations.total} +

+
+ + {#if !only_total_view_league_ids.includes(STANDINGS_DATA?.league_id)} +
selectTableView('home')} + class:activeOpt={selectedOpt == 'home'}> +

+ {STANDINGS_T.translations.home} +

+
+ +
selectTableView('away')} + class:activeOpt={selectedOpt == 'away'}> +

+ {STANDINGS_T.translations.away} +

+
+ {/if} + + +
+ + {#if mobileExclusive} +
toggle_mobile_form()}> +

+ Form +

+
+ {/if} +
+ + + + + + + + {#if (mobileExclusive + && selectedOptTableMobile == 1) + || !mobileExclusive} + + + + + + + + + + + + + + + {/if} + + {#if (mobileExclusive + && selectedOptTableMobile == 2) + || !mobileExclusive} + + + {/if} + + + + + {#if !season.group} + {#each season[selectedOpt] as team} + {#if !showMore + && (team?.team_name == FIXTURE_INFO?.data?.away_team_name + || team?.team_name == FIXTURE_INFO?.data?.home_team_name)} + + {:else if showMore} + + {/if} + {/each} + + {:else} + {#each season.group_standings as group} + + + + {#each group[selectedOpt] as team} + + {/each} + {/each} + + + + {/if} + +
+

+ # + + {STANDINGS_T.translations.team} +

+
+

+ {STANDINGS_T.translations.pts} +

+
+

+ {STANDINGS_T.translations.tooltips.pts.title} +

+

+ {STANDINGS_T.translations.tooltips.pts.description} +

+
+
+

+ {STANDINGS_T.translations.pld} +

+
+

+ {STANDINGS_T.translations.tooltips.pld.title} +

+

+ {STANDINGS_T.translations.tooltips.pld.description} +

+
+
+

+ {STANDINGS_T.translations.w} +

+
+

+ {STANDINGS_T.translations.tooltips.w.title} +

+

+ {STANDINGS_T.translations.tooltips.w.description} +

+
+
+

+ {STANDINGS_T.translations.d} +

+
+

+ {STANDINGS_T.translations.tooltips.d.title} +

+

+ {STANDINGS_T.translations.tooltips.d.description} +

+
+
+

+ {STANDINGS_T.translations.l} +

+
+

+ {STANDINGS_T.translations.tooltips.l.title} +

+

+ {STANDINGS_T.translations.tooltips.l.description} +

+
+
+

+ {STANDINGS_T.translations.gf} +

+
+

+ {STANDINGS_T.translations.tooltips.gf.title} +

+

+ {STANDINGS_T.translations.tooltips.gf.description} +

+
+
+

+ {STANDINGS_T.translations.ga} +

+
+

+ {STANDINGS_T.translations.tooltips.ga.title} +

+

+ {STANDINGS_T.translations.tooltips.ga.description} +

+
+
+

+ {STANDINGS_T.translations.recent_form} +

+
+
+

+ {STANDINGS_T?.translations?.group} + {group.group_name.split(' ')[1]} +

+
+
+
+ +
+

toggle_full_list()}> + {#if !showMore} + See the full standings + {:else} + Show less + {/if} +

+
+ +
+ + {:catch error} + {error} + {/await} + + {/if} + +
+ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/arrow-down.svg b/src/lib/components/fixtures_page/standings/assets/arrow-down.svg new file mode 100644 index 000000000..99cb371a3 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/arrow-down.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/arrow-up.svg b/src/lib/components/fixtures_page/standings/assets/arrow-up.svg new file mode 100644 index 000000000..6d02ba762 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/arrow-up.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual.svg b/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual.svg new file mode 100644 index 000000000..eed0034b7 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual_dark.svg b/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual_dark.svg new file mode 100644 index 000000000..9dffbefa2 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/no_featured_match_visual_dark.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/lib/components/fixtures_page/standings/assets/no_visual.svg b/src/lib/components/fixtures_page/standings/assets/no_visual.svg new file mode 100644 index 000000000..cc3b25c2b --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/no_visual.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/assets/no_visual_dark.svg b/src/lib/components/fixtures_page/standings/assets/no_visual_dark.svg new file mode 100644 index 000000000..d65df2f13 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/no_visual_dark.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/src/lib/components/fixtures_page/standings/assets/slider-left-dark.svg b/src/lib/components/fixtures_page/standings/assets/slider-left-dark.svg new file mode 100644 index 000000000..80f65f6c1 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/slider-left-dark.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/slider-left.svg b/src/lib/components/fixtures_page/standings/assets/slider-left.svg new file mode 100644 index 000000000..956f3ad65 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/slider-left.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/slider-right-dark.svg b/src/lib/components/fixtures_page/standings/assets/slider-right-dark.svg new file mode 100644 index 000000000..04088c224 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/slider-right-dark.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/slider-right.svg b/src/lib/components/fixtures_page/standings/assets/slider-right.svg new file mode 100644 index 000000000..5835c7129 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/slider-right.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/lib/components/fixtures_page/standings/assets/team-white.svg b/src/lib/components/fixtures_page/standings/assets/team-white.svg new file mode 100644 index 000000000..77e2d7791 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/team-white.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/lib/components/fixtures_page/standings/assets/team.svg b/src/lib/components/fixtures_page/standings/assets/team.svg new file mode 100644 index 000000000..4ec12ee73 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/assets/team.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Bottom.svelte b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Bottom.svelte new file mode 100644 index 000000000..0c2cfe034 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Bottom.svelte @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Head.svelte b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Head.svelte new file mode 100644 index 000000000..8a674bae3 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Head.svelte @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Left.svelte b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Left.svelte new file mode 100644 index 000000000..919576fe1 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Left.svelte @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Right.svelte b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Right.svelte new file mode 100644 index 000000000..9711b15f1 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-Row-Right.svelte @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-ViewSel.svelte b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-ViewSel.svelte new file mode 100644 index 000000000..12cbec5e3 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/desktop/Loader-ViewSel.svelte @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Bottom.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Bottom.svelte new file mode 100644 index 000000000..7a7da0032 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Bottom.svelte @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Head.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Head.svelte new file mode 100644 index 000000000..c2813e2bc --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Head.svelte @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Left-M.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Left-M.svelte new file mode 100644 index 000000000..58b622519 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Left-M.svelte @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Right-M.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Right-M.svelte new file mode 100644 index 000000000..58e48c8a1 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Row-Right-M.svelte @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Table-View.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Table-View.svelte new file mode 100644 index 000000000..f676d847a --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-Table-View.svelte @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel-Right.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel-Right.svelte new file mode 100644 index 000000000..a0d66c562 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel-Right.svelte @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel.svelte b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel.svelte new file mode 100644 index 000000000..ea06c6e78 --- /dev/null +++ b/src/lib/components/fixtures_page/standings/loaders/mobile/Loader-ViewSel.svelte @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/graphql/_main_/auth/query.ts b/src/lib/graphql/_main_/auth/query.ts new file mode 100644 index 000000000..a4bea9f82 --- /dev/null +++ b/src/lib/graphql/_main_/auth/query.ts @@ -0,0 +1,33 @@ +import { gql } from 'graphql-request'; + +/** + * ==================== + * [ℹ] Surgical Queries + * [ℹ] Obtained directly + * [ℹ] from HASURA + * ==================== +*/ + +/** + * [ℹ] GET target auth lang translation [main] [DATA] +*/ +export const BETARENA_SCORES_AUTH_TRANSLATION = gql` + query BETARENA_SCORES_AUTH_TRANSLATION + ( + $lang: String! + ) + @cached + (ttl: 300) + { + auth_translations ( + where: { + lang: { + _eq: $lang + } + } + ) { + lang + translation + } + } +`; diff --git a/src/lib/models/_main_/auth/types.ts b/src/lib/models/_main_/auth/types.ts new file mode 100644 index 000000000..54fd0c671 --- /dev/null +++ b/src/lib/models/_main_/auth/types.ts @@ -0,0 +1,27 @@ +import type { + Auth_Translation, + BETARENA_HASURA_auth_translations +} from "$lib/models/hasura" + +/** + * ========================================== + * CACHING PERSIST - COMPLETE WIDGET REQUIRED DATA + * ========================================== +*/ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface REDIS_CACHE_SINGLE_auth_translation + extends Auth_Translation { + lang?: string +} + +/** + * ========================================== + * HASURA DB - COMPLETE WIDGET REQUIRED DATA + * ========================================== +*/ + +export interface BETARENA_HASURA_auth_query { + // NOTE: translations + auth_translations: BETARENA_HASURA_auth_translations[] +} \ No newline at end of file diff --git a/src/lib/models/fixtures/scoreboard/types.ts b/src/lib/models/fixtures/scoreboard/types.ts index 30b5fc7ee..425c2d529 100644 --- a/src/lib/models/fixtures/scoreboard/types.ts +++ b/src/lib/models/fixtures/scoreboard/types.ts @@ -74,6 +74,7 @@ export interface Fixture_Scoreboard_Info { home: Fixture_Scoreboard_Team away: Fixture_Scoreboard_Team } + league_id?: number league_logo?: string league_urls?: ScoresTournamentsUrls // NOTE: Scoreboard Before the match (fixture_scoreboard); diff --git a/src/lib/models/hasura.ts b/src/lib/models/hasura.ts index 51d19e121..e96ec5850 100644 --- a/src/lib/models/hasura.ts +++ b/src/lib/models/hasura.ts @@ -1718,3 +1718,32 @@ export interface BETARENA_HASURA_scores_fixtures_h2h_translations { widget_title?: string; yellow_cards?: string; } + +/** + * [ℹ] HASURA: auth_translations (&) +*/ +export interface BETARENA_HASURA_auth_translations { + lang?: string; + translation?: Auth_Translation; +} export interface Auth_Translation { + or?: string; + inbox?: string; + login?: string; + err_msg?: string[]; + log_out?: string; + profile?: string; + sign_up?: string; + register?: string; + email_msg?: string[]; + no_account?: string; + processing?: string; + success_msg?: string[]; + verification?: string; + verify_email?: string; + or_web3_login?: string; + account_exists?: string; + email_continue?: string; + or_web3_signup?: string; + no_email_verify?: string[]; + email_verify_sent?: string[]; +} \ No newline at end of file diff --git a/src/routes/[lang=lang]/[sport]/[fixture=fixture]/+page.svelte b/src/routes/[lang=lang]/[sport]/[fixture=fixture]/+page.svelte index bf2d59eaa..f903dd102 100644 --- a/src/routes/[lang=lang]/[sport]/[fixture=fixture]/+page.svelte +++ b/src/routes/[lang=lang]/[sport]/[fixture=fixture]/+page.svelte @@ -51,6 +51,7 @@ import type { REDIS_CACHE_SINGLE_probabilities_translation } from '$lib/models/fixtures/probabilities/types'; import type { REDIS_CACHE_SINGLE_votes_translation } from '$lib/models/fixtures/votes/types'; import type { REDIS_CACHE_SINGLE_tournaments_fixtures_odds_widget_t_data_response } from '$lib/models/tournaments/fixtures_odds/types'; + import type { REDIS_CACHE_SINGLE_tournament_standings_data, REDIS_CACHE_SINGLE_tournament_standings_translation } from '$lib/models/tournaments/standings/types'; import AboutWidget from '$lib/components/fixtures_page/about/About_Widget.svelte'; import ContentWidget from '$lib/components/fixtures_page/content/Content_Widget.svelte'; @@ -59,6 +60,7 @@ import LineupsWidget from '$lib/components/fixtures_page/lineups/Lineups_Widget.svelte'; import ProbabilityWidget from '$lib/components/fixtures_page/probabilities/Probability_Widget.svelte'; import ScoreboardWidget from '$lib/components/fixtures_page/scoreboard/Scoreboard_Widget.svelte'; + import StandingsWidget from '$lib/components/fixtures_page/standings/Standings-Widget.svelte'; import StatisticsWidget from '$lib/components/fixtures_page/statistics/Statistics_Widget.svelte'; import VoteWidget from '$lib/components/fixtures_page/votes/Vote_Widget.svelte'; import FeaturedBettingSitesWidget from '$lib/components/home/featured_betting_sites/_FeaturedBettingSitesWidget.svelte'; @@ -84,6 +86,8 @@ let FIXTURES_ODDS_T: REDIS_CACHE_SINGLE_tournaments_fixtures_odds_widget_t_data_response let FIXTURE_H2H: Fixture_Head_2_Head let FIXTURE_H2H_TRANSLATION: REDIS_CACHE_SINGLE_h2h_translation + let STANDINGS_T: REDIS_CACHE_SINGLE_tournament_standings_translation + let STANDINGS_DATA: REDIS_CACHE_SINGLE_tournament_standings_data // ~~~~~~~~~~~~~~~~~~~~~ // REACTIVE SVELTE OTHER @@ -109,6 +113,8 @@ $: FIXTURES_ODDS_T = $page.data.FIXTURES_ODDS_T; $: FIXTURE_H2H = $page.data.FIXTURE_H2H; $: FIXTURE_H2H_TRANSLATION = $page.data.FIXTURE_H2H_TRANSLATION; + $: STANDINGS_T = $page.data.STANDINGS_T; + $: STANDINGS_DATA = $page.data.STANDINGS_DATA; $: country_link = FIXTURE_INFO?.data?.country == undefined @@ -262,23 +268,33 @@ id='fixture-page'> + [ℹ] breadcrumbs URL + -->
+ class=' + row-space-start + m-b-20 + '> + [ℹ] sport + --> + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}` + : `/${$page.params.sport}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.sport}

@@ -291,17 +307,23 @@ /> - + + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}/${country_link}` + : `/${$page.params.sport}/${country_link}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.country}

@@ -314,17 +336,23 @@ /> + [ℹ] league_name + --> + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}/${country_link}/${league_name_link}` + : `/${$page.params.sport}/${country_link}/${league_name_link}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.league_name}

@@ -337,9 +365,16 @@ /> + [ℹ] fxiture_name + -->

+ class=' + s-14 + color-white + m-r-10 + capitalize + fixture-name + '> {FIXTURE_INFO?.data?.home_team_name} vs {FIXTURE_INFO?.data?.away_team_name} @@ -395,6 +430,11 @@ {FIXTURE_INFO} {FIXTURE_PROBS_TRANSLATION} /> + + r.json()); + // [🐞] + const league_id = response_scoreboard?.league_id; + if (dev) console.log('league_id', league_id) + + const response_standings_translations: REDIS_CACHE_SINGLE_tournament_standings_translation = await fetch( + `/api/cache/tournaments/standings?lang=${urlLang}`, { + method: 'GET' + } + ).then((r) => r.json()); + + const response_standings_data: REDIS_CACHE_SINGLE_tournament_standings_data = await fetch( + `/api/cache/tournaments/standings?league_id=${league_id}`, { + method: 'GET' + } + ).then((r) => r.json()); + /** * ========== * [ℹ] RETURN @@ -395,6 +408,8 @@ export async function load({ if (response_h2h == undefined) console.log("response_h2h is undefined") if (response_h2h_translation == undefined) console.log("response_h2h_translation is undefined") if (response_fixtures_odds_translations == undefined) console.log("response_fixtures_odds_translations is undefined") + if (response_standings_translations == undefined) console.log("response_standings_translations is undefined") + if (response_standings_data == undefined) console.log("response_standings_data is undefined") } if ( @@ -441,7 +456,9 @@ export async function load({ FIXTURE_H2H: response_h2h, FIXTURE_H2H_TRANSLATION: response_h2h_translation, // extra - FIXTURES_ODDS_T: response_fixtures_odds_translations + FIXTURES_ODDS_T: response_fixtures_odds_translations, + STANDINGS_T: response_standings_translations, + STANDINGS_DATA: response_standings_data } } diff --git a/src/routes/[sport]/[fixture=fixture]/+page.svelte b/src/routes/[sport]/[fixture=fixture]/+page.svelte index bf2d59eaa..f903dd102 100644 --- a/src/routes/[sport]/[fixture=fixture]/+page.svelte +++ b/src/routes/[sport]/[fixture=fixture]/+page.svelte @@ -51,6 +51,7 @@ import type { REDIS_CACHE_SINGLE_probabilities_translation } from '$lib/models/fixtures/probabilities/types'; import type { REDIS_CACHE_SINGLE_votes_translation } from '$lib/models/fixtures/votes/types'; import type { REDIS_CACHE_SINGLE_tournaments_fixtures_odds_widget_t_data_response } from '$lib/models/tournaments/fixtures_odds/types'; + import type { REDIS_CACHE_SINGLE_tournament_standings_data, REDIS_CACHE_SINGLE_tournament_standings_translation } from '$lib/models/tournaments/standings/types'; import AboutWidget from '$lib/components/fixtures_page/about/About_Widget.svelte'; import ContentWidget from '$lib/components/fixtures_page/content/Content_Widget.svelte'; @@ -59,6 +60,7 @@ import LineupsWidget from '$lib/components/fixtures_page/lineups/Lineups_Widget.svelte'; import ProbabilityWidget from '$lib/components/fixtures_page/probabilities/Probability_Widget.svelte'; import ScoreboardWidget from '$lib/components/fixtures_page/scoreboard/Scoreboard_Widget.svelte'; + import StandingsWidget from '$lib/components/fixtures_page/standings/Standings-Widget.svelte'; import StatisticsWidget from '$lib/components/fixtures_page/statistics/Statistics_Widget.svelte'; import VoteWidget from '$lib/components/fixtures_page/votes/Vote_Widget.svelte'; import FeaturedBettingSitesWidget from '$lib/components/home/featured_betting_sites/_FeaturedBettingSitesWidget.svelte'; @@ -84,6 +86,8 @@ let FIXTURES_ODDS_T: REDIS_CACHE_SINGLE_tournaments_fixtures_odds_widget_t_data_response let FIXTURE_H2H: Fixture_Head_2_Head let FIXTURE_H2H_TRANSLATION: REDIS_CACHE_SINGLE_h2h_translation + let STANDINGS_T: REDIS_CACHE_SINGLE_tournament_standings_translation + let STANDINGS_DATA: REDIS_CACHE_SINGLE_tournament_standings_data // ~~~~~~~~~~~~~~~~~~~~~ // REACTIVE SVELTE OTHER @@ -109,6 +113,8 @@ $: FIXTURES_ODDS_T = $page.data.FIXTURES_ODDS_T; $: FIXTURE_H2H = $page.data.FIXTURE_H2H; $: FIXTURE_H2H_TRANSLATION = $page.data.FIXTURE_H2H_TRANSLATION; + $: STANDINGS_T = $page.data.STANDINGS_T; + $: STANDINGS_DATA = $page.data.STANDINGS_DATA; $: country_link = FIXTURE_INFO?.data?.country == undefined @@ -262,23 +268,33 @@ id='fixture-page'> + [ℹ] breadcrumbs URL + -->

+ class=' + row-space-start + m-b-20 + '> + [ℹ] sport + --> + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}` + : `/${$page.params.sport}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.sport}

@@ -291,17 +307,23 @@ /> - + + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}/${country_link}` + : `/${$page.params.sport}/${country_link}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.country}

@@ -314,17 +336,23 @@ /> + [ℹ] league_name + --> + href={$page.params.lang != undefined + ? `/${$page.params.lang}/${$page.params.sport}/${country_link}/${league_name_link}` + : `/${$page.params.sport}/${country_link}/${league_name_link}` + }>

+ class=' + s-14 + color-white + m-r-10 + capitalize + cursor-pointer + no-wrap + '> {FIXTURE_INFO?.data?.league_name}

@@ -337,9 +365,16 @@ /> + [ℹ] fxiture_name + -->

+ class=' + s-14 + color-white + m-r-10 + capitalize + fixture-name + '> {FIXTURE_INFO?.data?.home_team_name} vs {FIXTURE_INFO?.data?.away_team_name} @@ -395,6 +430,11 @@ {FIXTURE_INFO} {FIXTURE_PROBS_TRANSLATION} /> + + r.json()); + // [🐞] + const league_id = response_scoreboard?.league_id; + if (dev) console.log('league_id', league_id) + + const response_standings_translations: REDIS_CACHE_SINGLE_tournament_standings_translation = await fetch( + `/api/cache/tournaments/standings?lang=${urlLang}`, { + method: 'GET' + } + ).then((r) => r.json()); + + const response_standings_data: REDIS_CACHE_SINGLE_tournament_standings_data = await fetch( + `/api/cache/tournaments/standings?league_id=${league_id}`, { + method: 'GET' + } + ).then((r) => r.json()); + /** * ========== * [ℹ] RETURN @@ -395,6 +408,8 @@ export async function load({ if (response_h2h == undefined) console.log("response_h2h is undefined") if (response_h2h_translation == undefined) console.log("response_h2h_translation is undefined") if (response_fixtures_odds_translations == undefined) console.log("response_fixtures_odds_translations is undefined") + if (response_standings_translations == undefined) console.log("response_standings_translations is undefined") + if (response_standings_data == undefined) console.log("response_standings_data is undefined") } if ( @@ -441,7 +456,9 @@ export async function load({ FIXTURE_H2H: response_h2h, FIXTURE_H2H_TRANSLATION: response_h2h_translation, // extra - FIXTURES_ODDS_T: response_fixtures_odds_translations + FIXTURES_ODDS_T: response_fixtures_odds_translations, + STANDINGS_T: response_standings_translations, + STANDINGS_DATA: response_standings_data } } diff --git a/src/routes/api/hasura/_main_/auth/+server.ts b/src/routes/api/hasura/_main_/auth/+server.ts new file mode 100644 index 000000000..e885a11e9 --- /dev/null +++ b/src/routes/api/hasura/_main_/auth/+server.ts @@ -0,0 +1,86 @@ +import { json } from '@sveltejs/kit'; +import { performance } from 'perf_hooks'; + +import { initGrapQLClient } from '$lib/graphql/init_graphQL'; + +import { BETARENA_SCORES_AUTH_TRANSLATION } from '$lib/graphql/_main_/auth/query'; +import type { BETARENA_HASURA_auth_translations } from '$lib/models/hasura'; +import type { BETARENA_HASURA_auth_query, REDIS_CACHE_SINGLE_auth_translation } from '$lib/models/_main_/auth/types'; + +// [ℹ] debug info +const logs = []; + +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// [MAIN] ENDPOINT METHOD +// ~~~~~~~~~~~~~~~~~~~~~~~~ + +export async function GET(req): Promise { + const lang: string = req.url['searchParams'].get('lang'); + const target_translations = await main(lang); + return json(target_translations); +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// [MAIN] METHOD +// ~~~~~~~~~~~~~~~~~~~~~~~~ + +async function main ( + _lang: string +): Promise < REDIS_CACHE_SINGLE_auth_translation | null > { + + // [ℹ] relying on lang + // [ℹ] to get Target Translation + + const LANG = _lang + + /** + * [ℹ] obtain target historic_fixtures [fixture_id] + */ + + const data = await get_auth_translation(LANG); + // [ℹ] exit + if (data == undefined) { + return null; + } + + /** + * [ℹ] generate CONTENT data + * [ℹ] return FIXTURE-CONTENT + */ + + const object: REDIS_CACHE_SINGLE_auth_translation = {} + object.lang = LANG + + const objectAuthTrans = data + .find(({ lang }) => lang === LANG) + + const mergedObj = { + ...object, + ...objectAuthTrans?.translation + } + + return mergedObj; +} + +// ~~~~~~~~~~~~~~~~~~~~~~~~ +// [HELPER] OTHER METHODS +// ~~~~~~~~~~~~~~~~~~~~~~~~ + +async function get_auth_translation ( + lang: string +): Promise< BETARENA_HASURA_auth_translations[] > { + // [ℹ] obtain target external_content [fixture_id based] + const queryName = 'REDIS_CACHE_FIXTURE_CONTENT_DATA_3'; + const t0 = performance.now(); + const VARIABLES = { + lang + }; + const response: BETARENA_HASURA_auth_query = await initGrapQLClient().request( + BETARENA_SCORES_AUTH_TRANSLATION, + VARIABLES + ); + const t1 = performance.now(); + logs.push(`${queryName} completed in: ${(t1 - t0) / 1000} sec`); + + return response.auth_translations; +} \ No newline at end of file diff --git a/src/routes/api/hasura/fixtures/scoreboard/+server.ts b/src/routes/api/hasura/fixtures/scoreboard/+server.ts index 935eaa6c0..86dbfda8f 100644 --- a/src/routes/api/hasura/fixtures/scoreboard/+server.ts +++ b/src/routes/api/hasura/fixtures/scoreboard/+server.ts @@ -123,6 +123,7 @@ async function main ( home: home_team_obj || null, away: away_team_obj || null }, + league_id, league_logo: league_img || null, league_urls: tournament_urls || null, score_post: { diff --git a/tsconfig.json b/tsconfig.json index 7c3f64949..e5ba203c9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,5 +32,5 @@ "$lib/*": ["src/lib/*"] } }, - "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte", "my-server.js"] + "include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte", "docker-server.js", "heroku-server.js"] }