Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7a8765f58 | |||
| 214f120f7a | |||
| f26becad1d | |||
| 67ff415840 | |||
| 88659f1fa6 | |||
| c1e10f14a3 | |||
| 0881a0fa71 | |||
| e91209f7cb | |||
| 828d6bc456 | |||
| f945573f09 | |||
| 296430e4d7 |
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ jobs:
|
|||||||
# Remove sensitive files/directories if they exist
|
# Remove sensitive files/directories if they exist
|
||||||
echo "Removing sensitive files..."
|
echo "Removing sensitive files..."
|
||||||
rm -rf .gitea/ || true
|
rm -rf .gitea/ || true
|
||||||
rm -rf scripts/ || true
|
rm -rf scripts/install-gitea-runner.sh || true
|
||||||
rm -rf .drone* || true
|
rm -rf .drone* || true
|
||||||
rm -rf photo-sharing-prd.md || true
|
rm -rf photo-sharing-prd.md || true
|
||||||
rm -rf CLAUDE.md || true
|
rm -rf CLAUDE.md || true
|
||||||
|
|||||||
Binary file not shown.
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.850.0",
|
"@aws-sdk/client-s3": "^3.850.0",
|
||||||
"@aws-sdk/lib-storage": "^3.850.0",
|
"@aws-sdk/lib-storage": "^3.850.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-backend",
|
"name": "picpeak-backend",
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"description": "Backend for PicPeak event photo sharing platform",
|
"description": "Backend for PicPeak event photo sharing platform",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ router.put('/events/:eventId/feedback-settings',
|
|||||||
settings: updatedSettings
|
settings: updatedSettings
|
||||||
}, eventId, {
|
}, eventId, {
|
||||||
type: 'admin',
|
type: 'admin',
|
||||||
id: req.user.id,
|
id: req.admin.id,
|
||||||
name: req.user.username
|
name: req.admin.username
|
||||||
});
|
});
|
||||||
|
|
||||||
res.json(updatedSettings);
|
res.json(updatedSettings);
|
||||||
@@ -167,7 +167,7 @@ router.put('/feedback/:feedbackId/:action',
|
|||||||
return res.status(400).json({ error: 'Invalid action' });
|
return res.status(400).json({ error: 'Invalid action' });
|
||||||
}
|
}
|
||||||
|
|
||||||
await feedbackService.moderateFeedback(feedbackId, action, req.user.id);
|
await feedbackService.moderateFeedback(feedbackId, action, req.admin.id);
|
||||||
|
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -184,7 +184,7 @@ router.delete('/feedback/:feedbackId',
|
|||||||
try {
|
try {
|
||||||
const { feedbackId } = req.params;
|
const { feedbackId } = req.params;
|
||||||
|
|
||||||
await feedbackService.deleteFeedback(feedbackId, req.user.id);
|
await feedbackService.deleteFeedback(feedbackId, req.admin.id);
|
||||||
|
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -24,14 +24,15 @@ router.get('/:slug/feedback-settings',
|
|||||||
const settings = await feedbackService.getEventFeedbackSettings(event.id);
|
const settings = await feedbackService.getEventFeedbackSettings(event.id);
|
||||||
|
|
||||||
// Only send relevant settings to guests
|
// Only send relevant settings to guests
|
||||||
|
// Convert SQLite boolean values (0/1) to proper booleans
|
||||||
const guestSettings = {
|
const guestSettings = {
|
||||||
feedback_enabled: settings.feedback_enabled,
|
feedback_enabled: Boolean(settings.feedback_enabled),
|
||||||
allow_ratings: settings.allow_ratings,
|
allow_ratings: Boolean(settings.allow_ratings),
|
||||||
allow_likes: settings.allow_likes,
|
allow_likes: Boolean(settings.allow_likes),
|
||||||
allow_comments: settings.allow_comments,
|
allow_comments: Boolean(settings.allow_comments),
|
||||||
allow_favorites: settings.allow_favorites,
|
allow_favorites: Boolean(settings.allow_favorites),
|
||||||
require_name_email: settings.require_name_email,
|
require_name_email: Boolean(settings.require_name_email),
|
||||||
show_feedback_to_guests: settings.show_feedback_to_guests
|
show_feedback_to_guests: Boolean(settings.show_feedback_to_guests)
|
||||||
};
|
};
|
||||||
|
|
||||||
res.json(guestSettings);
|
res.json(guestSettings);
|
||||||
|
|||||||
@@ -227,11 +227,17 @@ async function validateGuestRequirements(settings, guestData) {
|
|||||||
|
|
||||||
const errors = [];
|
const errors = [];
|
||||||
|
|
||||||
if (!guestData.guest_name || guestData.guest_name.trim().length === 0) {
|
// Check for name - handle both undefined and empty strings
|
||||||
|
const name = guestData.guest_name;
|
||||||
|
if (!name || (typeof name === 'string' && name.trim().length === 0)) {
|
||||||
errors.push('Name is required');
|
errors.push('Name is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!guestData.guest_email || !validator.isEmail(guestData.guest_email)) {
|
// Check for email - handle both undefined and empty strings
|
||||||
|
const email = guestData.guest_email;
|
||||||
|
if (!email || (typeof email === 'string' && email.trim().length === 0)) {
|
||||||
|
errors.push('Email is required');
|
||||||
|
} else if (email && typeof email === 'string' && !validator.isEmail(email.trim())) {
|
||||||
errors.push('Valid email is required');
|
errors.push('Valid email is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ server {
|
|||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
|
# Allow larger file uploads (up to 100MB)
|
||||||
|
client_max_body_size 100M;
|
||||||
|
client_body_timeout 300s;
|
||||||
|
|
||||||
# Gzip compression
|
# Gzip compression
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
@@ -49,6 +53,10 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
proxy_cache_bypass $http_upgrade;
|
proxy_cache_bypass $http_upgrade;
|
||||||
proxy_read_timeout 86400;
|
proxy_read_timeout 86400;
|
||||||
|
|
||||||
|
# Allow larger uploads for API endpoints
|
||||||
|
client_max_body_size 100M;
|
||||||
|
client_body_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Photo serving proxy
|
# Photo serving proxy
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/react-query": "^5.0.0",
|
"@tanstack/react-query": "^5.0.0",
|
||||||
"@tiptap/extension-character-count": "^2.26.1",
|
"@tiptap/extension-character-count": "^2.26.1",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "picpeak-frontend",
|
"name": "picpeak-frontend",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.105",
|
"version": "1.0.108",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -118,14 +118,30 @@ export const FeedbackModerationPanel: React.FC<FeedbackModerationPanelProps> = (
|
|||||||
</span>
|
</span>
|
||||||
<span className="text-neutral-500">•</span>
|
<span className="text-neutral-500">•</span>
|
||||||
<span className="text-neutral-500">
|
<span className="text-neutral-500">
|
||||||
{format(parseISO(item.created_at), 'MMM d, h:mm a')}
|
{format(
|
||||||
|
typeof item.created_at === 'string'
|
||||||
|
? parseISO(item.created_at)
|
||||||
|
: new Date(item.created_at),
|
||||||
|
'MMM d, h:mm a'
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-sm text-neutral-700">{item.comment}</p>
|
<p className="mt-1 text-sm text-neutral-700">{item.comment_text || item.comment}</p>
|
||||||
{item.photo_filename && (
|
{item.photo_id && (
|
||||||
<p className="mt-1 text-xs text-neutral-500">
|
<div className="mt-2 flex items-center gap-2">
|
||||||
{t('feedback.onPhoto', 'On photo')}: {item.photo_filename}
|
<img
|
||||||
</p>
|
src={`/api/admin/photos/${eventId}/thumbnail/${item.photo_id}`}
|
||||||
|
alt={item.filename || 'Photo'}
|
||||||
|
className="w-16 h-16 object-cover rounded"
|
||||||
|
onError={(e) => {
|
||||||
|
// Hide image if thumbnail fails to load
|
||||||
|
(e.target as HTMLImageElement).style.display = 'none';
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<p className="text-xs text-neutral-500">
|
||||||
|
{t('feedback.onPhoto', 'On photo')}: {item.filename || item.photo_filename || `#${item.photo_id}`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { X } from 'lucide-react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { Button, Input } from '../common';
|
||||||
|
|
||||||
|
interface FeedbackIdentityModalProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
onSubmit: (name: string, email: string) => void;
|
||||||
|
feedbackType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const FeedbackIdentityModal: React.FC<FeedbackIdentityModalProps> = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
onSubmit,
|
||||||
|
feedbackType
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [name, setName] = useState('');
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [errors, setErrors] = useState<Record<string, string>>({});
|
||||||
|
|
||||||
|
if (!isOpen) return null;
|
||||||
|
|
||||||
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const newErrors: Record<string, string> = {};
|
||||||
|
|
||||||
|
if (!name.trim()) {
|
||||||
|
newErrors.name = t('feedback.nameRequired', 'Name is required');
|
||||||
|
}
|
||||||
|
if (!email.trim()) {
|
||||||
|
newErrors.email = t('feedback.emailRequired', 'Email is required');
|
||||||
|
} else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||||
|
newErrors.email = t('feedback.invalidEmail', 'Invalid email address');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(newErrors).length > 0) {
|
||||||
|
setErrors(newErrors);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(name.trim(), email.trim());
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="fixed inset-0 z-50 flex items-center justify-center p-4">
|
||||||
|
<div className="fixed inset-0 bg-black bg-opacity-50" onClick={onClose} />
|
||||||
|
<div className="relative bg-white rounded-lg shadow-xl max-w-md w-full p-6">
|
||||||
|
<button
|
||||||
|
onClick={onClose}
|
||||||
|
className="absolute top-4 right-4 p-1 hover:bg-neutral-100 rounded-lg transition-colors"
|
||||||
|
>
|
||||||
|
<X className="w-5 h-5 text-neutral-600" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<h2 className="text-lg font-semibold text-neutral-900 mb-2">
|
||||||
|
{t('feedback.identityRequired', 'Your Information Required')}
|
||||||
|
</h2>
|
||||||
|
<p className="text-sm text-neutral-600 mb-4">
|
||||||
|
{t('feedback.identityReason', 'Please provide your name and email to submit {{type}}.', { type: feedbackType })}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||||||
|
<Input
|
||||||
|
label={t('feedback.yourName', 'Your Name')}
|
||||||
|
value={name}
|
||||||
|
onChange={(e) => setName(e.target.value)}
|
||||||
|
error={errors.name}
|
||||||
|
placeholder={t('feedback.namePlaceholder', 'Enter your name')}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
type="email"
|
||||||
|
label={t('feedback.yourEmail', 'Your Email')}
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
error={errors.email}
|
||||||
|
placeholder={t('feedback.emailPlaceholder', 'Enter your email')}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<div className="flex gap-2 pt-2">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="primary"
|
||||||
|
className="flex-1"
|
||||||
|
>
|
||||||
|
{t('feedback.submitFeedback', 'Submit Feedback')}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
onClick={onClose}
|
||||||
|
className="flex-1"
|
||||||
|
>
|
||||||
|
{t('common.cancel', 'Cancel')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -194,7 +194,7 @@ export const GallerySidebar: React.FC<GallerySidebarProps> = ({
|
|||||||
disabled={isDownloading}
|
disabled={isDownloading}
|
||||||
className="w-full"
|
className="w-full"
|
||||||
>
|
>
|
||||||
{t('gallery.downloadSelected')} ({selectedCount})
|
{t('gallery.downloadSelected', { count: selectedCount })} ({selectedCount})
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ export const PhotoComments: React.FC<PhotoCommentsProps> = ({
|
|||||||
|
|
||||||
submitCommentMutation.mutate({
|
submitCommentMutation.mutate({
|
||||||
comment_text: commentText.trim(),
|
comment_text: commentText.trim(),
|
||||||
guest_name: guestName.trim(),
|
guest_name: guestName.trim() || undefined,
|
||||||
guest_email: guestEmail.trim()
|
guest_email: guestEmail.trim() || undefined
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { feedbackService } from '../../services/feedback.service';
|
import { feedbackService } from '../../services/feedback.service';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { FeedbackIdentityModal } from './FeedbackIdentityModal';
|
||||||
|
|
||||||
interface PhotoFavoritesProps {
|
interface PhotoFavoritesProps {
|
||||||
photoId: string;
|
photoId: string;
|
||||||
@@ -11,6 +12,7 @@ interface PhotoFavoritesProps {
|
|||||||
isFavorited: boolean;
|
isFavorited: boolean;
|
||||||
favoriteCount: number;
|
favoriteCount: number;
|
||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
|
requireNameEmail?: boolean;
|
||||||
onFavoriteChange?: (favorited: boolean) => void;
|
onFavoriteChange?: (favorited: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,17 +22,22 @@ export const PhotoFavorites: React.FC<PhotoFavoritesProps> = ({
|
|||||||
isFavorited,
|
isFavorited,
|
||||||
favoriteCount,
|
favoriteCount,
|
||||||
isEnabled,
|
isEnabled,
|
||||||
|
requireNameEmail = false,
|
||||||
onFavoriteChange
|
onFavoriteChange
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [animating, setAnimating] = useState(false);
|
const [animating, setAnimating] = useState(false);
|
||||||
|
const [showIdentityModal, setShowIdentityModal] = useState(false);
|
||||||
|
const [savedIdentity, setSavedIdentity] = useState<{ name: string; email: string } | null>(null);
|
||||||
|
|
||||||
const submitFavoriteMutation = useMutation({
|
const submitFavoriteMutation = useMutation({
|
||||||
mutationFn: () =>
|
mutationFn: (data: { guest_name?: string; guest_email?: string } = {}) =>
|
||||||
feedbackService.submitFeedback(gallerySlug, photoId, {
|
feedbackService.submitFeedback(gallerySlug, photoId, {
|
||||||
feedback_type: 'favorite'
|
feedback_type: 'favorite',
|
||||||
|
guest_name: data.guest_name || undefined,
|
||||||
|
guest_email: data.guest_email || undefined
|
||||||
}),
|
}),
|
||||||
onMutate: async () => {
|
onMutate: async () => {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
@@ -62,13 +69,25 @@ export const PhotoFavorites: React.FC<PhotoFavoritesProps> = ({
|
|||||||
|
|
||||||
const handleFavoriteClick = () => {
|
const handleFavoriteClick = () => {
|
||||||
if (!isEnabled || isSubmitting) return;
|
if (!isEnabled || isSubmitting) return;
|
||||||
submitFavoriteMutation.mutate();
|
|
||||||
|
if (requireNameEmail && !savedIdentity) {
|
||||||
|
setShowIdentityModal(true);
|
||||||
|
} else {
|
||||||
|
submitFavoriteMutation.mutate(savedIdentity || {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleIdentitySubmit = (name: string, email: string) => {
|
||||||
|
setSavedIdentity({ name, email });
|
||||||
|
setShowIdentityModal(false);
|
||||||
|
submitFavoriteMutation.mutate({ guest_name: name, guest_email: email });
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isEnabled) return null;
|
if (!isEnabled) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<>
|
||||||
|
<button
|
||||||
onClick={handleFavoriteClick}
|
onClick={handleFavoriteClick}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className={`group flex items-center gap-2 px-3 py-2 rounded-lg transition-all ${
|
className={`group flex items-center gap-2 px-3 py-2 rounded-lg transition-all ${
|
||||||
@@ -88,6 +107,13 @@ export const PhotoFavorites: React.FC<PhotoFavoritesProps> = ({
|
|||||||
<span className="text-sm font-medium">
|
<span className="text-sm font-medium">
|
||||||
{favoriteCount > 0 ? favoriteCount : ''}
|
{favoriteCount > 0 ? favoriteCount : ''}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
<FeedbackIdentityModal
|
||||||
|
isOpen={showIdentityModal}
|
||||||
|
onClose={() => setShowIdentityModal(false)}
|
||||||
|
onSubmit={handleIdentitySubmit}
|
||||||
|
feedbackType={t('feedback.favorite', 'favorite')}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -26,7 +26,11 @@ export const PhotoFeedback: React.FC<PhotoFeedbackProps> = ({
|
|||||||
// Fetch feedback settings for the gallery
|
// Fetch feedback settings for the gallery
|
||||||
const { data: settings, isLoading: settingsLoading } = useQuery({
|
const { data: settings, isLoading: settingsLoading } = useQuery({
|
||||||
queryKey: ['gallery-feedback-settings', gallerySlug],
|
queryKey: ['gallery-feedback-settings', gallerySlug],
|
||||||
queryFn: () => feedbackService.getGalleryFeedbackSettings(gallerySlug),
|
queryFn: async () => {
|
||||||
|
const data = await feedbackService.getGalleryFeedbackSettings(gallerySlug);
|
||||||
|
console.log('PhotoFeedback received settings:', data);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
|
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -104,6 +108,7 @@ export const PhotoFeedback: React.FC<PhotoFeedbackProps> = ({
|
|||||||
averageRating={Number(feedbackData?.summary?.average_rating) || 0}
|
averageRating={Number(feedbackData?.summary?.average_rating) || 0}
|
||||||
totalRatings={Number(feedbackData?.summary?.total_ratings) || 0}
|
totalRatings={Number(feedbackData?.summary?.total_ratings) || 0}
|
||||||
isEnabled={true}
|
isEnabled={true}
|
||||||
|
requireNameEmail={settings.require_name_email || false}
|
||||||
onRatingChange={handleRatingChange}
|
onRatingChange={handleRatingChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -118,6 +123,7 @@ export const PhotoFeedback: React.FC<PhotoFeedbackProps> = ({
|
|||||||
isLiked={isLiked}
|
isLiked={isLiked}
|
||||||
likeCount={likeCount}
|
likeCount={likeCount}
|
||||||
isEnabled={true}
|
isEnabled={true}
|
||||||
|
requireNameEmail={settings.require_name_email || false}
|
||||||
onLikeChange={handleLikeChange}
|
onLikeChange={handleLikeChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -128,6 +134,7 @@ export const PhotoFeedback: React.FC<PhotoFeedbackProps> = ({
|
|||||||
isFavorited={isFavorited}
|
isFavorited={isFavorited}
|
||||||
favoriteCount={favoriteCount}
|
favoriteCount={favoriteCount}
|
||||||
isEnabled={true}
|
isEnabled={true}
|
||||||
|
requireNameEmail={settings.require_name_email || false}
|
||||||
onFavoriteChange={handleFavoriteChange}
|
onFavoriteChange={handleFavoriteChange}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { feedbackService } from '../../services/feedback.service';
|
import { feedbackService } from '../../services/feedback.service';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { FeedbackIdentityModal } from './FeedbackIdentityModal';
|
||||||
|
|
||||||
interface PhotoLikesProps {
|
interface PhotoLikesProps {
|
||||||
photoId: string;
|
photoId: string;
|
||||||
@@ -11,6 +12,7 @@ interface PhotoLikesProps {
|
|||||||
isLiked: boolean;
|
isLiked: boolean;
|
||||||
likeCount: number;
|
likeCount: number;
|
||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
|
requireNameEmail?: boolean;
|
||||||
onLikeChange?: (liked: boolean) => void;
|
onLikeChange?: (liked: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,17 +22,22 @@ export const PhotoLikes: React.FC<PhotoLikesProps> = ({
|
|||||||
isLiked,
|
isLiked,
|
||||||
likeCount,
|
likeCount,
|
||||||
isEnabled,
|
isEnabled,
|
||||||
|
requireNameEmail = false,
|
||||||
onLikeChange
|
onLikeChange
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [animating, setAnimating] = useState(false);
|
const [animating, setAnimating] = useState(false);
|
||||||
|
const [showIdentityModal, setShowIdentityModal] = useState(false);
|
||||||
|
const [savedIdentity, setSavedIdentity] = useState<{ name: string; email: string } | null>(null);
|
||||||
|
|
||||||
const submitLikeMutation = useMutation({
|
const submitLikeMutation = useMutation({
|
||||||
mutationFn: () =>
|
mutationFn: (data: { guest_name?: string; guest_email?: string } = {}) =>
|
||||||
feedbackService.submitFeedback(gallerySlug, photoId, {
|
feedbackService.submitFeedback(gallerySlug, photoId, {
|
||||||
feedback_type: 'like'
|
feedback_type: 'like',
|
||||||
|
guest_name: data.guest_name || undefined,
|
||||||
|
guest_email: data.guest_email || undefined
|
||||||
}),
|
}),
|
||||||
onMutate: async () => {
|
onMutate: async () => {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
@@ -62,13 +69,25 @@ export const PhotoLikes: React.FC<PhotoLikesProps> = ({
|
|||||||
|
|
||||||
const handleLikeClick = () => {
|
const handleLikeClick = () => {
|
||||||
if (!isEnabled || isSubmitting) return;
|
if (!isEnabled || isSubmitting) return;
|
||||||
submitLikeMutation.mutate();
|
|
||||||
|
if (requireNameEmail && !savedIdentity) {
|
||||||
|
setShowIdentityModal(true);
|
||||||
|
} else {
|
||||||
|
submitLikeMutation.mutate(savedIdentity || {});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleIdentitySubmit = (name: string, email: string) => {
|
||||||
|
setSavedIdentity({ name, email });
|
||||||
|
setShowIdentityModal(false);
|
||||||
|
submitLikeMutation.mutate({ guest_name: name, guest_email: email });
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isEnabled) return null;
|
if (!isEnabled) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<>
|
||||||
|
<button
|
||||||
onClick={handleLikeClick}
|
onClick={handleLikeClick}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
className={`group flex items-center gap-2 px-3 py-2 rounded-lg transition-all ${
|
className={`group flex items-center gap-2 px-3 py-2 rounded-lg transition-all ${
|
||||||
@@ -88,6 +107,13 @@ export const PhotoLikes: React.FC<PhotoLikesProps> = ({
|
|||||||
<span className="text-sm font-medium">
|
<span className="text-sm font-medium">
|
||||||
{likeCount > 0 ? likeCount : ''}
|
{likeCount > 0 ? likeCount : ''}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
<FeedbackIdentityModal
|
||||||
|
isOpen={showIdentityModal}
|
||||||
|
onClose={() => setShowIdentityModal(false)}
|
||||||
|
onSubmit={handleIdentitySubmit}
|
||||||
|
feedbackType={t('feedback.like', 'like')}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
import { feedbackService } from '../../services/feedback.service';
|
import { feedbackService } from '../../services/feedback.service';
|
||||||
import { toast } from 'react-toastify';
|
import { toast } from 'react-toastify';
|
||||||
|
import { FeedbackIdentityModal } from './FeedbackIdentityModal';
|
||||||
|
|
||||||
interface PhotoRatingProps {
|
interface PhotoRatingProps {
|
||||||
photoId: string;
|
photoId: string;
|
||||||
@@ -12,6 +13,7 @@ interface PhotoRatingProps {
|
|||||||
averageRating?: number;
|
averageRating?: number;
|
||||||
totalRatings?: number;
|
totalRatings?: number;
|
||||||
isEnabled: boolean;
|
isEnabled: boolean;
|
||||||
|
requireNameEmail?: boolean;
|
||||||
onRatingChange?: (rating: number) => void;
|
onRatingChange?: (rating: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ export const PhotoRating: React.FC<PhotoRatingProps> = ({
|
|||||||
averageRating = 0,
|
averageRating = 0,
|
||||||
totalRatings = 0,
|
totalRatings = 0,
|
||||||
isEnabled,
|
isEnabled,
|
||||||
|
requireNameEmail = false,
|
||||||
onRatingChange
|
onRatingChange
|
||||||
}) => {
|
}) => {
|
||||||
// Ensure averageRating is a valid number
|
// Ensure averageRating is a valid number
|
||||||
@@ -30,18 +33,23 @@ export const PhotoRating: React.FC<PhotoRatingProps> = ({
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [hoveredRating, setHoveredRating] = useState(0);
|
const [hoveredRating, setHoveredRating] = useState(0);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
const [showIdentityModal, setShowIdentityModal] = useState(false);
|
||||||
|
const [pendingRating, setPendingRating] = useState(0);
|
||||||
|
const [savedIdentity, setSavedIdentity] = useState<{ name: string; email: string } | null>(null);
|
||||||
|
|
||||||
const submitRatingMutation = useMutation({
|
const submitRatingMutation = useMutation({
|
||||||
mutationFn: (rating: number) =>
|
mutationFn: (data: { rating: number; guest_name?: string; guest_email?: string }) =>
|
||||||
feedbackService.submitFeedback(gallerySlug, photoId, {
|
feedbackService.submitFeedback(gallerySlug, photoId, {
|
||||||
feedback_type: 'rating',
|
feedback_type: 'rating',
|
||||||
rating
|
rating: data.rating,
|
||||||
|
guest_name: data.guest_name || undefined,
|
||||||
|
guest_email: data.guest_email || undefined
|
||||||
}),
|
}),
|
||||||
onMutate: async (rating) => {
|
onMutate: async (data) => {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Optimistic update
|
// Optimistic update
|
||||||
if (onRatingChange) {
|
if (onRatingChange) {
|
||||||
onRatingChange(rating);
|
onRatingChange(data.rating);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@@ -69,47 +77,75 @@ export const PhotoRating: React.FC<PhotoRatingProps> = ({
|
|||||||
|
|
||||||
// If clicking the same rating, remove it
|
// If clicking the same rating, remove it
|
||||||
const newRating = rating === currentRating ? 0 : rating;
|
const newRating = rating === currentRating ? 0 : rating;
|
||||||
submitRatingMutation.mutate(newRating);
|
|
||||||
|
if (requireNameEmail && !savedIdentity) {
|
||||||
|
setPendingRating(newRating);
|
||||||
|
setShowIdentityModal(true);
|
||||||
|
} else {
|
||||||
|
submitRatingMutation.mutate({
|
||||||
|
rating: newRating,
|
||||||
|
guest_name: savedIdentity?.name,
|
||||||
|
guest_email: savedIdentity?.email
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleIdentitySubmit = (name: string, email: string) => {
|
||||||
|
setSavedIdentity({ name, email });
|
||||||
|
setShowIdentityModal(false);
|
||||||
|
submitRatingMutation.mutate({
|
||||||
|
rating: pendingRating,
|
||||||
|
guest_name: name,
|
||||||
|
guest_email: email
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isEnabled) return null;
|
if (!isEnabled) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center gap-2">
|
<>
|
||||||
{/* Star Rating Input */}
|
<div className="flex flex-col items-center gap-2">
|
||||||
<div className="flex items-center gap-1">
|
{/* Star Rating Input */}
|
||||||
{[1, 2, 3, 4, 5].map((star) => (
|
<div className="flex items-center gap-1">
|
||||||
<button
|
{[1, 2, 3, 4, 5].map((star) => (
|
||||||
key={star}
|
<button
|
||||||
onClick={() => handleRatingClick(star)}
|
key={star}
|
||||||
onMouseEnter={() => setHoveredRating(star)}
|
onClick={() => handleRatingClick(star)}
|
||||||
onMouseLeave={() => setHoveredRating(0)}
|
onMouseEnter={() => setHoveredRating(star)}
|
||||||
disabled={isSubmitting}
|
onMouseLeave={() => setHoveredRating(0)}
|
||||||
className={`p-1 transition-all ${
|
disabled={isSubmitting}
|
||||||
isSubmitting ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:scale-110'
|
className={`p-1 transition-all ${
|
||||||
}`}
|
isSubmitting ? 'cursor-not-allowed opacity-50' : 'cursor-pointer hover:scale-110'
|
||||||
aria-label={t('feedback.rateStar', 'Rate {{count}} stars', { count: star })}
|
|
||||||
>
|
|
||||||
<Star
|
|
||||||
className={`w-6 h-6 transition-colors ${
|
|
||||||
star <= (hoveredRating || currentRating)
|
|
||||||
? 'fill-yellow-500 text-yellow-500'
|
|
||||||
: 'text-neutral-300 hover:text-yellow-400'
|
|
||||||
}`}
|
}`}
|
||||||
/>
|
aria-label={t('feedback.rateStar', 'Rate {{count}} stars', { count: star })}
|
||||||
</button>
|
>
|
||||||
))}
|
<Star
|
||||||
</div>
|
className={`w-6 h-6 transition-colors ${
|
||||||
|
star <= (hoveredRating || currentRating)
|
||||||
{/* Average Rating Display */}
|
? 'fill-yellow-500 text-yellow-500'
|
||||||
{totalRatings > 0 && (
|
: 'text-neutral-300 hover:text-yellow-400'
|
||||||
<div className="text-sm text-neutral-600">
|
}`}
|
||||||
<span className="font-medium">{safeAverageRating.toFixed(1)}</span>
|
/>
|
||||||
<span className="text-neutral-400 ml-1">
|
</button>
|
||||||
({t('feedback.ratingsCount', '{{count}} ratings', { count: totalRatings })})
|
))}
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
</div>
|
{/* Average Rating Display */}
|
||||||
|
{totalRatings > 0 && (
|
||||||
|
<div className="text-sm text-neutral-600">
|
||||||
|
<span className="font-medium">{safeAverageRating.toFixed(1)}</span>
|
||||||
|
<span className="text-neutral-400 ml-1">
|
||||||
|
({t('feedback.ratingsCount', '{{count}} ratings', { count: totalRatings })})
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<FeedbackIdentityModal
|
||||||
|
isOpen={showIdentityModal}
|
||||||
|
onClose={() => setShowIdentityModal(false)}
|
||||||
|
onSubmit={handleIdentitySubmit}
|
||||||
|
feedbackType={t('feedback.rating', 'rating')}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -48,10 +48,25 @@ api.interceptors.request.use(
|
|||||||
const galleryMatch = config.url?.match(/gallery\/([^\/]+)/);
|
const galleryMatch = config.url?.match(/gallery\/([^\/]+)/);
|
||||||
|
|
||||||
if (galleryMatch && galleryMatch[1]) {
|
if (galleryMatch && galleryMatch[1]) {
|
||||||
const gallerySlug = galleryMatch[1];
|
const galleryIdOrSlug = galleryMatch[1];
|
||||||
// Remove any query parameters from the slug
|
// Remove any query parameters from the slug
|
||||||
const cleanSlug = gallerySlug.split('?')[0];
|
const cleanIdOrSlug = galleryIdOrSlug.split('?')[0];
|
||||||
const token = localStorage.getItem(`gallery_token_${cleanSlug}`);
|
|
||||||
|
// Check if it's a numeric ID (for upload endpoints)
|
||||||
|
let token = null;
|
||||||
|
if (/^\d+$/.test(cleanIdOrSlug)) {
|
||||||
|
// It's an event ID - try to find the token from current page slug
|
||||||
|
const pathParts = window.location.pathname.split('/');
|
||||||
|
if (pathParts[1] === 'gallery' && pathParts[2]) {
|
||||||
|
const gallerySlug = pathParts[2];
|
||||||
|
const cleanSlug = gallerySlug.split('?')[0];
|
||||||
|
token = localStorage.getItem(`gallery_token_${cleanSlug}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// It's a slug - use it directly
|
||||||
|
token = localStorage.getItem(`gallery_token_${cleanIdOrSlug}`);
|
||||||
|
}
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
if (!config.headers) {
|
if (!config.headers) {
|
||||||
config.headers = {};
|
config.headers = {};
|
||||||
|
|||||||
@@ -134,7 +134,6 @@
|
|||||||
"sortByName": "Nach Name sortieren",
|
"sortByName": "Nach Name sortieren",
|
||||||
"sortBySize": "Nach Größe sortieren",
|
"sortBySize": "Nach Größe sortieren",
|
||||||
"allPhotos": "Alle Fotos",
|
"allPhotos": "Alle Fotos",
|
||||||
"downloadSelected": "Ausgewählte herunterladen",
|
|
||||||
"shareGallery": "Galerie teilen",
|
"shareGallery": "Galerie teilen",
|
||||||
"needHelp": "Hilfe benötigt? Kontaktieren Sie uns unter",
|
"needHelp": "Hilfe benötigt? Kontaktieren Sie uns unter",
|
||||||
"noPhotosFound": "Keine Fotos gefunden",
|
"noPhotosFound": "Keine Fotos gefunden",
|
||||||
|
|||||||
@@ -279,12 +279,38 @@ export const EventDetailsPage: React.FC = () => {
|
|||||||
|
|
||||||
const handleCopyLink = async () => {
|
const handleCopyLink = async () => {
|
||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(event.share_link);
|
// Check if share_link exists
|
||||||
|
if (!event.share_link) {
|
||||||
|
toast.error(t('errors.noShareLink', 'No share link available'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try modern clipboard API first
|
||||||
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
await navigator.clipboard.writeText(event.share_link);
|
||||||
|
} else {
|
||||||
|
// Fallback for non-HTTPS contexts or older browsers
|
||||||
|
const textArea = document.createElement('textarea');
|
||||||
|
textArea.value = event.share_link;
|
||||||
|
textArea.style.position = 'fixed';
|
||||||
|
textArea.style.left = '-999999px';
|
||||||
|
textArea.style.top = '-999999px';
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
const successful = document.execCommand('copy');
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
if (!successful) {
|
||||||
|
throw new Error('Copy failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setCopiedLink(true);
|
setCopiedLink(true);
|
||||||
setTimeout(() => setCopiedLink(false), 2000);
|
setTimeout(() => setCopiedLink(false), 2000);
|
||||||
toast.success(t('toast.linkCopied'));
|
toast.success(t('toast.linkCopied'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast.error(t('errors.somethingWentWrong'));
|
console.error('Copy failed:', err);
|
||||||
|
toast.error(t('errors.copyFailed', 'Failed to copy link. Please copy manually.'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -250,11 +250,17 @@ export const EventFeedbackPage: React.FC = () => {
|
|||||||
{feedbackData?.feedback?.map((item: PhotoFeedback) => (
|
{feedbackData?.feedback?.map((item: PhotoFeedback) => (
|
||||||
<Card key={item.id} className="overflow-hidden">
|
<Card key={item.id} className="overflow-hidden">
|
||||||
<div className="p-4 flex items-start gap-4">
|
<div className="p-4 flex items-start gap-4">
|
||||||
<img
|
{item.photo_id && (
|
||||||
src={`/thumbnails/${item.path}`}
|
<img
|
||||||
alt={item.filename}
|
src={`/api/admin/photos/${eventId}/thumbnail/${item.photo_id}`}
|
||||||
className="w-16 h-16 object-cover rounded"
|
alt={item.filename || 'Photo'}
|
||||||
/>
|
className="w-16 h-16 object-cover rounded"
|
||||||
|
onError={(e) => {
|
||||||
|
// Hide image if thumbnail fails to load
|
||||||
|
(e.target as HTMLImageElement).style.display = 'none';
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="flex items-start justify-between">
|
<div className="flex items-start justify-between">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user