From bbbeca80bce21c883e7fa72f2ce05975a44f3d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20=C5=A0onovsk=C3=BD?= <stepan.sonovsky@inqool.cz> Date: Mon, 12 Aug 2024 16:45:50 +0200 Subject: [PATCH] chore: removed unused code --- src/app/components/App.tsx | 2 +- src/app/components/CommitDetail.tsx | 5 ++--- src/app/csvDownload/CsvButtons.tsx | 6 +----- src/app/csvDownload/CsvDownload.tsx | 3 +-- src/app/csvDownload/CsvDownloadTestFiles.tsx | 1 - src/app/hooks/useCommitDetails.ts | 6 +++--- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/app/components/App.tsx b/src/app/components/App.tsx index b5cb1b8..8bd67b4 100644 --- a/src/app/components/App.tsx +++ b/src/app/components/App.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import CommitList from './CommitList'; import CommitDetail from './CommitDetail'; -import { extractProjectIdFromUrl, extractGitlabDomainFromUrl } from '../../utils.ts'; +import { extractProjectIdFromUrl, extractGitlabDomainFromUrl } from '@/utils'; const App: React.FC = () => { const [repoUrl, setRepoUrl] = useState<string>(''); diff --git a/src/app/components/CommitDetail.tsx b/src/app/components/CommitDetail.tsx index 0e00a9d..5051b80 100644 --- a/src/app/components/CommitDetail.tsx +++ b/src/app/components/CommitDetail.tsx @@ -1,5 +1,4 @@ -import React, { useEffect, useState } from 'react'; -import api from "@/client"; +import React from 'react'; import useCommitDetails from "@/app/hooks/useCommitDetails"; import {useCommitFiles} from "@/app/hooks/useCommitFiles"; @@ -11,7 +10,7 @@ interface CommitDetailProps { const CommitDetail: React.FC<CommitDetailProps> = ({ projectId, commitId, token, host }) => { const { commit, loading, error } = useCommitDetails(projectId, commitId, token, host); - const { files, loadingE, errorE } = useCommitFiles(projectId, commitId, token); + const { files} = useCommitFiles(projectId, commitId, token); if (loading) return <p>Loading...</p>; diff --git a/src/app/csvDownload/CsvButtons.tsx b/src/app/csvDownload/CsvButtons.tsx index e71778c..9acf406 100644 --- a/src/app/csvDownload/CsvButtons.tsx +++ b/src/app/csvDownload/CsvButtons.tsx @@ -8,25 +8,21 @@ const CsvButtons = ({projectId, token, host}) => { const [showCsvDownloadPositivity, setShowCsvDownloadPositivity] = useState(false); const [showCsvDownloadSize, setShowCsvDownloadSize] = useState(false); const [showCsvDownloadTestFiles, setShowCsvDownloadTestFiles] = useState(false); - const [fetchCommits, setFetchCommits] = useState(false); - const {commits, loading, error} = useCommitsAll(projectId, token, host); + const {commits} = useCommitsAll(projectId, token, host); console.log(projectId, host); const handleFetchSize = () => { setShowCsvDownloadSize(true); - setFetchCommits(true); }; const handleFetchPositivity = () => { setShowCsvDownloadPositivity(true); - setFetchCommits(true); }; const handleFetchTestFiles = () => { setShowCsvDownloadTestFiles(true); - setFetchCommits(true); }; return ( diff --git a/src/app/csvDownload/CsvDownload.tsx b/src/app/csvDownload/CsvDownload.tsx index 3d4e93e..7f503d0 100644 --- a/src/app/csvDownload/CsvDownload.tsx +++ b/src/app/csvDownload/CsvDownload.tsx @@ -1,6 +1,5 @@ -import { useState, useEffect, createRef } from 'react'; import { CSVLink } from "react-csv"; -import useCommitDetails, { useCommitsPositivity } from "@/app/hooks/useCommitDetails"; +import { useCommitsPositivity } from "@/app/hooks/useCommitDetails"; const CsvDownloadPositivity = ({ commits, projectId, token, host }) => { const { data, isLoading } = useCommitsPositivity(projectId, commits, token, host); diff --git a/src/app/csvDownload/CsvDownloadTestFiles.tsx b/src/app/csvDownload/CsvDownloadTestFiles.tsx index fafd9fb..f3d9491 100644 --- a/src/app/csvDownload/CsvDownloadTestFiles.tsx +++ b/src/app/csvDownload/CsvDownloadTestFiles.tsx @@ -1,5 +1,4 @@ import {CSVLink} from "react-csv"; -import {useCommitsPositivity} from "@/app/hooks/useCommitDetails"; import {useCommitTestFiles} from "@/app/hooks/useCommitTestFiles"; const CsvDownloadTestFiles = ({commits, projectId, token, host}) => { diff --git a/src/app/hooks/useCommitDetails.ts b/src/app/hooks/useCommitDetails.ts index 05d9d5d..fc39754 100644 --- a/src/app/hooks/useCommitDetails.ts +++ b/src/app/hooks/useCommitDetails.ts @@ -11,7 +11,7 @@ export const useCommitsPositivity = (projectId, commitIds, token, host) => { axios.get(`${host}/api/v4/projects/${projectId}/repository/commits/${commitId.id}`, { headers: {'PRIVATE-TOKEN': token} }).then(response => { - const {id, author_name, created_at, stats} = response.data; + const { author_name, created_at, stats} = response.data; let commitType = 'mixed'; if (stats.additions > 0 && stats.deletions === 0) { commitType = 'addition'; @@ -41,7 +41,7 @@ export const useCommitSize = (projectId, commitIds, token, host) => { axios.get(`${host}/api/v4/projects/${projectId}/repository/commits/${commitId.id}`, { headers: {'PRIVATE-TOKEN': token} }).then(response => { - const {id, author_name, created_at, stats} = response.data; + const {author_name, created_at, stats} = response.data; let commitSize = 'small'; const totalChanges = stats.additions + stats.deletions; if (totalChanges > 50) { @@ -90,7 +90,7 @@ const useCommitDetails = (projectId: string, commitId: string, token: string, ho }; fetchCommitDetails(); - }, [projectId, commitId, token]); + }, [projectId, commitId, token, host]); return {commit, loading, error}; }; -- GitLab