larxius commited on
Commit
5dfe702
·
verified ·
1 Parent(s): 381b43d

Update frontend/src/pages/Profile.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/Profile.jsx +53 -33
frontend/src/pages/Profile.jsx CHANGED
@@ -133,6 +133,24 @@ export const Profile = () => {
133
  }
134
  };
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  const handleDragOver = (e) => {
137
  e.preventDefault();
138
  e.stopPropagation();
@@ -613,24 +631,39 @@ export const Profile = () => {
613
  {/* Second Row for Report Branding */}
614
  {(profile.role === 'super_admin' || profile.role === 'org_admin') && (
615
  <div className="w-full bg-white border border-[#e5e7eb] rounded-xl shadow-xs p-6 md:p-8 mt-6">
616
- <div className="flex items-center gap-2 mb-1">
617
- <span className="material-symbols-outlined text-[#2563eb] text-[22px]">palette</span>
618
- <h3 className="font-bold text-[#111827] text-[18px] m-0">
619
- Report Branding
620
- </h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  </div>
622
- <p className="text-[#4b5563] text-sm mt-1 mb-5 m-0">
623
- Customize generated PDF security reports with your organization's logo.
624
- </p>
625
 
626
- <div className="border-t border-[#f3f4f6] pt-6">
627
  <div
628
  onDragOver={handleDragOver}
629
  onDragEnter={handleDragOver}
630
  onDragLeave={handleDragLeave}
631
  onDrop={handleDrop}
632
  onClick={() => fileInputRef.current?.click()}
633
- className={`relative border-2 border-dashed rounded-xl py-12 px-6 flex flex-col items-center justify-center text-center transition-all duration-200 cursor-pointer ${
634
  isDragging
635
  ? 'border-[#2563eb] bg-[#eff6ff] scale-[1.005]'
636
  : 'border-[#d1d5db] bg-[#f9fafb] hover:border-[#9ca3af] hover:bg-[#f3f4f6]'
@@ -648,24 +681,11 @@ export const Profile = () => {
648
  className="hidden"
649
  />
650
 
651
- <div className="pointer-events-none flex flex-col items-center justify-center">
652
- <span className={`material-symbols-outlined text-[36px] text-[#2563eb] mb-3 transition-transform ${isDragging ? 'scale-110' : ''} ${uploadingLogo ? 'animate-spin' : ''}`}>
653
- {uploadingLogo ? 'sync' : 'cloud'}
654
- </span>
655
-
656
- <h4 className="font-bold text-[#111827] text-[16px] mb-1 m-0">
657
- {isDragging ? 'Drop Image Here to Upload' : 'Upload Organization Logo'}
658
- </h4>
659
- <p className="text-[#6b7280] text-sm mt-1 mb-5 m-0">
660
- {isDragging ? 'Release to upload your custom logo immediately' : 'Upload your custom logo to brand all PDF security reports'}
661
- </p>
662
-
663
- {reportLogoUrl && (
664
- <div className="mb-5 p-3 bg-white rounded-lg border border-[#e5e7eb] shadow-2xs flex items-center justify-center pointer-events-auto">
665
- <img src={reportLogoUrl} alt="Organization Logo" className="max-h-16 max-w-xs object-contain" />
666
- </div>
667
- )}
668
- </div>
669
 
670
  <button
671
  type="button"
@@ -674,16 +694,16 @@ export const Profile = () => {
674
  e.stopPropagation();
675
  fileInputRef.current?.click();
676
  }}
677
- className="relative z-20 bg-[#2563eb] hover:bg-[#1d4ed8] text-white font-semibold px-5 py-2.5 rounded-lg flex items-center gap-2 text-sm shadow-xs transition-colors cursor-pointer mb-4 disabled:opacity-50"
678
  >
679
  <span className={`material-symbols-outlined text-[18px] ${uploadingLogo ? 'animate-spin' : ''}`}>
680
- {uploadingLogo ? 'sync' : 'upload'}
681
  </span>
682
- <span>{uploadingLogo ? 'Uploading...' : (reportLogoUrl ? 'Change Logo' : 'Upload Here')}</span>
683
  </button>
684
 
685
- <p className="text-[#6b7280] text-[12px] m-0 font-normal pointer-events-none">
686
- Supported formats: PNG, JPG, WebP, SVG (Max 5MB)
687
  </p>
688
  </div>
689
  </div>
 
133
  }
134
  };
135
 
136
+ const handleRemoveLogo = async () => {
137
+ try {
138
+ const res = await fetch('/api/auth/organizations/logo', {
139
+ method: 'DELETE',
140
+ headers: { 'Authorization': `Bearer ${token}` }
141
+ });
142
+ if (res.ok) {
143
+ setReportLogoUrl('');
144
+ toast.success("Logo removed successfully.");
145
+ fetchBrandingManual();
146
+ } else {
147
+ toast.error("Failed to remove logo.");
148
+ }
149
+ } catch (err) {
150
+ toast.error("Error removing logo.");
151
+ }
152
+ };
153
+
154
  const handleDragOver = (e) => {
155
  e.preventDefault();
156
  e.stopPropagation();
 
631
  {/* Second Row for Report Branding */}
632
  {(profile.role === 'super_admin' || profile.role === 'org_admin') && (
633
  <div className="w-full bg-white border border-[#e5e7eb] rounded-xl shadow-xs p-6 md:p-8 mt-6">
634
+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-4">
635
+ <div>
636
+ <div className="flex items-center gap-2">
637
+ <span className="material-symbols-outlined text-[#2563eb] text-[22px]">palette</span>
638
+ <h3 className="font-bold text-[#111827] text-[18px] m-0">
639
+ Report Branding
640
+ </h3>
641
+ </div>
642
+ <p className="text-[#4b5563] text-sm mt-1 m-0">
643
+ Customize generated PDF security reports with your organization's logo.
644
+ </p>
645
+ </div>
646
+
647
+ {reportLogoUrl && (
648
+ <button
649
+ type="button"
650
+ onClick={handleRemoveLogo}
651
+ className="shrink-0 border border-[#fecaca] hover:bg-[#fef2f2] hover:border-[#fca5a5] text-[#dc2626] font-medium text-xs px-3.5 py-2 rounded-lg flex items-center gap-1.5 transition-colors cursor-pointer border-solid self-start sm:self-auto"
652
+ >
653
+ <span className="material-symbols-outlined text-[16px]">delete</span>
654
+ <span>Remove Logo</span>
655
+ </button>
656
+ )}
657
  </div>
 
 
 
658
 
659
+ <div className="border-t border-[#e5e7eb] pt-6">
660
  <div
661
  onDragOver={handleDragOver}
662
  onDragEnter={handleDragOver}
663
  onDragLeave={handleDragLeave}
664
  onDrop={handleDrop}
665
  onClick={() => fileInputRef.current?.click()}
666
+ className={`relative border-2 border-dashed rounded-xl py-10 px-6 flex flex-col items-center justify-center text-center transition-all duration-200 cursor-pointer ${
667
  isDragging
668
  ? 'border-[#2563eb] bg-[#eff6ff] scale-[1.005]'
669
  : 'border-[#d1d5db] bg-[#f9fafb] hover:border-[#9ca3af] hover:bg-[#f3f4f6]'
 
681
  className="hidden"
682
  />
683
 
684
+ {reportLogoUrl && (
685
+ <div className="mb-6 p-4 bg-white rounded-xl border border-[#e5e7eb] shadow-xs flex items-center justify-center max-w-sm w-full pointer-events-auto">
686
+ <img src={reportLogoUrl} alt="Organization Logo" className="max-h-24 max-w-full object-contain" />
687
+ </div>
688
+ )}
 
 
 
 
 
 
 
 
 
 
 
 
 
689
 
690
  <button
691
  type="button"
 
694
  e.stopPropagation();
695
  fileInputRef.current?.click();
696
  }}
697
+ className="relative z-20 bg-[#2563eb] hover:bg-[#1d4ed8] text-white font-semibold px-6 py-2.5 rounded-lg flex items-center gap-2 text-sm shadow-xs transition-colors cursor-pointer mb-4 disabled:opacity-50"
698
  >
699
  <span className={`material-symbols-outlined text-[18px] ${uploadingLogo ? 'animate-spin' : ''}`}>
700
+ {uploadingLogo ? 'sync' : 'upload_file'}
701
  </span>
702
+ <span>{uploadingLogo ? 'Uploading...' : 'Upload Here (Change Logo)'}</span>
703
  </button>
704
 
705
+ <p className="text-[#6b7280] text-sm m-0 font-normal pointer-events-none">
706
+ Or drag and drop a new logo file above (PNG, JPG, WebP, SVG up to 5MB)
707
  </p>
708
  </div>
709
  </div>