You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 11, 2022. It is now read-only.
@@ -234,17 +243,102 @@ class EmailInvitationForm extends React.Component<Props, State> {
234
243
});
235
244
};
236
245
246
+
handleFile=evt=>{
247
+
this.setState({
248
+
importError: '',
249
+
});
250
+
251
+
// Only show loading indicator for large files
252
+
// where it takes > 200ms to load
253
+
consttimeout=setTimeout(()=>{
254
+
this.setState({
255
+
isLoading: true,
256
+
});
257
+
},200);
258
+
259
+
constreader=newFileReader();
260
+
reader.onload=file=>{
261
+
clearTimeout(timeout);
262
+
this.setState({
263
+
isLoading: false,
264
+
});
265
+
266
+
letparsed;
267
+
try{
268
+
if(typeofreader.result!=='string')return;
269
+
parsed=JSON.parse(reader.result);
270
+
}catch(err){
271
+
this.setState({
272
+
importError: 'Only .json files are supported for import.',
273
+
});
274
+
return;
275
+
}
276
+
277
+
if(!Array.isArray(parsed)){
278
+
this.setState({
279
+
importError:
280
+
'Your JSON data is in the wrong format. Please provide either an array of emails ["[email protected]"] or an array of objects with an "email" property and (optionally) a "name" property [{ "email": "[email protected]", "name": "Me" }].',
0 commit comments