Skip to content

Commit ac84484

Browse files
fixed ts errors on frontend
1 parent 003f338 commit ac84484

File tree

2 files changed

+81
-109
lines changed

2 files changed

+81
-109
lines changed

Frontend/src/App/CodeEditor/GitPanel/GitPanel.tsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@ import BranchSelector from "./BranchSelector";
44
import CommitHistory from "./CommitHistory";
55
// import CommitTree from "./CommitTree";
66
import CommitForm from "./CommitForm";
7-
import type { GitState } from "./GitTypes";
8-
import { fetchBranches, fetchCommits } from "./gitOperations";
97

108
const GitPanel = () => {
119
const { theme } = useTheme();
1210

13-
// Initial state - will be populated from API
14-
const [gitState, setGitState] = useState<GitState>({
15-
branches: [],
16-
commits: [],
17-
currentBranch: "",
18-
});
19-
2011
// Loading states
2112
const [isLoading, setIsLoading] = useState(true);
2213
const [error, setError] = useState<string | null>(null);
@@ -27,25 +18,6 @@ const GitPanel = () => {
2718
try {
2819
setIsLoading(true);
2920
setError(null);
30-
31-
// Fetch branches
32-
const branches = await fetchBranches();
33-
34-
// Find the active branch
35-
const activeBranch = branches.find((branch) => branch.isActive);
36-
if (!activeBranch) {
37-
throw new Error("No active branch found");
38-
}
39-
40-
// Fetch commits for active branch
41-
const commits = await fetchCommits(activeBranch.name);
42-
43-
// Set initial state
44-
setGitState({
45-
branches,
46-
commits,
47-
currentBranch: activeBranch.name,
48-
});
4921
} catch (err) {
5022
setError("Failed to initialize Git panel");
5123
console.error(err);
@@ -84,7 +56,7 @@ const GitPanel = () => {
8456
</div>
8557

8658
<div className="flex-grow overflow-auto p-4 Simple-Scrollbar">
87-
{isLoading && gitState.commits.length === 0 && (
59+
{isLoading && (
8860
<div
8961
className={`flex items-center justify-center h-full ${theme.textMuted}`}
9062
>
@@ -121,7 +93,7 @@ const GitPanel = () => {
12193
</div>
12294
)}
12395

124-
{!isLoading && gitState.commits.length > 0 && (
96+
{!isLoading && (
12597
<>
12698
<CommitHistory
12799
// commits={gitState.commits}
Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
1-
import type { Commit, Branch, GitState } from "./GitTypes";
1+
// import type { Commit, Branch, GitState } from "./GitTypes";
22

3-
// This file will be used for actual Git operations in a real application
4-
// For now, it just contains mock implementations
3+
// // This file will be used for actual Git operations in a real application
4+
// // For now, it just contains mock implementations
55

6-
// Fetch branches for the current repository
7-
export const fetchBranches = async (): Promise<Branch[]> => {
8-
// In a real app, this would make an API call to fetch branches
9-
// For demo purposes, returning mock data
10-
return [
11-
{ name: "main", isActive: false },
12-
{ name: "versioning", isActive: true },
13-
{ name: "feature/ui-updates", isActive: false },
14-
];
15-
};
6+
// // Fetch branches for the current repository
7+
// export const fetchBranches = async (): Promise<Branch[]> => {
8+
// // In a real app, this would make an API call to fetch branches
9+
// // For demo purposes, returning mock data
10+
// return [
11+
// { name: "main", isActive: false },
12+
// { name: "versioning", isActive: true },
13+
// { name: "feature/ui-updates", isActive: false },
14+
// ];
15+
// };
1616

17-
// Fetch commits for the specified branch
18-
export const fetchCommits = async (branchName: string): Promise<Commit[]> => {
19-
// In a real app, this would make an API call to fetch commits for the branch
20-
// For demo purposes, returning mock data (ignoring branchName parameter for now)
21-
return [
22-
{
23-
id: "abc123",
24-
message: "Initial commit",
25-
author: "John Doe",
26-
date: new Date(2023, 7, 15, 10, 30),
27-
isCurrent: false,
28-
},
29-
{
30-
id: "def456",
31-
message: "Add authentication flow",
32-
author: "Jane Smith",
33-
date: new Date(2023, 7, 20, 14, 45),
34-
isCurrent: false,
35-
},
36-
{
37-
id: "ghi789",
38-
message: "Fix styling issues",
39-
author: "John Doe",
40-
date: new Date(2023, 7, 25, 9, 15),
41-
isCurrent: true,
42-
},
43-
];
44-
};
17+
// // Fetch commits for the specified branch
18+
// export const fetchCommits = async (): Promise<Commit[]> => {
19+
// // In a real app, this would make an API call to fetch commits for the branch
20+
// // For demo purposes, returning mock data (ignoring branchName parameter for now)
21+
// return [
22+
// {
23+
// id: "abc123",
24+
// message: "Initial commit",
25+
// author: "John Doe",
26+
// date: new Date(2023, 7, 15, 10, 30),
27+
// isCurrent: false,
28+
// },
29+
// {
30+
// id: "def456",
31+
// message: "Add authentication flow",
32+
// author: "Jane Smith",
33+
// date: new Date(2023, 7, 20, 14, 45),
34+
// isCurrent: false,
35+
// },
36+
// {
37+
// id: "ghi789",
38+
// message: "Fix styling issues",
39+
// author: "John Doe",
40+
// date: new Date(2023, 7, 25, 9, 15),
41+
// isCurrent: true,
42+
// },
43+
// ];
44+
// };
4545

46-
// Switch to a different branch
47-
export const switchBranch = async (branchName: string): Promise<GitState> => {
48-
// In a real app, this would make an API call to switch branches
49-
// For demo purposes, returning mock data
50-
const branches = await fetchBranches();
51-
const updatedBranches = branches.map((branch) => ({
52-
...branch,
53-
isActive: branch.name === branchName,
54-
}));
46+
// // Switch to a different branch
47+
// export const switchBranch = async (branchName: string): Promise<GitState> => {
48+
// // In a real app, this would make an API call to switch branches
49+
// // For demo purposes, returning mock data
50+
// const branches = await fetchBranches();
51+
// const updatedBranches = branches.map((branch) => ({
52+
// ...branch,
53+
// isActive: branch.name === branchName,
54+
// }));
5555

56-
const commits = await fetchCommits(branchName);
56+
// const commits = await fetchCommits(branchName);
5757

58-
return {
59-
branches: updatedBranches,
60-
commits,
61-
currentBranch: branchName,
62-
};
63-
};
58+
// return {
59+
// branches: updatedBranches,
60+
// commits,
61+
// currentBranch: branchName,
62+
// };
63+
// };
6464

65-
// Create a new commit
66-
export const createCommit = async (message: string): Promise<Commit> => {
67-
// In a real app, this would make an API call to create a commit
68-
// For demo purposes, returning mock data
69-
return {
70-
id: `commit_${Date.now()}`,
71-
message,
72-
author: "Current User",
73-
date: new Date(),
74-
isCurrent: true,
75-
};
76-
};
65+
// // Create a new commit
66+
// export const createCommit = async (message: string): Promise<Commit> => {
67+
// // In a real app, this would make an API call to create a commit
68+
// // For demo purposes, returning mock data
69+
// return {
70+
// id: `commit_${Date.now()}`,
71+
// message,
72+
// author: "Current User",
73+
// date: new Date(),
74+
// isCurrent: true,
75+
// };
76+
// };
7777

78-
// Rollback to a specific commit
79-
export const rollbackToCommit = async (commitId: string): Promise<Commit[]> => {
80-
// In a real app, this would make an API call to rollback to a commit
81-
// For demo purposes, returning mock data
82-
const commits = await fetchCommits("versioning");
83-
return commits.map((commit) => ({
84-
...commit,
85-
isCurrent: commit.id === commitId,
86-
}));
87-
};
78+
// // Rollback to a specific commit
79+
// export const rollbackToCommit = async (commitId: string): Promise<Commit[]> => {
80+
// // In a real app, this would make an API call to rollback to a commit
81+
// // For demo purposes, returning mock data
82+
// const commits = await fetchCommits("versioning");
83+
// return commits.map((commit) => ({
84+
// ...commit,
85+
// isCurrent: commit.id === commitId,
86+
// }));
87+
// };

0 commit comments

Comments
 (0)