Skip to content

Commit

Permalink
Merge pull request #37 from fga-eps-mds/feat(#122)/ordenacao-jornadas
Browse files Browse the repository at this point in the history
Feat(#122)/ordenacao jornadas
  • Loading branch information
DaviMatheus authored Sep 2, 2024
2 parents ea66d09 + a5ff85e commit 50c0a24
Show file tree
Hide file tree
Showing 45 changed files with 1,804 additions and 782 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@
"dotenv": "^16.4.5",
"glob": "^9.3.5",
"lucide-react": "^0.428.0",
"material-react-table": "^2.13.1",
"next": "^14.2.5",
"next-auth": "^4.24.7",
"next-safe-action": "^7.4.3",
"react": "^18.3.1",
"react-beautiful-dnd": "^13.1.1",
"react-dom": "^18.3.1",
"react-hook-form": "^7.52.1",
"react-markdown": "^9.0.1",
"react-table": "^7.8.0",
"react-multi-carousel": "^2.8.5",
"react-toastify": "^10.0.5",
"rehype-katex": "^7.0.0",
Expand Down
14 changes: 5 additions & 9 deletions src/app/(auth)/oauth/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const OAuthContent = () => {
const refresh = searchParams.get('refresh');
const [isPending, setIsPending] = useState(true);


useEffect(() => {
const fetchSession = async () => {
const result = await signIn('credentials', {
Expand All @@ -47,16 +46,13 @@ const OAuthContent = () => {
router.push('/login');
}

localStorage.setItem('token', JSON.stringify(session?.user.accessToken));
localStorage.setItem(
'refresh',
JSON.stringify(session?.user.refreshToken),
);
localStorage.setItem('token', JSON.stringify(token));
localStorage.setItem('refresh', JSON.stringify(refresh));
router.push('/home');
}
};
fetchSession();
}, [])
}, []);

if (!token) {
toast.error('Erro ao efetuar login, por favor tente novamente!');
router.push('/login');
Expand Down
9 changes: 7 additions & 2 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ const Admin: React.FC = () => {
)}
</DialogContent>
<DialogActions>
<MyButton onClick={cancelRoleChange} color="red" radius='30px' bold>
<MyButton onClick={cancelRoleChange} color="red" radius="30px" bold>
Cancelar
</MyButton>
<MyButton onClick={confirmRoleChange} color="green" radius='30px' bold>
<MyButton
onClick={confirmRoleChange}
color="green"
radius="30px"
bold
>
Confirmar
</MyButton>
</DialogActions>
Expand Down
7 changes: 3 additions & 4 deletions src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import { useSession } from 'next-auth/react';
import HomePrincipalPage from '@/components/home/homePage';


export default function HomePage() {
const { data: session } = useSession();

return (
<div className='bg-[#F1F1F1] min-h-screen'>
<div className='bg-[#F1F1F1] max-w-7xl mx-auto pt-14 px-5'>
<HomePrincipalPage />
<div className="bg-[#F1F1F1] min-h-screen">
<div className="bg-[#F1F1F1] max-w-7xl mx-auto pt-14 px-5">
<HomePrincipalPage />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/journey-page/[journeyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useEffect, useState } from 'react';
import { Box, CircularProgress, Divider, Typography } from '@mui/material';
import JourneyInfo from '@/components/journey/journeyInfo';
import JourneyPath from '@/components/journey/journeyPath';
import { addJourneyToUser, getJourney, getJourneysByUser, getTrails } from '@/services/studioMaker.service';
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';
Expand Down
62 changes: 32 additions & 30 deletions src/app/journeys/page.tsx → src/app/journey/[...pointId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import React, { useState, useEffect } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useSession } from 'next-auth/react';
import {
Box,
Dialog,
Expand All @@ -11,29 +11,27 @@ import {
Button,
Typography,
CircularProgress,
TextField,
} from '@mui/material';
import ButtonRed from '@/components/ui/buttons/red.button';
import SearchBar from '@/components/admin/SearchBar';
import JourneyTable from '@/components/tables/journey.table';
import { Journey } from '@/lib/interfaces/journey.interface';
import { UserRole } from '@/lib/enum/userRole.enum';
import {
deleteJourney,
getJourneys,
getJourneysByUser,
getJourneysByPoint,
} from '@/services/studioMaker.service';
import Popup from '@/components/ui/popup';
import { CreateJourneyForm } from '@/components/forms/createJourney.form';
import { UpdateJourneyForm } from '@/components/forms/editJourney.form';
import { JourneyForm } from '@/components/forms/journey.form';
import { toast } from 'sonner';

const JourneyPage: React.FC = () => {
const { data: session } = useSession();
export default function JourneyPage({
params,
}: {
params: { pointId: string };
}) {
const fetchJourneys = async (): Promise<Journey[]> => {
const journeys = !session?.user.role.includes(UserRole.ADMIN)
? await getJourneysByUser(session?.user.id!)
: await getJourneys();
let journeys = await getJourneysByPoint(params.pointId);
journeys.sort((a, b) => a.order - b.order);
setListJourneys(journeys);
setFilteredJourneys(journeys);
return journeys;
Expand All @@ -42,10 +40,9 @@ const JourneyPage: React.FC = () => {
const {
data = [],
isLoading,

error,
} = useQuery<Journey[], Error>({
queryKey: ['journeys'],
queryKey: ['journeys', params.pointId],
queryFn: fetchJourneys,
});

Expand Down Expand Up @@ -88,12 +85,15 @@ const JourneyPage: React.FC = () => {

const handleJourneyAction = (action: string) => {
if (action === 'editar') setEditionDialogOpen(true);
if (action === 'gerenciar') alert("Redirect to selected journey's trails");
if (action === 'gerenciar') {
}
if (action === 'excluir') setExclusionDialogOpen(true);
};

const addJourney = (journey: Journey) => {
setListJourneys([...listJourneys, journey]);
setListJourneys(
[...listJourneys, journey].sort((a, b) => a.order - b.order),
);
};

const updateJourney = (journey: Journey) => {
Expand All @@ -119,6 +119,7 @@ const JourneyPage: React.FC = () => {
const handleCloseCreateDialog = () => {
setCreateDialogOpen(false);
};

if (isLoading) {
return <CircularProgress />;
}
Expand All @@ -145,13 +146,15 @@ const JourneyPage: React.FC = () => {
<SearchBar value={searchQuery} onChange={setSearchQuery} />
</Box>

<JourneyTable
journeys={filteredJourneys}
anchorEl={anchorEl}
onMenuClick={handleMenuOpen}
onMenuClose={handleMenuClose}
onJourneyAction={handleJourneyAction}
/>
<Box sx={{ width: '100%', maxWidth: 800, marginBottom: 2 }}>
<JourneyTable
journeys={filteredJourneys}
anchorEl={anchorEl}
onMenuClick={handleMenuOpen}
onMenuClose={handleMenuClose}
onJourneyAction={handleJourneyAction}
/>
</Box>

<ButtonRed onClick={() => setCreateDialogOpen(true)}>
Nova Jornada
Expand All @@ -162,8 +165,8 @@ const JourneyPage: React.FC = () => {
setPopup={setEditionDialogOpen}
title="Editar Jornada"
>
<UpdateJourneyForm
updateJourney={updateJourney}
<JourneyForm
callback={updateJourney}
journey={selectedJourney!}
setDialog={setEditionDialogOpen}
/>
Expand All @@ -174,8 +177,9 @@ const JourneyPage: React.FC = () => {
setPopup={setCreateDialogOpen}
title="Criar Nova Jornada"
>
<CreateJourneyForm
addJourney={addJourney}
<JourneyForm
callback={addJourney}
pointId={params.pointId[0]}
setDialog={setCreateDialogOpen}
/>
</Popup>
Expand Down Expand Up @@ -204,6 +208,4 @@ const JourneyPage: React.FC = () => {
</Dialog>
</Box>
);
};

export default JourneyPage;
}
7 changes: 1 addition & 6 deletions src/app/reset-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
'use client';

import Image from 'next/image';
import {
Box,
TextField,
IconButton,
InputAdornment,
} from '@mui/material';
import { Box, TextField, IconButton, InputAdornment } from '@mui/material';
import { Visibility, VisibilityOff } from '@mui/icons-material';
import MyButton from '@/components/ui/buttons/myButton.component';
import calculusLogos from '@/public/calculus-logo.svg';
Expand Down
Loading

0 comments on commit 50c0a24

Please sign in to comment.