MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / onFileChange

Function onFileChange

apps/web/ui/ConfigurationsView/SlackImportRow/index.tsx:28–62  ·  view source on GitHub ↗
(event: React.ChangeEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

26 };
27
28 const onFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
29 if (!event.target.files?.length) return;
30
31 const file = event.target.files.item(0);
32 if (!file) return;
33
34 setProgress(0);
35 setUploading(true);
36
37 try {
38 const { url, fileUrl } = await api.get<{ url: string; fileUrl: string }>(
39 `/api/accounts/slack-import?${qs({ accountId: currentCommunity.id })}`
40 );
41 await api.putWithOptions(url, file, {
42 headers: {
43 'Content-Length': new Blob([file]).size,
44 },
45 onUploadProgress: (progressEvent_1: ProgressEvent) => {
46 const percentCompleted = Math.round(
47 (progressEvent_1.loaded * 100) / progressEvent_1.total
48 );
49 setProgress(percentCompleted);
50 },
51 });
52 setUploading(false);
53 await api.startSync({
54 account_id: currentCommunity.id,
55 file_location: fileUrl,
56 });
57 Toast.success('Import process initiated');
58 } catch (response) {
59 setUploading(false);
60 Toast.error('Something went wrong');
61 }
62 };
63
64 return (
65 <>

Callers

nothing calls this directly

Calls 3

qsFunction · 0.90
successMethod · 0.80
errorMethod · 0.65

Tested by

no test coverage detected