From c2e98a5aca2a9d1db4666515b2175add00183dfe Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Sep 2024 23:09:58 -0300 Subject: [PATCH 1/4] feat(#78): Progresso da Trilha MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alteração do modo de ingresso em jornadas Co-authored-by: joaobisi --- src/app/journey-page/[journeyId]/page.tsx | 20 ++------------------ src/components/journey/journeyInfo.tsx | 7 ------- src/components/journey/journeyPath.tsx | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/app/journey-page/[journeyId]/page.tsx b/src/app/journey-page/[journeyId]/page.tsx index 6eb8099..dfac53b 100644 --- a/src/app/journey-page/[journeyId]/page.tsx +++ b/src/app/journey-page/[journeyId]/page.tsx @@ -8,10 +8,7 @@ import { getJourney, getTrails } from '@/services/studioMaker.service'; import { Journey } from '@/lib/interfaces/journey.interface'; import { Trail } from '@/lib/interfaces/trails.interface'; import { useParams } from 'next/navigation'; -import { - subscribeJourney, - getSubscribedJourneys, -} from '@/services/user.service'; +import { getSubscribedJourneys,} from '@/services/user.service'; import { useSession } from 'next-auth/react'; import { getCompletedTrails } from '@/services/user.service'; @@ -68,18 +65,6 @@ export default function JourneyPage() { fetchJourneyData(); }, [journeyId, session?.user?.id]); - const handleJoin = async () => { - if (session?.user.id) { - const id = Array.isArray(journeyId) ? journeyId[0] : journeyId; - await subscribeJourney({ - userId: session.user.id, - journeyId: id, - accessToken: session?.user.accessToken, - }); - setHasJourney(true); - } - }; - if (error) { return
{error}
; } @@ -113,7 +98,6 @@ export default function JourneyPage() { description={journey.description} trailCount={trails.length} hasJourney={hasJourney} - onJoin={handleJoin} completedTrailsCount={completedTrailsInJourney.length} /> @@ -137,7 +121,7 @@ export default function JourneyPage() { ) : ( - + )} diff --git a/src/components/journey/journeyInfo.tsx b/src/components/journey/journeyInfo.tsx index 3eb927f..ed9de00 100644 --- a/src/components/journey/journeyInfo.tsx +++ b/src/components/journey/journeyInfo.tsx @@ -3,14 +3,12 @@ import React from 'react'; import { Box, Typography, LinearProgress } from '@mui/material'; import CollectionsBookmarkIcon from '@mui/icons-material/CollectionsBookmark'; -import MyButton from '@/components/ui/buttons/myButton.component'; interface JourneyInfoProps { title: string; description: string; trailCount: number; hasJourney: boolean; - onJoin: () => void; completedTrailsCount: number; } @@ -19,14 +17,9 @@ const JourneyInfo: React.FC = ({ description, trailCount, hasJourney, - onJoin, completedTrailsCount, }) => { - const handleJoinClick = () => { - onJoin(); - }; - const progressValue = Math.floor(( completedTrailsCount / trailCount ) * 100); return ( diff --git a/src/components/journey/journeyPath.tsx b/src/components/journey/journeyPath.tsx index 443ce6b..e9dbf71 100644 --- a/src/components/journey/journeyPath.tsx +++ b/src/components/journey/journeyPath.tsx @@ -3,13 +3,15 @@ import { Box, Button, Typography } from '@mui/material'; import { Trail } from '@/lib/interfaces/trails.interface'; import { useRouter } from 'next/navigation'; import { useSession } from 'next-auth/react'; -import { getCompletedTrails } from '@/services/user.service'; +import { getCompletedTrails, subscribeJourney } from '@/services/user.service'; interface JourneyPathProps { trails: Trail[]; + journeyId: string; + hasJourney: boolean; } -const JourneyPath: React.FC = ({ trails }) => { +const JourneyPath: React.FC = ({ trails, journeyId, hasJourney }) => { const nodeSpacing = 120; const nodeSize = 80; const zigzagOffset = 100; @@ -86,7 +88,15 @@ const JourneyPath: React.FC = ({ trails }) => { }; }, [trails]); - const handleClick = (trailId: string) => { + const handleClick = async (trailId: string) => { + if (session?.user.id && !hasJourney) { + const id = Array.isArray(journeyId) ? journeyId[0] : journeyId; + await subscribeJourney({ + userId: session.user.id, + journeyId: id, + accessToken: session?.user.accessToken, + }); + } router.push(`/trail-page/${trailId}`); }; From 34d9b81a35266b4d7b222c57e8d2af902da5a74b Mon Sep 17 00:00:00 2001 From: Joa0V Date: Tue, 3 Sep 2024 12:46:56 -0300 Subject: [PATCH 2/4] feat(#78):adicionando botoes de voltar e avancar jornadas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adicionando botões de voltar e avançar jornadas na journeyPage --- src/app/journey-page/[journeyId]/page.tsx | 72 +++++++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/src/app/journey-page/[journeyId]/page.tsx b/src/app/journey-page/[journeyId]/page.tsx index dfac53b..f61be03 100644 --- a/src/app/journey-page/[journeyId]/page.tsx +++ b/src/app/journey-page/[journeyId]/page.tsx @@ -1,25 +1,31 @@ 'use client'; import React, { useEffect, useState } from 'react'; -import { Box, CircularProgress, Divider, Typography } from '@mui/material'; +import { Box, CircularProgress, Divider, IconButton, Typography } from '@mui/material'; import JourneyInfo from '@/components/journey/journeyInfo'; import JourneyPath from '@/components/journey/journeyPath'; -import { getJourney, getTrails } from '@/services/studioMaker.service'; +import { getJourney, getJourneysByPoint, getTrails } from '@/services/studioMaker.service'; import { Journey } from '@/lib/interfaces/journey.interface'; import { Trail } from '@/lib/interfaces/trails.interface'; -import { useParams } from 'next/navigation'; -import { getSubscribedJourneys,} from '@/services/user.service'; +import { useParams, useRouter } from 'next/navigation'; +import { getSubscribedJourneys, } from '@/services/user.service'; import { useSession } from 'next-auth/react'; import { getCompletedTrails } from '@/services/user.service'; +import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; + export default function JourneyPage() { const { journeyId } = useParams(); + const router = useRouter(); const [journey, setJourney] = useState(null); const [trails, setTrails] = useState([]); const [error, setError] = useState(null); const [hasJourney, setHasJourney] = useState(false); const { data: session } = useSession(); const [completedTrails, setCompletedTrails] = useState([]); + const [previousJourney, setPreviousJourney] = useState(null); + const [nextJourney, setNextJourney] = useState(null); useEffect(() => { const fetchCompletedTrails = async () => { @@ -47,6 +53,23 @@ export default function JourneyPage() { const trailsData = await getTrails({ id, token }); setTrails(trailsData); + const pointId = journeyData.point; + if (pointId) { + const relatedJourneys: Journey[] = await getJourneysByPoint(pointId); + const next = relatedJourneys.find(j => j.order === journeyData.order + 1); + if (next != undefined) { + setNextJourney(next); + console.log(next); + console.log(nextJourney); + } + const previous = relatedJourneys.find(j => j.order === journeyData.order - 1); + if (previous != undefined) { + setPreviousJourney(previous); + console.log(previous); + console.log(previousJourney); + } + } + if (session?.user?.id) { const userJourneys = await getSubscribedJourneys(session.user.id); let isSubscribed = false; @@ -65,6 +88,14 @@ export default function JourneyPage() { fetchJourneyData(); }, [journeyId, session?.user?.id]); + const handleNext = async () => { + router.push(`/journey-page/${nextJourney?._id}`); + } + + const handlePrevious = async () => { + router.push(`/journey-page/${previousJourney?._id}`); + } + if (error) { return
{error}
; } @@ -82,6 +113,39 @@ export default function JourneyPage() { backgroundColor: '#f1f1f1', height: '100vh', }}> + + {(previousJourney) ? + + + + : (null) + } + {(nextJourney) ? + + + + : (null) + } + Date: Tue, 3 Sep 2024 15:38:45 -0300 Subject: [PATCH 3/4] =?UTF-8?q?feat(#78):Reposicionando=20os=20bot=C3=B5es?= =?UTF-8?q?=20de=20voltar=20e=20avan=C3=A7ar=20Reposicionando=20e=20garant?= =?UTF-8?q?indo=20que=20os=20bot=C3=B5es=20de=20voltar=20e=20avan=C3=A7ar?= =?UTF-8?q?=20apare=C3=A7am?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/journey-page/[journeyId]/page.tsx | 47 +++++++++++++---------- src/components/journey/journeyPath.tsx | 1 + 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/app/journey-page/[journeyId]/page.tsx b/src/app/journey-page/[journeyId]/page.tsx index f61be03..eb84497 100644 --- a/src/app/journey-page/[journeyId]/page.tsx +++ b/src/app/journey-page/[journeyId]/page.tsx @@ -112,40 +112,43 @@ export default function JourneyPage() { - - {(previousJourney) ? + {(previousJourney) && - : (null) } - {(nextJourney) ? - + + {(nextJourney) && + - : (null) } - + @@ -165,13 +169,14 @@ export default function JourneyPage() { completedTrailsCount={completedTrailsInJourney.length} /> - + + {!trails.length ? ( = ({ trails, journeyId, hasJourney height: `${Math.max(trails.length * nodeSpacing + nodeSize + 50, 400)}px`, backgroundColor: '#f0f0f0', overflow: 'hidden', + zIndex: 1, }} > Date: Tue, 3 Sep 2024 15:58:46 -0300 Subject: [PATCH 4/4] feat(#78):mantendo a Toolbar no lugar Mantendo a Toolbar independente de quanto scrolle pra baixo --- src/components/studio/MarkdownPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/studio/MarkdownPage.tsx b/src/components/studio/MarkdownPage.tsx index d4f1ed0..02882ed 100644 --- a/src/components/studio/MarkdownPage.tsx +++ b/src/components/studio/MarkdownPage.tsx @@ -65,8 +65,8 @@ const MarkdownPage: React.FC = ({ trailId }) => { return (