Skip to content

Commit

Permalink
Format and lint, remove unecessary files
Browse files Browse the repository at this point in the history
  • Loading branch information
Erwan Dano authored and Erwan Dano committed Mar 25, 2024
1 parent 675cbbe commit 6ae44f5
Show file tree
Hide file tree
Showing 61 changed files with 1,719 additions and 1,666 deletions.
76 changes: 40 additions & 36 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
<script setup lang="ts">
import NavbarSection from '@/components/NavbarSection.vue'
import { onBeforeMount, onMounted } from 'vue'
import { userPreferenceStore } from './store/userPreferences'
import { useI18n } from 'vue-i18n'
import { RouterView } from 'vue-router'
import { type DaisyThemes, useThemeManager, daisyThemes } from '@/plugins/themeManager'
import * as tsSdk from './helpers/tsSdk'
import { ref } from 'vue'
import { loadSession } from './helpers/session'
import NavbarSection from "@/components/NavbarSection.vue";
import { onBeforeMount, onMounted } from "vue";
import { userPreferenceStore } from "./store/userPreferences";
import { useI18n } from "vue-i18n";
import { RouterView } from "vue-router";
import {
type DaisyThemes,
useThemeManager,
daisyThemes,
} from "@/plugins/themeManager";
import * as tsSdk from "./helpers/tsSdk";
import { ref } from "vue";
import { loadSession } from "./helpers/session";
const preference = userPreferenceStore()
const i18n = useI18n()
const $theme = useThemeManager()
const platformLoading = ref(true)
const sessionLoading = ref(true)
const preference = userPreferenceStore();
const i18n = useI18n();
const $theme = useThemeManager();
const platformLoading = ref(true);
const sessionLoading = ref(true);
onBeforeMount(() => {
// Add a script tag to the page to download the ts-platform sdk
// https://developer.transmitsecurity.com/guides/risk/quick_start_web/#step-2-load-sdk
const platformScript = document.createElement('script')
platformScript.src = import.meta.env.VITE_PLATFORM_SDK_URL
platformScript.defer = true
platformScript.id = 'ts-platform-script'
document.head.appendChild(platformScript)
const platformScript = document.createElement("script");
platformScript.src = import.meta.env.VITE_PLATFORM_SDK_URL;
platformScript.defer = true;
platformScript.id = "ts-platform-script";
document.head.appendChild(platformScript);
// Then, initialize the ts-platform sdk
tsSdk.initWhenLoaded()
tsSdk.initWhenLoaded();
// The ts platform SDK is not loaded yet, we need to wait
// for it to be loaded and then initialize the app
// this is necessary to perform a silent risk based user authentication
document.addEventListener('tsPlatformLoaded', async function (e) {
platformLoading.value = false
await loadSession()
document.addEventListener("tsPlatformLoaded", async function (e) {
platformLoading.value = false;
await loadSession();
// Dispatch an event indicating that the session was loaded
// when the session is loaded the app is displayed
const event = new CustomEvent('sessionLoaded')
document.dispatchEvent(event)
console.log('Session loading attempt done')
})
const event = new CustomEvent("sessionLoaded");
document.dispatchEvent(event);
console.log("Session loading attempt done");
});
// The session is not loaded yet, we need to wait
// this is necessary to perform a silent risk based user authentication
document.addEventListener('sessionLoaded', function (e) {
sessionLoading.value = false
})
})
document.addEventListener("sessionLoaded", function (e) {
sessionLoading.value = false;
});
});
onMounted(() => {
// Set the language based on saved preferences
if (preference.language !== '' && i18n.locale.value !== preference.language)
i18n.locale.value = preference.language
if (preference.language !== "" && i18n.locale.value !== preference.language)
i18n.locale.value = preference.language;
// Set the theme based on the .env configuration or saved preferences
const theme = preference.theme || import.meta.env.VITE_THEME || 'breeze'
$theme.set(theme as DaisyThemes)
})
const theme = preference.theme || import.meta.env.VITE_THEME || "breeze";
$theme.set(theme as DaisyThemes);
});
</script>

<template>
Expand Down
4 changes: 2 additions & 2 deletions src/assets/google-material.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.material-icons {
font-family: 'Material Icons';
font-family: "Material Icons";
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
Expand All @@ -20,5 +20,5 @@
-moz-osx-font-smoothing: grayscale;

/* Support for IE. */
font-feature-settings: 'liga';
font-feature-settings: "liga";
}
4 changes: 2 additions & 2 deletions src/assets/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import './base.css';
@import './google-material.css';
@import "./base.css";
@import "./google-material.css";

