···
// Check if this is the user's own project
const isOwnProject = isDID && profile?.isOwner
+
// Check if user is authenticated and can make proposals
+
const canEdit = isDID && profile !== null
+
const isProposal = isDID && !profile?.isOwner && profile !== null
console.log('Debug - isOwnProject:', isOwnProject, 'isDID:', isDID, 'profile?.isOwner:', profile?.isOwner)
+
console.log('Debug - canEdit:', canEdit, 'isProposal:', isProposal)
// Check if we have public/fallback data
const hasPublicData = statusMessage && statusMessage.includes('public data')
···
const handleSave = async (field: string) => {
console.error('Not authorized to edit this profile')
···
(projectStatus?.categories || []),
impactMetrics: projectStatus?.impactMetrics || [],
geographicDistribution: projectStatus?.geographicDistribution || [],
+
// Add proposal-specific parameters
+
targetDid: isProposal ? id : undefined,
const response = await fetch('/api/project-status', {
···
+
const responseData = await response.json()
+
if (responseData.isProposal) {
+
// Handle proposal success
+
alert('Proposal submitted successfully! The project owner will be able to review your suggested changes.')
+
// Handle direct update success
+
setProjectStatus({...projectStatus, ...updatedData})
// Clear temporary input values
categoriesInput: undefined
+
console.log('Successfully saved', field, responseData.isProposal ? 'as proposal' : 'as direct update')
const errorData = await response.json()
console.error('Save failed:', errorData.error)
···
+
{/* Proposal Status Message */}
+
<div className="bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4 mb-6">
+
<div className="flex items-start">
+
<div className="flex-shrink-0">
+
<svg className="h-5 w-5 text-amber-400" viewBox="0 0 20 20" fill="currentColor">
+
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
+
<p className="text-sm text-amber-700 dark:text-amber-300">
+
You're viewing someone else's project. Any changes you make will be saved as proposals to your own repository for the project owner to review.
<div className="bg-surface border-subtle shadow-card p-4 sm:p-6 group">
<div className="flex flex-col sm:flex-row sm:items-start justify-between mb-4 sm:mb-6 gap-4">
···
onClick={() => handleSave('name')}
className="p-1 text-accent hover:text-accent-hover disabled:opacity-50"
+
title={isProposal ? "Submit proposal" : "Save changes"}
<Save className="h-4 w-4" />
···
<h1 className="text-2xl sm:text-3xl font-serif font-semibold text-primary">
{editValues.name || project?.name || `${displayName}'s project`}
onClick={() => handleEdit('name')}
className="p-1 text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-opacity"
+
title={isProposal ? "Propose change" : "Edit"}
<Edit2 className="h-4 w-4" />
···
onClick={() => handleSave('description')}
className="p-1 text-accent hover:text-accent-hover disabled:opacity-50"
+
title={isProposal ? "Submit proposal" : "Save changes"}
<Save className="h-4 w-4" />
···
<div className="flex items-start gap-2">
<p className="text-sm sm:text-lg text-secondary leading-relaxed flex-1">
+
{editValues.description || project?.description || (canEdit ? (isProposal ? 'Click to propose a description for this environmental project...' : 'Click to add a description of your environmental project...') : 'No project details have been added yet.')}
onClick={() => handleEdit('description')}
className="p-1 text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-opacity"
+
title={isProposal ? "Propose change" : "Edit"}
<Edit2 className="h-4 w-4" />
···
onClick={() => handleSave('website')}
className="p-1 text-accent hover:text-accent-hover disabled:opacity-50"
+
title={isProposal ? "Submit proposal" : "Save changes"}
<Save className="h-3 w-3" />
···
<ExternalLink className="h-4 w-4 ml-1" />
+
<div className={`inline-flex items-center text-muted text-sm ${canEdit ? 'cursor-pointer' : 'opacity-50'}`}>
<ExternalLink className="h-4 w-4 mr-1" />
+
{canEdit ? (isProposal ? 'Click to propose website' : 'Click to add website') : 'Website not specified'}
onClick={() => handleEdit('website')}
className="p-1 text-muted hover:text-primary opacity-0 group-hover:opacity-100 transition-opacity"
+
title={isProposal ? "Propose change" : "Edit"}
<Edit2 className="h-3 w-3" />
···
onClick={() => handleSave('categories')}
className="p-1 text-accent hover:text-accent-hover disabled:opacity-50"
+
title={isProposal ? "Submit proposal" : "Save changes"}
<Save className="h-3 w-3" />
···
<span className="inline-flex items-center px-2 py-1 text-xs font-medium bg-surface-hover text-muted border-dashed border border-border">
+
{canEdit ? (isProposal ? '+ Propose categories' : '+ Add categories') : 'No categories set'}
onClick={() => handleEdit('categories')}
className="inline-flex items-center px-2 py-1 text-xs font-medium bg-surface-hover text-muted hover:text-primary border-dashed border border-border opacity-0 group-hover:opacity-100 transition-opacity ml-1"
+
title={isProposal ? "Propose categories" : "Edit categories"}
<Edit2 className="h-3 w-3 mr-1" />
+
{isProposal ? 'Propose' : 'Edit'}