Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
interface ReviewStepProps {
  formData: any;
  filesPreview?: any;
  formatSize?: (bytes: number) => string;
}
 
export const ReviewStep = ({ formData, filesPreview, formatSize }: ReviewStepProps) => {
  const getProviderDisplayName = (provider: string) => {
    const providerMap: Record<string, string> = {
      s3: "Amazon S3",
      gcp: "Google Cloud Storage",
      azure: "Azure Blob Storage",
      redis: "Redis",
      localfiles: "Local Files",
    };
    return providerMap[provider] || provider;
  };
 
  const getBucketName = () => {
    return formData.bucket || formData.container || "Not specified";
  };
 
  const getFileCount = () => {
    if (!filesPreview) return "0 files";
 
    // Check if the last file is the "preview limit reached" indicator
    const lastFile = filesPreview[filesPreview.length - 1];
    const hasMoreFiles = lastFile && lastFile.key === null;
 
    if (hasMoreFiles) {
      // Subtract 1 to exclude the placeholder file
      const visibleFileCount = filesPreview.length - 1;
      return `More than ${visibleFileCount} files`;
    }
 
    return `${filesPreview.length} files`;
  };
 
  const getTotalSize = () => {
    if (!filesPreview || !formatSize) return "0 Bytes";
 
    // Check if the last file is the "preview limit reached" indicator
    const lastFile = filesPreview[filesPreview.length - 1];
    const hasMoreFiles = lastFile && lastFile.key === null;
 
    // Calculate total size excluding the placeholder file if it exists
    const filesToCount = hasMoreFiles ? filesPreview.slice(0, -1) : filesPreview;
    const totalBytes = filesToCount.reduce((sum: number, file: any) => sum + (file.size || 0), 0);
 
    if (hasMoreFiles) {
      return `More than ${formatSize(totalBytes)}`;
    }
 
    return formatSize(totalBytes);
  };
 
  return (
    <div>
      <div className="border-b pb-4 mb-6">
        <h2 className="text-2xl font-bold text-gray-900">Ready to Connect</h2>
        <p className="text-gray-600 mt-1">Review your connection details and confirm to start importing</p>
      </div>
 
      {/* Connection Details Section */}
      <div className="grid grid-cols-2 gap-y-4 mb-8">
        <div>
          <p className="text-sm text-gray-500">Provider</p>
          <p className="font-medium">{getProviderDisplayName(formData.provider)}</p>
        </div>
 
        <div>
          <p className="text-sm text-gray-500">Storage Location</p>
          <p className="font-medium">{getBucketName()}</p>
        </div>
 
        {formData.prefix && (
          <div>
            <p className="text-sm text-gray-500">Prefix</p>
            <p className="font-medium">{formData.prefix}</p>
          </div>
        )}
 
        {filesPreview && (
          <>
            <div>
              <p className="text-sm text-gray-500">Files to import</p>
              <p className="font-medium">{getFileCount()}</p>
            </div>
 
            <div>
              <p className="text-sm text-gray-500">Total size</p>
              <p className="font-medium">{getTotalSize()}</p>
            </div>
          </>
        )}
      </div>
 
      {/* Import Process Section */}
      <div className="bg-primary-background border border-primary-border-subtler rounded-small p-4 mb-8">
        <h3 className="text-lg font-semibold mb-2">Import Process</h3>
        <p>Files will be imported in the background. You can continue working while the import is in progress.</p>
      </div>
    </div>
  );
};