From e998e71195be7d31cc97ec1a6a6107e40cb72e48 Mon Sep 17 00:00:00 2001 From: Claus Haas Date: Wed, 24 Jul 2024 17:30:33 -0300 Subject: [PATCH 1/3] bump package versions --- package-lock.json | 48 +++++++++++++++++++++++------------------------ package.json | 12 ++++++------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80f41fd..8a2c86e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "@aws-sdk/client-cognito-identity-provider": "^3.616.0", "@aws-sdk/client-secrets-manager": "^3.616.0", "@aws-sdk/client-sesv2": "^3.616.0", - "@aws-sdk/credential-providers": "^3.616.0", + "@aws-sdk/credential-providers": "^3.617.0", "@cloudflare/stream-react": "^1.9.1", "@epic-web/remember": "^1.1.0", "@heroicons/react": "^2.1.5", @@ -33,7 +33,7 @@ "axios": "^1.7.2", "clipboard-copy": "^4.0.1", "express": "^4.19.2", - "framer-motion": "^11.3.8", + "framer-motion": "^11.3.17", "fuse.js": "^7.0.0", "helmet": "^7.1.0", "hls.js": "^1.5.13", @@ -47,7 +47,7 @@ "quill-delta-to-html": "^0.12.1", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-phone-number-input": "^3.4.3", + "react-phone-number-input": "^3.4.4", "react-select": "^5.8.0", "remix-create-express-app": "^0.4.4", "remix-utils": "^7.6.0", @@ -67,18 +67,18 @@ "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", "lightningcss": "^1.25.1", - "postcss": "^8.4.39", + "postcss": "^8.4.40", "remix-development-tools": "^4.2.2", "remix-express-dev-server": "^0.4.4", "tailwindcss": "^3.4.6", "tailwindcss-radix": "^3.0.3", "tailwindcss-radix-colors": "^1.3.1", "tsx": "^4.16.2", - "typescript": "^5.5.3", + "typescript": "^5.5.4", "vite": "^5.3.4", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.3.2", - "xo": "^0.59.0" + "xo": "^0.59.2" }, "engines": { "node": ">=20.15.1" @@ -739,9 +739,9 @@ } }, "node_modules/@aws-sdk/credential-providers": { - "version": "3.616.0", - "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.616.0.tgz", - "integrity": "sha512-uyscpYV21lr24FNFu8ZkIKzOCD/xoysRci9HmShtKBY/FixwZRlLv7aUpqH7xcLd7sgsQwa2UD/7s9PKj/DXSg==", + "version": "3.617.0", + "resolved": "https://registry.npmjs.org/@aws-sdk/credential-providers/-/credential-providers-3.617.0.tgz", + "integrity": "sha512-ZXzdnHI7Tfsk7Y2hezlhxFHlG2VM5tTWQPZ0qZ/cYCzZxyZfsmSFr/rMi6wJGB2J6ZDbbAohEoOWrEblHVq7Cw==", "dependencies": { "@aws-sdk/client-cognito-identity": "3.616.0", "@aws-sdk/client-sso": "3.616.0", @@ -12749,9 +12749,9 @@ } }, "node_modules/framer-motion": { - "version": "11.3.8", - "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.3.8.tgz", - "integrity": "sha512-1D+RDTsIp4Rz2dq/oToqSEc9idEQwgBRQyBq4rGpFba+0Z+GCbj9z1s0+ikFbanWe3YJ0SqkNlDe08GcpFGj5A==", + "version": "11.3.17", + "resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-11.3.17.tgz", + "integrity": "sha512-LZcckvZL8Rjod03bud8LQcp+R0PLmWIlOSu+NVc+v6Uh43fQr4IBsEAX7sSn7CdBQ1L0fZ/IqSXZVPnGFSMxHw==", "dependencies": { "tslib": "^2.4.0" }, @@ -17040,9 +17040,9 @@ } }, "node_modules/postcss": { - "version": "8.4.39", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.39.tgz", - "integrity": "sha512-0vzE+lAiG7hZl1/9I8yzKLx3aR9Xbof3fBHKunvMfOCYAtMhrsnccJY2iTURb9EZd5+pLuiNV9/c/GZJOHsgIw==", + "version": "8.4.40", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.40.tgz", + "integrity": "sha512-YF2kKIUzAofPMpfH6hOi2cGnv/HrUlfucspc7pDyvv7kGdqXrfj8SCl/t8owkEgKEuu8ZcRjSOxFxVLqwChZ2Q==", "funding": [ { "type": "opencollective", @@ -17616,9 +17616,9 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, "node_modules/react-phone-number-input": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/react-phone-number-input/-/react-phone-number-input-3.4.3.tgz", - "integrity": "sha512-n0dD9V1T8EWeRoGwVMcNK6bwOdEbIk0U3EQ87K0WTADgyJZUJd9NIQMmpcl9mtWSL+LwPaEMzre0yGkhwZYTzg==", + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/react-phone-number-input/-/react-phone-number-input-3.4.4.tgz", + "integrity": "sha512-zeyZeS1Iazhj3vTHj6qOyTTguBf/WFLAe9OtA8s0Itycy7AOoQI0vFlpxKDaEcyvYup7Wt79lKu+nl/nJwyLdw==", "dependencies": { "classnames": "^2.5.1", "country-flag-icons": "^1.5.11", @@ -20383,9 +20383,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", - "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -21769,9 +21769,9 @@ } }, "node_modules/xo": { - "version": "0.59.0", - "resolved": "https://registry.npmjs.org/xo/-/xo-0.59.0.tgz", - "integrity": "sha512-SBYYsZahFkdKKuz53Y3szikIfyAk1EVQimdwwXbxXKh35vwq7OEZWuezPda2wWizYGnJ7ZVfNxem4qc+BI60rg==", + "version": "0.59.2", + "resolved": "https://registry.npmjs.org/xo/-/xo-0.59.2.tgz", + "integrity": "sha512-sg7MEgQp/I7KW8ssUdTsO0JmOjppPWx3m3y1/T0r5lQY9n4UAUjF2zuPX/C0IcwrNwFpdHoSYcbHUdGEmWUFmw==", "dev": true, "dependencies": { "@eslint/eslintrc": "^3.1.0", diff --git a/package.json b/package.json index b07461e..2f2bf2d 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "@aws-sdk/client-cognito-identity-provider": "^3.616.0", "@aws-sdk/client-secrets-manager": "^3.616.0", "@aws-sdk/client-sesv2": "^3.616.0", - "@aws-sdk/credential-providers": "^3.616.0", + "@aws-sdk/credential-providers": "^3.617.0", "@cloudflare/stream-react": "^1.9.1", "@epic-web/remember": "^1.1.0", "@heroicons/react": "^2.1.5", @@ -58,7 +58,7 @@ "axios": "^1.7.2", "clipboard-copy": "^4.0.1", "express": "^4.19.2", - "framer-motion": "^11.3.8", + "framer-motion": "^11.3.17", "fuse.js": "^7.0.0", "helmet": "^7.1.0", "hls.js": "^1.5.13", @@ -72,7 +72,7 @@ "quill-delta-to-html": "^0.12.1", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-phone-number-input": "^3.4.3", + "react-phone-number-input": "^3.4.4", "react-select": "^5.8.0", "remix-create-express-app": "^0.4.4", "remix-utils": "^7.6.0", @@ -92,18 +92,18 @@ "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", "lightningcss": "^1.25.1", - "postcss": "^8.4.39", + "postcss": "^8.4.40", "remix-development-tools": "^4.2.2", "remix-express-dev-server": "^0.4.4", "tailwindcss": "^3.4.6", "tailwindcss-radix": "^3.0.3", "tailwindcss-radix-colors": "^1.3.1", "tsx": "^4.16.2", - "typescript": "^5.5.3", + "typescript": "^5.5.4", "vite": "^5.3.4", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.3.2", - "xo": "^0.59.0" + "xo": "^0.59.2" }, "prisma": { "seed": "tsx ./prisma/seed.ts" From 694d59b147e417fdcf2aa63c7a96e6969cd9e33e Mon Sep 17 00:00:00 2001 From: Claus Haas Date: Wed, 24 Jul 2024 18:18:38 -0300 Subject: [PATCH 2/3] add lesson duration filters --- .../courses.$course-slug.$module-slug_.tsx | 215 ++++++++++++------ 1 file changed, 140 insertions(+), 75 deletions(-) diff --git a/app/routes/courses.$course-slug.$module-slug_.tsx b/app/routes/courses.$course-slug.$module-slug_.tsx index 31c00e3..2f8b29e 100644 --- a/app/routes/courses.$course-slug.$module-slug_.tsx +++ b/app/routes/courses.$course-slug.$module-slug_.tsx @@ -47,7 +47,7 @@ export const loader = defineLoader(async ({request, params}: LoaderFunctionArgs) const url = new URL(request.url); - const appliedTags = [...url.searchParams.entries()].filter(([key]) => key === 'Dificuldade' || key === 'Técnicas' || key === 'Ênfase'); + const appliedTags = [...url.searchParams.entries()].filter(([key]) => key === 'Duração' || key === 'Dificuldade' || key === 'Técnicas' || key === 'Ênfase'); const pageString = url.searchParams.get('page'); const page = (pageString && !Number.isNaN(pageString)) ? Number(pageString) : 1; @@ -101,7 +101,7 @@ export default function Module() { const navigate = useNavigate(); const {search} = useLocation(); - const queriesArray = decodeURI(search).slice(1).split('&').filter(query => !query.includes('page')); + const queriesArray = decodeURI(search).slice(1).split('&').filter(query => !query.includes('page') && query !== ''); const [filterQueries, setFilterQueries] = useState(queriesArray); const [isFilterMenuOpen, setIsFilterMenuOpen] = useState(false); @@ -171,88 +171,153 @@ export default function Module() { - {module.lessons.length > 0 && ( -
-
-

Aulas

- - {tags && tags.length > 0 && module.module.showTagsFilters && ( - - - -

Filtros

- -
-
- - - -
Selecione as opções e clique em aplicar filtros:
- - {tags.map(tag => ( -
-

{tag.tagOption}

- - {tag.tagValues.map(tagValue => ( -
- { - onFilterChange(`${tag.tagOption}=${tagValue}`, event); - })} - > - - -

{tagValue}

-
- ))} -
- ))} - -
-
+ + +
+
+
+ )} +
+ +
+ {module.lessons.length > 0 + ? (module.lessons as unknown as TLessonDataForCache[]).map(lesson => ( ({...accumulator, ...activity}), {})[lesson.lesson.slug] ?? undefined} /> - ))} -
- {module.pages > 1 && } -
- )} + )) + :

Nenhuma aula encontrada

} + + + {module.pages > 1 && } + From d07f6b5de269991be81d23a6875f77357c5d5f9c Mon Sep 17 00:00:00 2001 From: Claus Haas Date: Wed, 24 Jul 2024 18:37:33 -0300 Subject: [PATCH 3/3] fix duration filter --- app/services/module.service.server.ts | 51 ++++++++++++++++++++------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/services/module.service.server.ts b/app/services/module.service.server.ts index 53d701a..d1488a3 100644 --- a/app/services/module.service.server.ts +++ b/app/services/module.service.server.ts @@ -285,20 +285,47 @@ export class ModuleService { return accumulator; }, []); - const lessons = allModuleLessons - .filter(lesson => { - if (appliedTags.length === 0) { - return true; + const durationTagsTest = (value: number, lessonDuration: number) => { + switch (value) { + case 1: { + return lessonDuration <= 30; } - return organizedTags.every(tagObject => - Object.entries(tagObject).every(([key, values]) => - lesson.lesson.tags.some(tag => - tag.tagOptionName === key && values.includes(tag.tagValueName), - ), - ), - ); - }); + case 2: { + return lessonDuration >= 31 && lessonDuration <= 50; + } + + case 3: { + return lessonDuration >= 51 && lessonDuration <= 70; + } + + case 4: { + return lessonDuration >= 71; + } + + default: { + return false; + } + } + }; + + const lessons = allModuleLessons.filter(lesson => { + if (appliedTags.length === 0) { + return true; + } + + return organizedTags.every(tagObject => + Object.entries(tagObject).every(([key, values]) => { + if (key === 'Duração') { + return values.some(value => durationTagsTest(Number(value), lesson.lesson.duration ?? 500)); + } + + return lesson.lesson.tags.some(tag => + tag.tagOptionName === key && values.includes(tag.tagValueName), + ); + }), + ); + }); module.pages = Math.ceil(lessons.length / 16);