#app {
max-width: 1280px;
Expand Down
4 changes: 2 additions & 2 deletions src/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ html {
/* Lines - steps visited */
.steps.shop-steps li.step.step-primary:before {
/* Display first line */
content: ' ' !important;
content: " " !important;
--tw-bg-opacity: 1;
background-color: hsl(var(--p) / var(--tw-bg-opacity));
--tw-text-opacity: 1;
Expand All @@ -78,7 +78,7 @@ html {

.steps.shop-steps li.step.step-primary:first-child:before {
/* Display first line */
content: ' ' !important;
content: " " !important;
--tw-bg-opacity: 1;
background-color: hsl(var(--p) / var(--tw-bg-opacity));
--tw-text-opacity: 1;
Expand Down
15 changes: 10 additions & 5 deletions src/components/FooterSection.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<script setup lang="ts">
import LogoOnPrimary from '@/components/logo/LogoOnPrimary.vue'
import LogoOnPrimary from "@/components/logo/LogoOnPrimary.vue";
</script>
<template>
<footer class="bg-primary text-primary-content">
<div class="container px-6 py-8 mx-auto space-y-8 md:space-y-0 md:flex md:justify-between">
<div
class="container px-6 py-8 mx-auto space-y-8 md:space-y-0 md:flex md:justify-between"
>
<div>
<a class="flex flex-start" href="#">
<logo-on-primary />
</a>

<p class="max-w-lg mt-6 leading-relaxed">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt voluptatum amet
molestiae consequatur quam velit sint modi aut illo dolorem.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt
voluptatum amet molestiae consequatur quam velit sint modi aut illo
dolorem.
</p>
</div>

Expand Down Expand Up @@ -124,7 +127,9 @@ import LogoOnPrimary from '@/components/logo/LogoOnPrimary.vue'
</div>
</div>

<p class="w-full py-6 mx-auto text-primary-content text-center bg-primary-focus">
<p
class="w-full py-6 mx-auto text-primary-content text-center bg-primary-focus"
>
&copy; 2023 Acme. All rights reserved.
</p>
</footer>
Expand Down
35 changes: 22 additions & 13 deletions src/components/NavbarSection.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<script setup lang="ts">
import { MagnifyingGlassIcon, BellIcon, ArrowLeftOnRectangleIcon } from '@heroicons/vue/24/outline'
import { UserCircleIcon } from '@heroicons/vue/24/solid'
import { userSessionStore } from '@/store/userSession'
import { logout } from '@/helpers/session'
import LogoOnBase from './logo/LogoOnBase.vue'
import { storeToRefs } from 'pinia'
import {
MagnifyingGlassIcon,
BellIcon,
ArrowLeftOnRectangleIcon,
} from "@heroicons/vue/24/outline";
import { UserCircleIcon } from "@heroicons/vue/24/solid";
import { userSessionStore } from "@/store/userSession";
import { logout } from "@/helpers/session";
import LogoOnBase from "./logo/LogoOnBase.vue";
import { storeToRefs } from "pinia";
const userSession = userSessionStore()
const userSessionRefs = storeToRefs(userSession)
const { fullName } = userSessionRefs
const userSession = userSessionStore();
const userSessionRefs = storeToRefs(userSession);
const { fullName } = userSessionRefs;
</script>
<template>
<div class="navbar bg-base-200 text-base-content">
Expand Down Expand Up @@ -36,7 +40,9 @@ const { fullName } = userSessionRefs

<!-- Login button or profile dropdown -->
<div v-if="!userSession.isAuthenticated" class="pr-4">
<router-link :to="{ name: 'login' }">{{ $t('authentication.login') }}</router-link>
<router-link :to="{ name: 'login' }">{{
$t("authentication.login")
}}</router-link>
</div>
<div class="dropdown dropdown-end min-w-max" v-else>
<label tabindex="0" class="btn btn-ghost btn-circle avatar">
Expand All @@ -50,14 +56,17 @@ const { fullName } = userSessionRefs
{{ fullName }}
</li>
<li>
<router-link :to="{ name: 'accountProfile' }" class="justify-between pr-24">
{{ $t('menu.profile') }}
<router-link
:to="{ name: 'accountProfile' }"
class="justify-between pr-24"
>
{{ $t("menu.profile") }}
</router-link>
</li>
<li>
<a @click="logout"
><arrow-left-on-rectangle-icon class="w-4 h-4" />
<span>{{ $t('authentication.logout') }}</span>
<span>{{ $t("authentication.logout") }}</span>
</a>
</li>
</ul>
Expand Down
18 changes: 13 additions & 5 deletions src/components/NotFoundPage.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<template>
<main class="min-h-screen w-full flex flex-col justify-center items-center bg-base-100 not-found">
<h1 class="text-9xl font-extrabold text-base-content tracking-widest">404</h1>
<div class="px-2 text-sm rounded rotate-12 absolute bg-error text-error-content">
<main
class="min-h-screen w-full flex flex-col justify-center items-center bg-base-100 not-found"
>
<h1 class="text-9xl font-extrabold text-base-content tracking-widest">
404
</h1>
<div
class="px-2 text-sm rounded rotate-12 absolute bg-error text-error-content"
>
<slot>
{{ $t('global.pageNotFound') }}
{{ $t("global.pageNotFound") }}
</slot>
</div>
<button class="mt-5 px-8 btn btn-primary">
<router-link :to="{ name: 'home' }">{{ $t('global.goHome') }}</router-link>
<router-link :to="{ name: 'home' }">{{
$t("global.goHome")
}}</router-link>
</button>
</main>
</template>
30 changes: 19 additions & 11 deletions src/components/account/AccountMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
*
* Lists the different sub menus the user can access
*/
import { UserCircleIcon, Cog8ToothIcon } from '@heroicons/vue/24/outline'
import { UserCircleIcon, Cog8ToothIcon } from "@heroicons/vue/24/outline";
import AccountMenuButton from '@/components/account/AccountMenuButton.vue'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { ref } from 'vue'
import AccountMenuButton from "@/components/account/AccountMenuButton.vue";
import { useRoute } from "vue-router";
import { useI18n } from "vue-i18n";
import { ref } from "vue";
const { t } = useI18n()
const route = useRoute()
const { t } = useI18n();
const route = useRoute();
const menuRoutes = ref([
{ title: t('menu.profile'), icon: UserCircleIcon, routeName: 'accountProfile' },
{ title: t('menu.account'), icon: Cog8ToothIcon, routeName: 'accountSettings' },
])
{
title: t("menu.profile"),
icon: UserCircleIcon,
routeName: "accountProfile",
},
{
title: t("menu.account"),
icon: Cog8ToothIcon,
routeName: "accountSettings",
},
]);
function accountRouteSelected(routeName: string) {
return route.name === routeName
return route.name === routeName;
}
</script>
<template>
Expand Down
35 changes: 18 additions & 17 deletions src/components/account/AccountMenuButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@
/**
* Link to a sub menu, used in the AccountMenu component
*/
import { computed, toRefs } from 'vue'
import type { FunctionalComponent, HTMLAttributes, VNodeProps } from 'vue'
import { computed, toRefs } from "vue";
import type { FunctionalComponent, HTMLAttributes, VNodeProps } from "vue";
const props = withDefaults(
defineProps<{
title: string
icon: FunctionalComponent<HTMLAttributes & VNodeProps, {}, any>
routeName: string
selected?: boolean
title: string;
icon: FunctionalComponent<HTMLAttributes & VNodeProps, {}, any>;
routeName: string;
selected?: boolean;
}>(),
{ selected: false },
)
{ selected: false }
);
const { title, icon, selected, routeName } = toRefs(props)
const { title, icon, selected, routeName } = toRefs(props);
const selectedLinkClass =
'bg-primary/5 border-primary-focus text-primary hover:bg-primary/10 hover:text-primary-focus'
const normalLinkClass = 'text-base-content/50 hover:bg-base-200 hover:text-base-content/70'
const selectedIconClass = 'group-hover:text-primary-focus'
const normalIconClass = 'text-base-content/50 group-hover:text-base-content/70'
"bg-primary/5 border-primary-focus text-primary hover:bg-primary/10 hover:text-primary-focus";
const normalLinkClass =
"text-base-content/50 hover:bg-base-200 hover:text-base-content/70";
const selectedIconClass = "group-hover:text-primary-focus";
const normalIconClass = "text-base-content/50 group-hover:text-base-content/70";
const linkClass = computed(() => {
return selected.value ? selectedLinkClass : normalLinkClass
})
return selected.value ? selectedLinkClass : normalLinkClass;
});
const iconClass = computed(() => {
return selected.value ? selectedIconClass : normalIconClass
})
return selected.value ? selectedIconClass : normalIconClass;
});
</script>
<template>
<router-link
Expand Down
Loading

0 comments on commit 6ae44f5

Please sign in to comment.