File size: 1,208 Bytes
194aaa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';

interface UploadSectionProps {
  fileInputRef: React.RefObject<HTMLInputElement | null>;
  isUploading: boolean;
  uploadError: string | null;
  onFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
}

export function UploadSection({

  fileInputRef,

  isUploading,

  uploadError,

  onFileChange,

}: UploadSectionProps) {
  return (
    <div className="upload-section">

      <div

        className="upload-dropzone"

        onClick={() => fileInputRef.current?.click()}

      >

        <p>Upload Document</p>

        <span>PDF, DOCX, TXT up to 10MB</span>

        <input

          type="file"

          ref={fileInputRef}

          onChange={onFileChange}

          accept=".pdf,.docx,.txt"

          style={{ display: 'none' }}

        />

      </div>



      {isUploading && (

        <div className="upload-progress">

          <span>Uploading & Processing...</span>

          <div className="upload-spinner" />

        </div>

      )}



      {uploadError && (

        <div style={{ color: 'var(--red-hover)', fontSize: '0.8rem', marginTop: '8px' }}>

          {uploadError}

        </div>

      )}

    </div>
  );
}