Skip to content

Commit 2b50a3a

Browse files
committed
hi guys
1 parent 0374b8b commit 2b50a3a

6 files changed

Lines changed: 310 additions & 233 deletions

File tree

src/api/downloadCSV.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import axios from "axios";
21
import instance from "./axiosConfig";
32

4-
export const downloadCSV = async () => {
5-
try {
6-
const response = await instance.get(`/admin/usercsv`, {
7-
withCredentials: true,
8-
responseType: 'blob'
9-
}
10-
);
11-
return response;
12-
} catch (err: any) {
13-
throw new Error(err.response?.data?.message || 'Failed to delete score');
3+
export const downloadCSV = async (): Promise<Blob> => {
4+
try {
5+
const response = await instance.get<Blob>(`/admin/usercsv`, {
6+
withCredentials: true,
7+
responseType: "blob",
8+
});
9+
return response.data;
10+
} catch (error: unknown) {
11+
if (error instanceof Error) {
12+
throw new Error(error.message || "Failed to download CSV");
1413
}
15-
};
16-
14+
throw new Error("Failed to download CSV");
15+
}
16+
};

src/api/fetchScores.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { AxiosError } from "axios";
12
import axios from "./axiosConfig";
23
import { z } from "zod";
34

@@ -57,11 +58,12 @@ export const fetchScores = async (teamId: string): Promise<ScoreResponse[]> => {
5758
});
5859
const parsedResponse = scoresResponseSchema.parse(response.data);
5960
return parsedResponse.data?.scores ?? [];
60-
} catch (err: any) {
61-
if (err.response?.status === 404) {
61+
} catch (err) {
62+
const error=err as AxiosError
63+
if (error.status === 404) {
6264
return [];
6365
}
64-
throw new Error(err.response?.data?.message || 'Failed to fetch scores');
66+
throw new Error(error.message || 'Failed to fetch scores');
6567
}
6668
};
6769

@@ -76,9 +78,10 @@ export const createScore = async (data: CreateScoreRequest) => {
7678
);
7779
const parsedResponse = createUpdateResponseSchema.parse(response.data);
7880
return parsedResponse;
79-
} catch (error: any) {
80-
if (error.response?.data?.message) {
81-
throw new Error(error.response.data.message);
81+
} catch (err) {
82+
const error=err as AxiosError
83+
if (error.message) {
84+
throw new Error(error.message);
8285
}
8386
throw new Error('Failed to create score');
8487
}
@@ -92,8 +95,9 @@ export const deleteScore = async (scoreId: string) => {
9295

9396
const parsedResponse = deleteResponseSchema.parse(response.data);
9497
return parsedResponse;
95-
} catch (err: any) {
96-
throw new Error(err.response?.data?.message || 'Failed to delete score');
98+
} catch (err) {
99+
const error=err as AxiosError
100+
throw new Error(error.message || 'Failed to delete score');
97101
}
98102
};
99103

@@ -108,9 +112,10 @@ export const updateScore = async (data: UpdateScoreRequest) => {
108112
);
109113
const parsedResponse = createUpdateResponseSchema.parse(response.data);
110114
return parsedResponse;
111-
} catch (error: any) {
112-
if (error.response?.data?.message) {
113-
throw new Error(error.response.data.message);
115+
} catch (err) {
116+
const error=err as AxiosError
117+
if (error.message) {
118+
throw new Error(error.message);
114119
}
115120
throw new Error('Failed to update score');
116121
}

src/app/idea/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export default function TeamsIdeasTable() {
7777

7878
const filtered = processedData.filter(team => {
7979
const matchesSearch = searchTerm
80-
? (team.name?.toLowerCase().includes(searchTerm.toLowerCase()) || false) ||
81-
(team.submission?.title?.toLowerCase().includes(searchTerm.toLowerCase()) || false)
80+
? (team.name?.toLowerCase().includes(searchTerm.toLowerCase()) ?? false) ||
81+
(team.submission?.title?.toLowerCase().includes(searchTerm.toLowerCase()) ?? false)
8282
: true;
8383

8484
const matchesTrack = selectedTrack
@@ -99,7 +99,7 @@ export default function TeamsIdeasTable() {
9999
),
100100
cell: ({ row }) => (
101101
<div className="max-w-[200px] truncate font-medium">
102-
{row.getValue("name") || "Unnamed Team"}
102+
{row.getValue("name") ?? "Unnamed Team"}
103103
</div>
104104
),
105105
},
@@ -122,7 +122,7 @@ export default function TeamsIdeasTable() {
122122
),
123123
cell: ({ row }) => (
124124
<div className="max-w-[200px] truncate">
125-
{row.original.submission?.title || "No submission"}
125+
{row.original.submission?.title ?? "No submission"}
126126
</div>
127127
),
128128
},
@@ -134,7 +134,7 @@ export default function TeamsIdeasTable() {
134134
),
135135
cell: ({ row }) => (
136136
<div className="max-w-[300px] truncate">
137-
{row.original.submission?.description || "No description"}
137+
{row.original.submission?.description ?? "No description"}
138138
</div>
139139
),
140140
},
@@ -146,7 +146,7 @@ export default function TeamsIdeasTable() {
146146
),
147147
cell: ({ row }) => (
148148
<div className="max-w-[200px] truncate">
149-
{row.original.submission?.track || "Unassigned"}
149+
{row.original.submission?.track ?? "Unassigned"}
150150
</div>
151151
),
152152
},
@@ -183,7 +183,7 @@ export default function TeamsIdeasTable() {
183183
onChange={(e) => setSearchTerm(e.target.value)}
184184
/>
185185
<Select
186-
value={selectedTrack || "all"}
186+
value={selectedTrack ?? "all"}
187187
onValueChange={(value) => setSelectedTrack(value === "all" ? "" : value)}
188188
>
189189
<SelectTrigger className="w-48">

0 commit comments

Comments
 (0)