SCGR commited on
Commit
ad5f9c7
·
1 Parent(s): abcce96

merge text boxes

Browse files
frontend/src/pages/MapDetailsPage/MapDetailPage.tsx CHANGED
@@ -965,75 +965,34 @@ export default function MapDetailPage() {
965
  </div>
966
  </Container>
967
 
968
- {/* Three-Part Analysis Structure */}
969
  {filteredMap.raw_json ? (
970
  <>
971
  {/* Try to extract three parts from edited field first (new format) */}
972
  {filteredMap.edited && filteredMap.edited.includes('Description:') ? (
973
- <>
974
- <Container
975
- heading="Description"
976
- headingLevel={3}
977
- withHeaderBorder
978
- withInternalPadding
979
- spacing="comfortable"
980
- >
981
- <div className={styles.captionContainer}>
982
- {(() => {
983
- const descMatch = filteredMap.edited.match(/Description:\s*(.*?)(?=\n\nAnalysis:|$)/s);
984
- return descMatch ? (
985
- <div className={styles.captionText}>
986
- <p>{descMatch[1].trim()}</p>
987
- </div>
988
- ) : (
989
- <p className="text-gray-500 italic">— no description available —</p>
990
- );
991
- })()}
992
- </div>
993
- </Container>
994
-
995
- <Container
996
- heading="Analysis"
997
- headingLevel={3}
998
- withHeaderBorder
999
- withInternalPadding
1000
- spacing="comfortable"
1001
- >
1002
- <div className={styles.captionContainer}>
1003
- {(() => {
1004
- const analysisMatch = filteredMap.edited.match(/Analysis:\s*(.*?)(?=\n\nRecommended Actions:|$)/s);
1005
- return analysisMatch ? (
1006
- <div className={styles.captionText}>
1007
- <p>{analysisMatch[1].trim()}</p>
1008
- </div>
1009
- ) : (
1010
- <p className="text-gray-500 italic">— no analysis available —</p>
1011
- );
1012
- })()}
1013
- </div>
1014
- </Container>
1015
-
1016
- <Container
1017
- heading="Recommended Actions"
1018
- headingLevel={3}
1019
- withHeaderBorder
1020
- withInternalPadding
1021
- spacing="comfortable"
1022
- >
1023
- <div className={styles.captionContainer}>
1024
- {(() => {
1025
- const actionsMatch = filteredMap.edited.match(/Recommended Actions:\s*(.*?)$/s);
1026
- return actionsMatch ? (
1027
- <div className={styles.captionText}>
1028
- <p>{actionsMatch[1].trim()}</p>
1029
- </div>
1030
- ) : (
1031
- <p className="text-gray-500 italic">— no recommended actions available —</p>
1032
- );
1033
- })()}
1034
  </div>
1035
- </Container>
1036
- </>
1037
  ) : (
1038
  <Container
1039
  heading="Description"
 
965
  </div>
966
  </Container>
967
 
968
+ {/* Combined Analysis Structure */}
969
  {filteredMap.raw_json ? (
970
  <>
971
  {/* Try to extract three parts from edited field first (new format) */}
972
  {filteredMap.edited && filteredMap.edited.includes('Description:') ? (
973
+ <Container
974
+ heading="AI Generated Content"
975
+ headingLevel={3}
976
+ withHeaderBorder
977
+ withInternalPadding
978
+ spacing="comfortable"
979
+ >
980
+ <div className={styles.captionContainer}>
981
+ <div className={styles.captionText}>
982
+ {filteredMap.edited.split('\n').map((line, index) => (
983
+ <div key={index}>
984
+ {line.startsWith('Description:') || line.startsWith('Analysis:') || line.startsWith('Recommended Actions:') ? (
985
+ <h4 className="font-semibold text-gray-800 mt-4 mb-2">{line}</h4>
986
+ ) : line.trim() === '' ? (
987
+ <br />
988
+ ) : (
989
+ <p className="mb-2">{line}</p>
990
+ )}
991
+ </div>
992
+ ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
993
  </div>
994
+ </div>
995
+ </Container>
996
  ) : (
997
  <Container
998
  heading="Description"
frontend/src/pages/UploadPage/UploadPage.tsx CHANGED
@@ -1353,41 +1353,26 @@ export default function UploadPage() {
1353
  >
1354
  <div className="text-left space-y-4">
1355
  <div>
1356
- <label className="block text-sm font-medium text-gray-700 mb-2">
1357
- Description
1358
- </label>
1359
  <TextArea
1360
- name="description"
1361
- value={description}
1362
- onChange={(value) => setDescription(value || '')}
1363
- rows={4}
1364
- placeholder="AI-generated description will appear here..."
1365
- />
1366
- </div>
1367
-
1368
- <div>
1369
- <label className="block text-sm font-medium text-gray-700 mb-2">
1370
- Analysis
1371
- </label>
1372
- <TextArea
1373
- name="analysis"
1374
- value={analysis}
1375
- onChange={(value) => setAnalysis(value || '')}
1376
- rows={4}
1377
- placeholder="AI-generated analysis will appear here..."
1378
- />
1379
- </div>
1380
-
1381
- <div>
1382
- <label className="block text-sm font-medium text-gray-700 mb-2">
1383
- Recommended Actions
1384
- </label>
1385
- <TextArea
1386
- name="recommendedActions"
1387
- value={recommendedActions}
1388
- onChange={(value) => setRecommendedActions(value || '')}
1389
- rows={4}
1390
- placeholder="AI-generated recommended actions will appear here..."
1391
  />
1392
  </div>
1393
  </div>
 
1353
  >
1354
  <div className="text-left space-y-4">
1355
  <div>
 
 
 
1356
  <TextArea
1357
+ name="generatedContent"
1358
+ value={`Description:\n${description || 'AI-generated description will appear here...'}\n\nAnalysis:\n${analysis || 'AI-generated analysis will appear here...'}\n\nRecommended Actions:\n${recommendedActions || 'AI-generated recommended actions will appear here...'}`}
1359
+ onChange={(value) => {
1360
+ // Parse the combined text back into separate fields
1361
+ if (value) {
1362
+ const lines = value.split('\n');
1363
+ const descIndex = lines.findIndex(line => line.startsWith('Description:'));
1364
+ const analysisIndex = lines.findIndex(line => line.startsWith('Analysis:'));
1365
+ const actionsIndex = lines.findIndex(line => line.startsWith('Recommended Actions:'));
1366
+
1367
+ if (descIndex !== -1 && analysisIndex !== -1 && actionsIndex !== -1) {
1368
+ setDescription(lines.slice(descIndex + 1, analysisIndex).join('\n').trim());
1369
+ setAnalysis(lines.slice(analysisIndex + 1, actionsIndex).join('\n').trim());
1370
+ setRecommendedActions(lines.slice(actionsIndex + 1).join('\n').trim());
1371
+ }
1372
+ }
1373
+ }}
1374
+ rows={12}
1375
+ placeholder="AI-generated content will appear here..."
 
 
 
 
 
 
 
 
 
 
 
 
1376
  />
1377
  </div>
1378
  </div>