Skip to content

Commit

Permalink
refactor: small edits to new shapefile uploader [2025-01-18]
Browse files Browse the repository at this point in the history
  • Loading branch information
CHRISCARLON committed Jan 18, 2025
1 parent 6bb682f commit ea72a91
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useSingleFileUploader = () => {
_workspaceId: string,
onProgress?: (progress: number) => void,
onSuccess?: (data: UploadResponse) => void,
onError?: (error: string) => void
onError?: (error: string) => void,
): Promise<void> => {
const currentWorkspaceId = getWorkspaceIdFromUrl();
try {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const useSingleFileUploader = () => {
headers,
body: formData,
credentials: "include",
}
},
);

if (!response.ok) {
Expand All @@ -109,7 +109,7 @@ export const useSingleFileUploader = () => {
console.error("Upload error:", err);
}
},
[]
[],
);
return { uploadSingleFile };
};
Expand All @@ -121,7 +121,7 @@ export const useShapefileUploader = () => {
_workspaceId: string,
onProgress?: (progress: number) => void,
onSuccess?: (data: UploadResponse) => void,
onError?: (error: string) => void
onError?: (error: string) => void,
): Promise<void> => {
if (!file.name.toLowerCase().endsWith(".zip")) {
onError?.("Please upload a ZIP file containing shapefile components");
Expand All @@ -140,7 +140,7 @@ export const useShapefileUploader = () => {
zipContents.forEach((relativePath) => {
const extension = relativePath.split(".").pop()?.toLowerCase();
console.log(
`Found file: ${relativePath} with extension: ${extension}`
`Found file: ${relativePath} with extension: ${extension}`,
);
shapefileComponents.push(relativePath);

Expand Down Expand Up @@ -172,12 +172,12 @@ export const useShapefileUploader = () => {
});
} catch (err) {
onError?.(
err instanceof Error ? err.message : "Error processing ZIP file"
err instanceof Error ? err.message : "Error processing ZIP file",
);
console.error("Upload error:", err);
}
},
[]
[],
);

return { uploadShapefile };
Expand Down

0 comments on commit ea72a91

Please sign in to comment.