Skip to content

Commit

Permalink
fix:conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus-Senna committed Sep 25, 2023
2 parents 17d6708 + bab4310 commit 64bf4bb
Show file tree
Hide file tree
Showing 38 changed files with 2,239 additions and 1,626 deletions.
3 changes: 3 additions & 0 deletions apps/app/components/atoms/AppIconButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const apps: { [key: string]: { url: string } } = {
solidity: {
url: "https://soliditylang.org/?utm_source=menthor.io",
},
html: {
url: "https://developer.mozilla.org/pt-BR/docs/Web/HTML?utm_source=menthor.io",
},
};
</script>

Expand Down
7 changes: 6 additions & 1 deletion apps/app/components/content/ProseA.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ defineProps({
</script>

<template>
<NuxtLink :href="href" target="_blank" external>
<NuxtLink
:href="href"
target="_blank"
external
class="font-bold border-b border-pink-500 hover:border-b-[2px]"
>
<slot />
</NuxtLink>
</template>
5 changes: 5 additions & 0 deletions apps/app/components/content/ProseUl.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<ol class="list-disc list-inside">
<slot />
</ol>
</template>
1 change: 0 additions & 1 deletion apps/app/components/molecules/EnrollmentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const redirectUri = computed(() => {
function openDiscordOAuth() {
localStorage.setItem("m-discord-role", course.discordRole);
console.log({ redirectUri });
const discordUrl = `https://discord.com/api/oauth2/authorize?client_id=1125151922958106734&redirect_uri=${encodeURIComponent(
redirectUri.value
)}&response_type=code&scope=identify%20email`;
Expand Down
17 changes: 15 additions & 2 deletions apps/app/components/molecules/SearchModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { ParsedContent } from "../../../../node_modules/@nuxt/content/dist/runtime/types";
import { useDebounceFn } from "@vueuse/core";
import { useMagicKeys } from "@vueuse/core";
const { escape } = useMagicKeys();
Expand All @@ -23,7 +24,7 @@ function resetNavigatedIndex() {
}
const searchModalStore = useSearchModalStore();
const loading = ref(false);
const search = ref(null);
const { data: coursesAndCategories } = await useAsyncData(
Expand Down Expand Up @@ -62,6 +63,11 @@ function resetSearch() {
});
}
const searchDebounce = useDebounceFn(() => {
searchContent();
loading.value = false;
}, 1000);
async function searchContent() {
resetNavigatedIndex();
if (String(search.value).length <= 0) {
Expand Down Expand Up @@ -130,11 +136,18 @@ watch(searchModalStore, async (newValue) => {
ref="searchInput"
type="search"
v-model="search"
@input="searchContent"
@input="
loading = true;
searchDebounce();
"
autocomplete="off"
placeholder="Pesquise aulas ou escreva um comando..."
class="mb-3 block w-full pt-2 text-base font-medium text-zinc-950 !outline-none placeholder:text-zinc-500"
/>
<MSpinner
v-if="loading"
class="absolute top-[24px] right-[24px] w-[14px] h-[14px] border-zinc-400"
/>
<div class="flex items-center text-sm">
<div class="flex flex-1 items-center gap-2 text-zinc-700">
<Command icon="arrow-up" />
Expand Down
13 changes: 3 additions & 10 deletions apps/app/components/molecules/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ const router = useRouter();
const sessionStore = useSessionStore();
const userStore = useUserStore();
const defaultAsideStore = useDefaultAsideStore();
function signOut() {
sessionStore.signOut();
router.push("/sign-in");
}
</script>

<template>
Expand Down Expand Up @@ -58,11 +53,9 @@ function signOut() {
<NuxtLink to="/profile">
<DropdownItem icon="circle-user" name="Perfil" />
</NuxtLink>
<DropdownItem
icon="arrow-right-from-bracket"
name="Sair"
@click="signOut"
/>
<NuxtLink to="/sign-out">
<DropdownItem icon="arrow-right-from-bracket" name="Sair" />
</NuxtLink>
</div>
</template>
</VDropdown>
Expand Down
6 changes: 5 additions & 1 deletion apps/app/components/organisms/DefaultAside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const queryBuilder = computed(() => {
return queryContent(`/${route.params?.slug ? route.params.slug[0] : ""}`);
});
const { data: navigation } = await useAsyncData(
const { data: navigation, refresh } = await useAsyncData(
route.params?.slug ? route.params.slug[0] : "navigation",
() => fetchContentNavigation(queryBuilder.value),
{
Expand All @@ -18,6 +18,10 @@ const { data: navigation } = await useAsyncData(
const isLesson = computed(() => {
return !!route.meta?.lesson;
});
watch(isLesson, async () => {
refresh();
});
</script>

<template>
Expand Down
67 changes: 67 additions & 0 deletions apps/app/composables/useCodeInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
export function useCodeInput(code: string[]) {
let dataFromPaste: string[] | undefined;

const keysAllowed: string[] = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
];

function isNumber(event: Event) {
(event.currentTarget as HTMLInputElement).value = "";
const keyPressed: string = (event as KeyboardEvent).key;
if (!keysAllowed.includes(keyPressed)) {
event.preventDefault();
}
}
function handleInput(event: Event) {
const inputType = (event as InputEvent).inputType;
let currentActiveElement = event.target as HTMLInputElement;

if (inputType === "insertText")
(currentActiveElement.nextElementSibling as HTMLElement)?.focus();

if (inputType === "insertFromPaste" && dataFromPaste) {
for (const num of dataFromPaste) {
const id: number = parseInt(currentActiveElement.id.split("_")[1]);
currentActiveElement.value = num;
code[id] = num;
if (currentActiveElement.nextElementSibling) {
currentActiveElement =
currentActiveElement.nextElementSibling as HTMLInputElement;
(currentActiveElement.nextElementSibling as HTMLElement)?.focus();
}
}
}
}
function handleDelete(event: Event) {
// keydown event = move to previous element then only delete number

const value = (event.target as HTMLInputElement).value;
const currentActiveElement = event.target as HTMLInputElement;
if (!value)
(currentActiveElement.previousElementSibling as HTMLElement)?.focus();
}

function onPaste(event: Event) {
dataFromPaste = (event as ClipboardEvent).clipboardData
?.getData("text")
.trim()
.split("");

if (dataFromPaste) {
for (const num of dataFromPaste) {
if (!keysAllowed.includes(num)) event.preventDefault();
}
}
}

return { isNumber, handleInput, handleDelete, onPaste };
}
10 changes: 10 additions & 0 deletions apps/app/composables/useCookieFetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { appendResponseHeader, H3Event } from "h3";

export const useCookieFetch = async (event: H3Event, url: string) => {
const res = await $fetch.raw(url);
const cookies = (res.headers.get("set-cookie") || "").split(",");
for (const cookie of cookies) {
appendResponseHeader(event, "set-cookie", cookie);
}
return res._data;
};
3 changes: 3 additions & 0 deletions apps/app/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
const userStore = useUserStore();
const sessionStore = useSessionStore();
const defaultAsideStore = useDefaultAsideStore();
sessionStore.refreshSession();
const content = ref();
const nuxtApp = useNuxtApp();
nuxtApp.hook("page:finish", () => {
if (!content.value) return;
content.value.scrollTo({
top: 0,
behavior: "smooth",
Expand Down
14 changes: 7 additions & 7 deletions apps/app/middleware/session.global.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export default defineNuxtRouteMiddleware(async (to) => {
if (to.query.oauth) return;

const sessionStore = useSessionStore();
const userStore = useUserStore();
const serverUser = useCookie("m-user");

const userCookie: Ref<typeof userStore.user> = useCookie("m-user");
if (userCookie.value) {
userStore.user = userCookie.value;
if (serverUser) {
userStore.user = serverUser.value as typeof userStore.user;
}

const serverHasSession = userCookie.value || sessionStore.hasSession();
if (to.query.oauth) return;

const sessionStore = useSessionStore();
const serverHasSession = !!serverUser.value || sessionStore.hasSession();

if (["profile"].includes(String(to.name)) && !serverHasSession) {
return navigateTo("/sign-in");
Expand Down
2 changes: 1 addition & 1 deletion apps/app/modules/eslint-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const autoImportEslint = defineNuxtModule({
getContents,
write: true,
});
console.log(`globals file is generated at ${fullPath}`);
// console.log(`globals file is generated at ${fullPath}`);
});
},
});
Expand Down
1 change: 0 additions & 1 deletion apps/app/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default defineNuxtConfig({
"nuxt-schema-org",
"@nuxtjs/fontaine",
"@nuxt/content",
"@vueuse/nuxt",
"@pinia/nuxt",
],
vite: {
Expand Down
9 changes: 5 additions & 4 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"postinstall": "nuxt prepare"
},
"devDependencies": {
"@nuxt/content": "^2.7.2",
"@nuxt/content": "npm:@nuxt/content-edge@latest",
"@nuxtjs/fontaine": "^0.2.5",
"@types/node": "^20.4.6",
"nuxt": "3.5.3",
"nuxt": "^3.7.3",
"nuxt-schema-org": "^2.1.3",
"typescript": "^5.1.6"
},
Expand All @@ -27,14 +27,15 @@
"@fortawesome/vue-fontawesome": "^3.0.3",
"@nuxt/image-edge": "1.0.0-rc.2-28246613.7d120ca",
"@pinia/nuxt": "^0.4.11",
"@vueuse/nuxt": "^10.3.0",
"@vueuse/core": "^10.3.0",
"@vueuse/integrations": "^10.3.0",
"eslint-config-custom": "workspace:*",
"floating-vue": "2.0.0-beta.24",
"nuxt-simple-sitemap": "^3.1.4",
"nuxt-umami": "^2.5.2",
"pinia": "^2.1.6",
"splitpanes": "^3.1.5",
"tailwind-config": "workspace:*",
"unstorage": "^1.8.0"
"universal-cookie": "^4.0.4"
}
}
7 changes: 5 additions & 2 deletions apps/app/pages/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ onMounted(async () => {
/>
<TaskModal :current-lesson="currentLesson" @next="redirectToNextLesson" />

<div class="mb-10 flex flex-wrap items-center gap-6 px-6 sm:px-8">
<div
v-if="currentCourse"
class="mb-10 flex flex-wrap items-center gap-6 px-6 sm:px-8"
>
<div
class="h-[160px] w-[160px] min-w-[160px] overflow-hidden rounded shadow-lg"
>
Expand All @@ -97,7 +100,7 @@ onMounted(async () => {
<div
class="mb-2 w-fit rounded-full bg-zinc-900 px-3 py-[2px] text-xs font-medium text-white"
>
{{ $filters.level(currentCourse.level) }}
{{ $filters?.level(currentCourse?.level) }}
</div>
<h1 class="text-3xl font-extrabold">
{{ currentCourse.title }}
Expand Down
64 changes: 3 additions & 61 deletions apps/app/pages/code.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,9 @@ const router = useRouter();
const toast: { error: Function } | undefined = inject("toast");
let code: string[] = Array(6);
let dataFromPaste: string[] | undefined;
const keysAllowed: string[] = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
];
function isNumber(event: Event) {
(event.currentTarget as HTMLInputElement).value = "";
const keyPressed: string = (event as KeyboardEvent).key;
if (!keysAllowed.includes(keyPressed)) {
event.preventDefault();
}
}
function handleInput(event: Event) {
const inputType = (event as InputEvent).inputType;
let currentActiveElement = event.target as HTMLInputElement;
if (inputType === "insertText")
(currentActiveElement.nextElementSibling as HTMLElement)?.focus();
if (inputType === "insertFromPaste" && dataFromPaste) {
for (const num of dataFromPaste) {
let id: number = parseInt(currentActiveElement.id.split("_")[1]);
currentActiveElement.value = num;
code[id] = num;
if (currentActiveElement.nextElementSibling) {
currentActiveElement =
currentActiveElement.nextElementSibling as HTMLInputElement;
(currentActiveElement.nextElementSibling as HTMLElement)?.focus();
}
}
}
}
function handleDelete(event: Event) {
//keydown event = move to previous element then only delete number
const { isNumber, handleInput, handleDelete, onPaste } = useCodeInput(code);
let value = (event.target as HTMLInputElement).value;
let currentActiveElement = event.target as HTMLInputElement;
if (!value)
(currentActiveElement.previousElementSibling as HTMLElement)?.focus();
}
function onPaste(event: Event) {
dataFromPaste = (event as ClipboardEvent).clipboardData
?.getData("text")
.trim()
.split("");
if (dataFromPaste) {
for (const num of dataFromPaste) {
if (!keysAllowed.includes(num)) event.preventDefault();
}
}
}
async function sendCode() {
loading.value = true;
Expand All @@ -83,7 +24,8 @@ async function sendCode() {
code: code.join(""),
});
userStore.setUser();
sessionStore.refreshSession();
await sessionStore.refreshSession();
router.push("/");
} catch (e) {
toast?.error("Código incorreto ou expirado.");
Expand Down
Loading

0 comments on commit 64bf4bb

Please sign in to comment.