Commit ebb51d8f authored by Gustavo Vicentini Deon's avatar Gustavo Vicentini Deon
Browse files

Merge branch 'develop' into 'main'

Last adjustments

See merge request !83
parents bfec9b78 8dd9ab3c
Pipeline #13160 passed with stages
in 5 minutes and 4 seconds
Showing with 353 additions and 14 deletions
+353 -14
src/assets/images/csv.png

11.7 KB

......@@ -3,15 +3,18 @@ import Button from '../Button';
export interface InputHeaderProps {
children: React.ReactNode;
onAddButtonClick?: () => void;
noButton?: boolean;
}
export function InputHeader({ children, onAddButtonClick }: InputHeaderProps) {
export function InputHeader({ children, onAddButtonClick, noButton = false }: InputHeaderProps) {
return (
<div className="flex space-x-5">
{children}
<Button variant="info" size="xsmall" onClickAction={onAddButtonClick}>
+
</Button>
{noButton ? null : (
<Button variant="info" size="xsmall" onClickAction={onAddButtonClick}>
+
</Button>
)}
</div>
);
}
......@@ -12,8 +12,8 @@ import laptopWhite from '../../assets/sideMenuIcons/laptopWhite.svg';
import laptopOrange from '../../assets/sideMenuIcons/laptopOrange.svg';
import groupWhite from '../../assets/sideMenuIcons/groupWhite.svg';
import groupOrange from '../../assets/sideMenuIcons/groupOrange.svg';
// import historyOrange from '../../assets/sideMenuIcons/historyOrange.svg';
// import historyWhite from '../../assets/sideMenuIcons/historyWhite.svg';
import historyOrange from '../../assets/sideMenuIcons/historyOrange.svg';
import historyWhite from '../../assets/sideMenuIcons/historyWhite.svg';
function SideMenu() {
const [activeButton, setActiveButton] = useState<string | null>(window.location.pathname);
......@@ -44,10 +44,7 @@ function SideMenu() {
imageWhite={talkWhite}
imageOrange={talkOrange}
/>
{
// TODO: implement backend and frontend history page to export
}
{/* <SideMenuItem
<SideMenuItem
onClick={() => {
handleActiveButton('/history');
handleNav('/history');
......@@ -56,7 +53,7 @@ function SideMenu() {
title="Histórico"
imageWhite={historyWhite}
imageOrange={historyOrange}
/> */}
/>
<SideMenuItem
onClick={() => {
handleActiveButton('/dashboard/orgs');
......
const history = [
{
id: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
name: 'Sprint 1',
startDate: '1970-01-01T00:00:00.000Z',
endDate: '1970-01-01T00:00:00.000Z',
squadId: null,
updated_at: '2023-11-24T03:43:44.721Z',
created_at: '2023-11-24T03:43:55.849Z',
stories: [
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia1',
final_points: 12,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task1DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task2DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia2',
final_points: 14,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'TaskDaHistoria2',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
],
},
{
id: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
name: 'Sprint 2',
startDate: '1970-01-01T00:00:00.000Z',
endDate: '1970-01-01T00:00:00.000Z',
squadId: null,
updated_at: '2023-11-24T03:43:44.721Z',
created_at: '2023-11-24T03:43:55.849Z',
stories: [
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia1',
final_points: 12,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task1DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task2DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia2',
final_points: 14,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'TaskDaHistoria2',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
],
},
{
id: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
name: 'Sprint 1',
startDate: '1970-01-01T00:00:00.000Z',
endDate: '1970-01-01T00:00:00.000Z',
squadId: null,
updated_at: '2023-11-24T03:43:44.721Z',
created_at: '2023-11-24T03:43:55.849Z',
stories: [
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia1',
final_points: 12,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task1DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task2DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia2',
final_points: 14,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'TaskDaHistoria2',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
],
},
{
id: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
name: 'Sprint 1',
startDate: '1970-01-01T00:00:00.000Z',
endDate: '1970-01-01T00:00:00.000Z',
squadId: null,
updated_at: '2023-11-24T03:43:44.721Z',
created_at: '2023-11-24T03:43:55.849Z',
stories: [
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia1',
final_points: 12,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task1DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'Task2DaHistoria1',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
{
id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
story_id: '123',
name: 'Historia2',
final_points: 14,
sprintId: '7495a9ee-7f37-4e0e-bfa2-335b25bc5468',
updated_at: '2023-11-24T03:44:05.984Z',
created_at: '2023-11-24T03:44:31.567Z',
tasks: [
{
id: 'c3d70818-6db7-42e0-a928-962c554f923f',
task_id: '123',
name: 'TaskDaHistoria2',
points: 12,
updated_at: '2023-11-24T03:44:37.561Z',
created_at: '2023-11-24T03:44:57.692Z',
story_id: 'f6fa5aac-0afd-4215-b38a-505bd824a712',
},
],
},
],
},
];
export default history;
......@@ -414,7 +414,7 @@ export default function Game() {
};
const handleDeleteSession = async (save: boolean) => {
await request(`/sessions/finalize/${session_id}?save=${save}}`);
await request(`/sessions/finalize/${session_id}?save=${save}`);
};
const FinishedVotingModal = () => {
......
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useCallback, useEffect } from 'react';
import { saveAs } from 'file-saver';
import Papa from 'papaparse';
import Container from '../../components/Container';
import { InputHeader } from '../../components/InputHeader/Index';
import { InputText } from '../../components/InputText/Index';
import { useGet } from '../../hooks/useGet';
import { CsvDownloadFilesDTO } from '../../types/CsvDownloadFilesDTO';
import Spinner from '../../components/Spinner';
import CsvImage from '../../assets/images/csv.png';
function History() {
const { data: info, request: getInfo, isLoading } = useGet<CsvDownloadFilesDTO[]>();
useEffect(() => {
getInfo(`/sprint`);
}, []);
const CsvContainer = useCallback((item: any) => {
const handleParseCSV = () => {
const csvData: any[] | Papa.UnparseObject<any> = [];
item.stories.forEach((item: any) => {
const row = {
Story: [item.name],
SumOfTasksVotes: item.final_points,
Tasks: item.tasks.map((task: any) => task.name),
TasksVotes: item.tasks.map((task: any) => task.points),
};
csvData.push(row);
});
const csv = Papa.unparse(csvData, { delimiter: ';' });
return csv;
};
const downloadFile = () => {
const csv = handleParseCSV();
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
saveAs(blob, `Squad_-_${item.name}.csv`);
};
return (
<div className="max-w-sm flex p-3 rounded-lg shadow-xl cursor-pointer" onClick={downloadFile}>
<div className="flex flex-shrink-0 items-center justify-center">
<img src={CsvImage} alt="csv" className="h-12 w-12" />
</div>
<div className="ml-6 pt-1">
<h4 className="text-xl text-gray-900">{item.name}</h4>
<p className="text-base text-gray-600">
Soma das histórias:{' '}
{item?.stories?.reduce((acc: any, story: any) => acc + story?.final_points, 0)}
</p>
</div>
</div>
);
}, []);
return (
<Container title="histórico">
<InputHeader>
<InputText value="" placeholder="Nome" size="medium" isRequired={true} />
<InputHeader noButton>
<InputText value="" placeholder="Arquivo" size="medium" isRequired={true} />
</InputHeader>
{isLoading ? (
<div className="w-full flex items-center justify-center mt-8 h-60">
<Spinner color="triider-primary-orange-dark" size="16" />
</div>
) : (
<div className="w-full overflow-auto gap-14 grid grid-cols-3 items-start justify-start mt-8 h-60">
{info?.map((item) => CsvContainer(item))}
</div>
)}
</Container>
);
}
......
export type CsvDownloadFilesDTO = {
id: string;
name: string;
startDate: string;
endDate: string;
squadId: string | null;
updated_at: string;
created_at: string;
stories: Stories[];
};
type Stories = {
id: string;
story_id: string;
name: string;
final_points: number;
sprintId: string;
updated_at: string;
created_at: string;
tasks: Tasks[];
};
type Tasks = {
id: string;
task_id: string;
name: string;
final_points: number;
storyId: string;
updated_at: string;
created_at: string;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment