SCGR commited on
Commit
29b7d98
·
1 Parent(s): fd3d1a8

contribute update

Browse files
frontend/src/pages/MapDetailsPage/MapDetailPage.tsx CHANGED
@@ -107,6 +107,7 @@ export default function MapDetailPage() {
107
  const [droneImagesSelected, setDroneImagesSelected] = useState(true);
108
 
109
  const [isDeleting, setIsDeleting] = useState(false);
 
110
 
111
  const {
112
  search, setSearch,
@@ -607,7 +608,12 @@ export default function MapDetailPage() {
607
  return matchesSearch && matchesSource && matchesCategory && matchesRegion && matchesCountry && matchesImageType && matchesReferenceExamples ? map : null;
608
  }, [map, search, srcFilter, catFilter, regionFilter, countryFilter, imageTypeFilter, showReferenceExamples]);
609
 
610
- const handleContribute = async () => {
 
 
 
 
 
611
  if (!map) return;
612
 
613
  setIsGenerating(true);
@@ -655,8 +661,8 @@ export default function MapDetailPage() {
655
  console.log('Caption generation response:', captionData);
656
 
657
  // Now navigate to the upload page with the processed data
658
- const url = `/upload?imageUrl=${encodeURIComponent(json.image_url)}&isContribution=true&step=2a&imageId=${newId}&imageType=${map.image_type}`;
659
- navigate(url);
660
 
661
  } catch (error: unknown) {
662
  console.error('Contribution failed:', error);
@@ -665,6 +671,10 @@ export default function MapDetailPage() {
665
  setIsGenerating(false);
666
  }
667
  };
 
 
 
 
668
 
669
  const createImageData = (map: any, fileName: string) => ({
670
  image: `images/${fileName}`,
@@ -1374,6 +1384,44 @@ export default function MapDetailPage() {
1374
  </div>
1375
  )}
1376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1377
  {/* Export Selection Modal */}
1378
  {showExportModal && (
1379
  <ExportModal
 
107
  const [droneImagesSelected, setDroneImagesSelected] = useState(true);
108
 
109
  const [isDeleting, setIsDeleting] = useState(false);
110
+ const [showContributeConfirm, setShowContributeConfirm] = useState(false);
111
 
112
  const {
113
  search, setSearch,
 
608
  return matchesSearch && matchesSource && matchesCategory && matchesRegion && matchesCountry && matchesImageType && matchesReferenceExamples ? map : null;
609
  }, [map, search, srcFilter, catFilter, regionFilter, countryFilter, imageTypeFilter, showReferenceExamples]);
610
 
611
+ const handleContribute = () => {
612
+ if (!map) return;
613
+ setShowContributeConfirm(true);
614
+ };
615
+
616
+ const handleContributeConfirm = async () => {
617
  if (!map) return;
618
 
619
  setIsGenerating(true);
 
661
  console.log('Caption generation response:', captionData);
662
 
663
  // Now navigate to the upload page with the processed data
664
+ const url = `/upload?imageUrl=${encodeURIComponent(json.image_url)}&isContribution=true&step=2a&imageId=${newId}&imageType=${map.image_type}`;
665
+ navigate(url);
666
 
667
  } catch (error: unknown) {
668
  console.error('Contribution failed:', error);
 
671
  setIsGenerating(false);
672
  }
673
  };
674
+
675
+ const handleContributeCancel = () => {
676
+ setShowContributeConfirm(false);
677
+ };
678
 
679
  const createImageData = (map: any, fileName: string) => ({
680
  image: `images/${fileName}`,
 
1384
  </div>
1385
  )}
1386
 
1387
+ {/* Contribute Confirmation Modal */}
1388
+ {showContributeConfirm && (
1389
+ <div className={styles.fullSizeModalOverlay} onClick={handleContributeCancel}>
1390
+ <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
1391
+ <div className={styles.ratingWarningContent}>
1392
+ <p className={styles.ratingWarningText}>
1393
+ This will start a new independent upload with just the image.
1394
+ </p>
1395
+ {!isGenerating && (
1396
+ <div className={styles.ratingWarningButtons}>
1397
+ <Button
1398
+ name="confirm-contribute"
1399
+ variant="secondary"
1400
+ onClick={handleContributeConfirm}
1401
+ >
1402
+ Continue
1403
+ </Button>
1404
+ <Button
1405
+ name="cancel-contribute"
1406
+ variant="tertiary"
1407
+ onClick={handleContributeCancel}
1408
+ >
1409
+ Cancel
1410
+ </Button>
1411
+ </div>
1412
+ )}
1413
+ {isGenerating && (
1414
+ <div className="flex flex-col items-center gap-2 mt-4">
1415
+ <Spinner className="text-ifrcRed" />
1416
+ <div className="text-sm font-medium">Generating...</div>
1417
+ <div className="text-xs text-gray-600">This might take a few seconds</div>
1418
+ </div>
1419
+ )}
1420
+ </div>
1421
+ </div>
1422
+ </div>
1423
+ )}
1424
+
1425
  {/* Export Selection Modal */}
1426
  {showExportModal && (
1427
  <ExportModal
frontend/src/pages/UploadPage/UploadPage.tsx CHANGED
@@ -1675,13 +1675,24 @@ export default function UploadPage() {
1675
  {step === 3 && (
1676
  <div className={styles.successContainer}>
1677
  <Heading level={2} className={styles.successHeading}>Saved!</Heading>
1678
- <p className={styles.successText}>Your caption has been successfully saved.</p>
 
 
 
 
 
1679
  <div className={styles.successButton}>
1680
  <Button
1681
- name="upload-another"
1682
- onClick={resetToStep1}
 
 
 
 
 
 
1683
  >
1684
- Upload Another
1685
  </Button>
1686
  </div>
1687
  </div>
 
1675
  {step === 3 && (
1676
  <div className={styles.successContainer}>
1677
  <Heading level={2} className={styles.successHeading}>Saved!</Heading>
1678
+ <p className={styles.successText}>
1679
+ {searchParams.get('isContribution') === 'true'
1680
+ ? 'Your contribution has been successfully saved.'
1681
+ : 'Your caption has been successfully saved.'
1682
+ }
1683
+ </p>
1684
  <div className={styles.successButton}>
1685
  <Button
1686
+ name={searchParams.get('isContribution') === 'true' ? 'back-to-explore' : 'upload-another'}
1687
+ onClick={() => {
1688
+ if (searchParams.get('isContribution') === 'true') {
1689
+ navigate('/explore');
1690
+ } else {
1691
+ resetToStep1();
1692
+ }
1693
+ }}
1694
  >
1695
+ {searchParams.get('isContribution') === 'true' ? 'Back to Explore' : 'Upload Another'}
1696
  </Button>
1697
  </div>
1698
  </div>