fix(gallery): publish dialog stuck for password-protected galleries with no inline email

handleSubmit required a password whenever requirePassword was true, but the
password field only renders on the inline-email path (requirePassword &&
customerEmail). For a password-protected gallery with no inline email the field
was hidden, so submit blocked on the missing password and the dialog never
closed. Gate password collection + validation on a single `needsPassword`
(requirePassword && customerEmail); the no-inline-email path publishes without
re-entering the password (existing hash kept, customer reaches it via portal).
This commit is contained in:
Luca
2026-06-26 15:28:58 +02:00
parent c657892bc8
commit aa3471efe1
@@ -39,19 +39,24 @@ export const PublishGalleryDialog: React.FC<PublishGalleryDialogProps> = ({
// Someone gets notified if there's an inline email OR an assigned account
// (the latter via the account "your galleries" email).
const willNotify = !!customerEmail || assignedCustomerCount > 0;
// The password is only collected (and required) on the inline-email path,
// because the gallery_created email carries it. With no inline email the field
// is hidden and the existing hash is kept — so don't gate submit on it, or a
// password-protected gallery without an email could never be published.
const needsPassword = requirePassword && !!customerEmail;
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [error, setError] = useState<string | undefined>(undefined);
const handleSubmit = () => {
if (requirePassword) {
if (needsPassword) {
if (!password || password.trim().length < 6) {
setError(t('events.publishDialog.errorMinLength', 'Password must be at least 6 characters long.'));
return;
}
}
setError(undefined);
onConfirm(requirePassword ? password : undefined);
onConfirm(needsPassword ? password : undefined);
};
return (
@@ -92,7 +97,7 @@ export const PublishGalleryDialog: React.FC<PublishGalleryDialogProps> = ({
})}
</p>
{requirePassword && customerEmail && (
{needsPassword && (
<div className="space-y-3 mb-4">
<Input
type={showPassword ? 'text' : 'password'}