Skip to content

Commit

Permalink
Dev (#2120)
Browse files Browse the repository at this point in the history
* fix: userguid modal (#2096)

* Fix/tag links/draft/0 (#2098)

* Fix/tutorial popup/draft/0 (#2099)

* fix: userguid modal

* fix: body  scroll

* fix: prevent articles with same id (#2102)

* Feature/bottom menu/draft/0 (#2103)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* Feature/bottom menu/draft/0 (#2104)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* remove yarn lock

* fix: canonical link (#2105)

* fix reopen userguide (#2106)

* Feature/bottom menu/draft/0 (#2107)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* icons color

* dev: mobile menu

* dev: blur popup background

* Feature/bottom menu/draft/0 (#2112)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* icons color

* dev: mobile menu

* dev: blur popup background

* dev: add new route

* Feature/bottom menu/draft/0 (#2113)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* icons color

* dev: mobile menu

* dev: blur popup background

* dev: add new route

* fix redirects

* dev: Avatar size

* Feature/bottom menu/draft/0 (#2114)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* icons color

* dev: mobile menu

* dev: blur popup background

* dev: add new route

* fix redirects

* dev: Avatar size

* fix leag load

* Feature/bottom menu/draft/0 (#2115)

* dev: mobile menu

* dev: mobile menu d'n'd

* dev: popup styles

* dev: dragged style

* dev: modal mouse events

* [dev] Mobile menu

* dev: change bottom position

* dev: mobile menu threshold

* fix: disable drag out

* remove unused code

* remove yarn.lock

* icons color

* dev: mobile menu

* dev: blur popup background

* dev: add new route

* fix redirects

* dev: Avatar size

* fix leag load

* avatar size

* fix redirect (#2118)

* ci: reset branch (dev) reset

[1] -----
Update Github actions workflow to make use of the 'dev' branch reset on 'main' (PR). Initially disabled for the idea of using a 'release' branch to be reset, instead of 'dev', as multiple developers can have pushed to 'dev' when a 'PR' goes to 'main', resetting version control state and unding work.

---------

Co-authored-by: MigBash <[email protected]>
  • Loading branch information
Izobov and migbash authored May 9, 2024
1 parent 31f13ed commit a003dda
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pr-main-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ jobs:

dev-branch-reset:
name: Git Reset Dev
if: false
needs: create-release
runs-on: ubuntu-22.04
steps:
Expand Down
7 changes: 6 additions & 1 deletion src/lib/constants/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,10 @@ export const
* @description
* 📣 Target `path` for **scores page**.
*/
routeIdScores = '/(scores)/[[lang=lang]]/scores'
routeIdScores = '/(scores)/[[lang=lang]]/scores',
/**
* @description
* 📣 Target `path` for **home page**.
*/
routeIdHome = '/(scores)/[[lang=lang]]'
;
46 changes: 46 additions & 0 deletions src/lib/firebase/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,52 @@ import type { Page } from '@sveltejs/kit';

// #region 🔥 USER

/**
* @author
* @izobov
* @summary
* - 🟥 MAIN
* - 🟦 HELPER
* @description
* 📣 Retrieves `Firebase/Firestore` data for **current user**.
* @param { string } uid
* 💠 **[required]** Target user **uid**.
* @return { Promise < void > }
*/
export async function getUserById
(
uid: string
)
{
// [🐞]
dlog
(
'🚏 checkpoint ➤ getUserById(..)',
true
);

console.log("db_firestore",db_firestore)
console.log("UID",uid)

const
docRef
= doc
(
db_firestore,
'betarena_users',
uid
),
docSnap
= await getDoc
(
docRef
)
;

if (!docSnap.exists()) return;

return docSnap.data();
}
/**
* @author
* @migbash
Expand Down
4 changes: 3 additions & 1 deletion src/lib/store/user-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function createLocalStore
extract:
<Typ1>
(
dataPoint: 'geo-bookmaker' | 'lang' | 'lang-user' | 'uid'
dataPoint: 'geo-bookmaker' | 'lang' | 'lang-user' | 'uid' | 'user'
): Typ1 | NullUndef =>
{
const
Expand All @@ -539,6 +539,8 @@ function createLocalStore
return localStore?.user?.scores_user_data?.lang as Typ1 | NullUndef;
else if (dataPoint == 'uid')
return localStore?.user?.firebase_user_data?.uid as Typ1 | NullUndef;
else if (dataPoint === 'user')
return localStore?.user?.scores_user_data as Typ1 | NullUndef;
;

return;
Expand Down
40 changes: 33 additions & 7 deletions src/lib/utils/deeplink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import { isSignInWithEmailLink, signInWithCustomToken, signInWithEmailLink } fro
import { auth } from '$lib/firebase/init.js';
import { setCookie } from '$lib/store/cookie.js';
import sessionStore from '$lib/store/session.js';
import userBetarenaSettings from '$lib/store/user-settings.js';
import { authWithMoralis, successAuthComplete } from './authentication.js';
import { AU_W_TAG, dlog, dlogv2, errlog } from './debug.js';

import type { Page } from '@sveltejs/kit';
import { routeIdHome } from '$lib/constants/paths.js';
import type { B_NAV_T } from '@betarena/scores-lib/types/navbar.js';
import { generateUrlCompetitions } from './string.js';

// #endregion ➤ 📦 Package Imports

Expand Down Expand Up @@ -51,13 +55,35 @@ export async function mainDeepLinkCheck
* @description
* 📝 Data for `page`.
*/
page = sessionStore.extract<Page>('page'),
/**
* @description
* 📝 Data for `page`.
*/
revertUrl = `${page?.url.origin}${page?.url.pathname}`
;
page = sessionStore.extract<Page>('page')
;
let /**
* @description
* 📝 Data for `page`.
*/
revertUrl = `${page?.url.origin}${page?.url.pathname}`
if (page?.route.id === routeIdHome)
{
const lang = sessionStore.extract<string>('lang');
const [preferedPage] = userBetarenaSettings.extract<{buttons_order: string[]}>('user')?.buttons_order || ["scores"];
const translations = page.data.B_NAV_T as B_NAV_T | null | undefined;
switch (preferedPage) {
case "competitions":
revertUrl = generateUrlCompetitions(
lang || "",
page.data.B_SAP_D3_CP_H
);
break;
case "content":
revertUrl =
translations?.scores_header_translations?.section_links
?.sports_content_url as string;
break;
case "scores":
default:
revertUrl = `/${lang === "en" ? "" : `${lang}/`}scores`;
}
}

await goto
(
Expand Down
89 changes: 43 additions & 46 deletions src/routes/(scores)/[[lang=lang]]/+page.server.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,62 @@
// ╭──────────────────────────────────────────────────────────────────────────────────╮
// │ 📌 High Order Component Overview │
// ┣──────────────────────────────────────────────────────────────────────────────────┫
// │ ➤ Internal Svelte Code Format :|: V.8.0 │
// │ ➤ Status :|: 🔒 LOCKED │
// │ ➤ Author(s) :|: @migbash │
// ┣──────────────────────────────────────────────────────────────────────────────────┫
// │ 📝 Description │
// ┣──────────────────────────────────────────────────────────────────────────────────┫
// │ Main Scores Platform Page Loader ('Client-Side') │
// ╰──────────────────────────────────────────────────────────────────────────────────╯

// #region ➤ 📦 Package Imports
// // ╭──────────────────────────────────────────────────────────────────────────────────╮
// // │ 📌 High Order Component Overview │
// // ┣──────────────────────────────────────────────────────────────────────────────────┫
// // │ ➤ Internal Svelte Code Format :|: V.8.0 │
// // │ ➤ Status :|: 🔒 LOCKED │
// // │ ➤ Author(s) :|: @migbash │
// // ┣──────────────────────────────────────────────────────────────────────────────────┫
// // │ 📝 Description │
// // ┣──────────────────────────────────────────────────────────────────────────────────┫
// // │ Main Scores Platform Page Loader ('Client-Side') │
// // ╰──────────────────────────────────────────────────────────────────────────────────╯

// // #region ➤ 📦 Package Imports

// import { ServerLoadEvent, redirect } from '@sveltejs/kit';

// import { main } from '$lib/sveltekit/load/load.lang.js';
// import { dlogv2 } from '$lib/utils/debug.js';
// import { getUserById, userDataFetch } from '$lib/firebase/common.js';

// #endregion ➤ 📦 Package Imports
// // #endregion ➤ 📦 Package Imports

// #region ➤ 🔄 LIFECYCLE [SVELTE]
// // #region ➤ 🔄 LIFECYCLE [SVELTE]

// /**
// * @type {import('./$types').PageLoad}
// */
// // /**
// // * @type {import('./$types').PageLoad}
// // */
// export async function load
// (
// event: ServerLoadEvent
// ): Promise < any >
// {
// console.log("EVENT :", event);
// const userId = await JSON.parse(event.locals.user);
// console.log("COOKIES :", userId["user-uid"]);
// if (!userId) redirect(300, "/scores");
// const user = await getUserById(userId);
// const { langParam } = await event.parent();
// // [🐞]
// dlogv2
// (
// '🚏 checkpoint ➤ src/routes/(scores)/[[lang=lang]]/+page.server.ts',
// [
// `🔹 [var] ➤ langParam :|: ${langParam}`,
// ],
// true
// );
// const defaultRedirectURL = `${langParam !== "en" ? `/${langParam}` : ""}/scores`;
// console.log("langParam1 :", langParam);
// const event_user = await JSON.parse(event.locals.user);
// const userId = event_user["user-uid"];
// console.log("COOKIES UID:", userId);

// const user = userId ? await getUserById(userId) : null;
// console.log("USER :", user);
// if (!user) redirect(300, "/scores");
// const
// d = await event.parent()
// ;
// console.log("PARENT DATA :", d);
// const {langParam} = d;
// // [🐞]
// dlogv2
// (
// '🚏 checkpoint ➤ src/routes/(scores)/[[lang=lang]]/+page.server.ts',
// [
// `🔹 [var] ➤ langParam :|: ${langParam}`,
// ],
// true
// );
// if (user)
// {
// return {}
// };
// console.log("REDIRECTING...", defaultRedirectURL)
// redirect(300, defaultRedirectURL)


// return await main
// (
// event,
// {
// langParam
// }
// );

// }

// #endregion ➤ 🔄 LIFECYCLE [SVELTE]
// // #endregion ➤ 🔄 LIFECYCLE [SVELTE]
20 changes: 9 additions & 11 deletions src/routes/(scores)/[[lang=lang]]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
import { goto } from "$app/navigation";
import { page } from "$app/stores";
import { generateUrlCompetitions } from "$lib/utils/string.js";
import { browser } from "$app/environment";
import type { B_NAV_T } from "@betarena/scores-lib/types/navbar.js";
$: ({ serverLang } = $sessionStore);
$: [preferedPage] = $userBetarenaSettings.user?.scores_user_data
?.buttons_order || ["scores"];
$: trsanslationData = $page.data.B_NAV_T as B_NAV_T | null | undefined;
let isRedirect = false;
$: {
let url = $page.url.pathname;
switch (preferedPage) {
Expand All @@ -59,27 +60,24 @@
break;
case "content":
url =
trsanslationData?.scores_header_translations?.section_links
?.sports_content_url;
trsanslationData?.scores_header_translations?.section_links
?.sports_content_url;
break;
case "scores":
case "scores":
default:
url = `/${serverLang === "en" ? "" : `${serverLang}/`}scores`;
}
if (!isRedirect) {
goto(url);
isRedirect = true;
}
}
if (browser) {
goto(url);
}
}
// #endregion ➤ 📦 Package Imports
</script>

<section />


<style>
section {
height: 100%;
}
</style>

2 changes: 1 addition & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@
// ╰─────
$: if (browser) {
_DEBUG_("Option1");
mainDeepLinkCheck();
userBetarenaSettings.useLocalStorage();
scoresAdminStore.useLocalStorage();
mainDeepLinkCheck();
}
// ╭─────
Expand Down

0 comments on commit a003dda

Please sign in to comment.