File size: 7,180 Bytes
1b4b6d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
106
107
108
109
110
111
112
113
114
115
116
117
118
import React from 'react';
import { ZoomIn, ZoomOut } from 'lucide-react';

export default function ClassifyStep({
  classifiedPages,
  setClassifiedPages,
  selectedPageIndex,
  setSelectedPageIndex,
  zoom,
  setZoom,
  isArabic,
  handleSaveClassifications,
  loading
}) {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: '1.2fr 1fr', gap: '25px', height: 'calc(100vh - 160px)' }}>
      {/* Left Page Image Viewer */}
      <div className="glass-panel" style={{ display: 'flex', flexDirection: 'column', overflow: 'hidden' }}>
        <div style={{ padding: '12px 18px', borderBottom: '1px solid var(--border-color)', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
          <span style={{ fontWeight: 700 }}>
            {isArabic ? 'معاينة المخطط' : 'Drawing Preview'} (Page {selectedPageIndex + 1})
          </span>
          <div style={{ display: 'flex', gap: '8px' }}>
            <button className="btn btn-secondary" onClick={() => setZoom(prev => Math.max(0.5, prev - 0.2))} style={{ padding: '6px' }}><ZoomOut size={16} /></button>
            <button className="btn btn-secondary" onClick={() => setZoom(prev => Math.min(3, prev + 0.2))} style={{ padding: '6px' }}><ZoomIn size={16} /></button>
          </div>
        </div>
        <div style={{ flex: 1, overflow: 'auto', backgroundColor: '#334155', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '15px' }}>
          {classifiedPages[selectedPageIndex] && (
            <img 
              src={`${classifiedPages[selectedPageIndex].image_url}`}
              alt="Page preview"
              style={{ transform: `scale(${zoom})`, transformOrigin: 'center center', maxWidth: '100%', height: 'auto', transition: 'transform 0.1s ease', borderRadius: '4px' }}
            />
          )}
        </div>
      </div>

      {/* Right Classify Options */}
      <div className="glass-panel" style={{ padding: '25px', display: 'flex', flexDirection: 'column', overflowY: 'auto' }}>
        <h3 style={{ fontSize: '1.2rem', fontWeight: 800, marginBottom: '5px' }}>
          {isArabic ? '2. نتائج التصنيف التلقائي للصفحات' : '2. Page Classification Results'}
        </h3>
        <p style={{ color: 'var(--text-secondary)', fontSize: '0.85rem', marginBottom: '20px' }}>
          {isArabic 
            ? 'يرجى مراجعة وتأكيد تصنيف الصفحات. اختر الصفحة لمشاهدة المخطط على اليسار وتعديل نوعه.'
            : 'Review classifications. Select a page, review its image on the left, and adjust the category if needed.'}
        </p>

        <div style={{ flex: 1, display: 'flex', flexDirection: 'column', gap: '12px', marginBottom: '20px' }}>
          {classifiedPages.map((page, idx) => (
            <div 
              key={idx}
              onClick={() => setSelectedPageIndex(idx)}
              style={{
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'space-between',
                padding: '10px 14px',
                borderRadius: '8px',
                border: '1px solid var(--border-color)',
                backgroundColor: idx === selectedPageIndex ? 'var(--primary-glow)' : 'var(--bg-secondary)',
                cursor: 'pointer'
              }}
            >
              <div>
                <span style={{ fontWeight: 700, fontSize: '0.88rem' }}>
                  {page.pdf === 'structural' ? (isArabic ? 'إنشائي' : 'Structural') : (isArabic ? 'معماري' : 'Architectural')} P{page.page_num}
                </span>
              </div>
              <select
                className="form-input"
                value={page.detected_type}
                onChange={(e) => {
                  const updated = [...classifiedPages];
                  updated[idx].detected_type = e.target.value;
                  setClassifiedPages(updated);
                }}
                style={{ width: '160px', padding: '6px 10px', fontSize: '0.85rem' }}
              >
                <option value="unknown">{isArabic ? 'غير مصنف' : 'Unknown'}</option>
                <option value="foundations">{isArabic ? 'جدول القواعد (Foundations)' : 'Foundations Schedule'}</option>
                <option value="tie_beam">{isArabic ? 'مخطط الميدة (Tie Beams)' : 'Tie Beams Layout'}</option>
                <option value="upper_columns">{isArabic ? 'جدول الأعمدة (Columns Schedule)' : 'Columns Schedule'}</option>
                <option value="neck_columns">{isArabic ? 'أعمدة الأرضي/الرقبة (Neck Columns)' : 'Neck Columns'}</option>
                <option value="columns_1f">{isArabic ? 'أعمدة الأول (1st Floor Columns)' : '1st Floor Columns'}</option>
                <option value="columns_2f">{isArabic ? 'أعمدة الثاني (2nd Floor Columns)' : '2nd Floor Columns'}</option>
                <option value="columns_roof">{isArabic ? 'أعمدة السطح (Roof Columns)' : 'Roof Columns'}</option>
                <option value="slab_1st">{isArabic ? 'سقف الأول (1st Floor Slab)' : '1st Floor Slab'}</option>
                <option value="slab_2nd">{isArabic ? 'سقف الثاني (2nd Floor Slab)' : '2nd Floor Slab'}</option>
                <option value="roof_slab">{isArabic ? 'سقف السطح (Roof Slab)' : 'Roof Slab'}</option>
                <option value="setting_out">{isArabic ? 'مخطط الموقع/الموقع العام (Setting Out)' : 'Setting Out / Plot Plan'}</option>
                <option value="ground_floor_plan">{isArabic ? 'مخطط الأرضي (Ground Floor Plan)' : 'Ground Floor Plan'}</option>
                <option value="first_floor_plan">{isArabic ? 'مخطط الأول (1st Floor Plan)' : '1st Floor Plan'}</option>
                <option value="second_floor_plan">{isArabic ? 'مخطط الثاني (2nd Floor Plan)' : '2nd Floor Plan'}</option>
                <option value="roof_floor_plan">{isArabic ? 'مخطط السطح (Roof Floor Plan)' : 'Roof Floor Plan'}</option>
                <option value="elevations">{isArabic ? 'الواجهات (Elevations)' : 'Elevations'}</option>
                <option value="schedules">{isArabic ? 'جداول الفتحات والأبواب (Schedules)' : 'Schedules (Doors/Windows)'}</option>
              </select>
            </div>
          ))}
        </div>

        <button className="btn btn-primary" onClick={handleSaveClassifications} style={{ width: '100%' }} disabled={loading}>
          {loading ? (
            <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '8px' }}>
              <div className="spin-anim" style={{ width: '16px', height: '16px', border: '2px solid white', borderTopColor: 'transparent', borderRadius: '50%' }}></div>
              <span>{isArabic ? 'جاري الحفظ...' : 'Saving & Proceeding...'}</span>
            </div>
          ) : (
            isArabic ? 'حفظ وتأكيد التصنيفات' : 'Save & Proceed to Extraction'
          )}
        </button>
      </div>
    </div>
  );
}