Simplify hero toggles
This commit is contained in:
@@ -53,7 +53,6 @@
|
||||
"nextStepTitle": "Nächster Schritt",
|
||||
"quickSettings": "Event-Einstellungen",
|
||||
"publishToggle": "Live",
|
||||
"autoApproveToggle": "Auto",
|
||||
"pending": "Noch offen",
|
||||
"complete": "Erledigt",
|
||||
"items": {
|
||||
|
||||
@@ -53,7 +53,6 @@
|
||||
"nextStepTitle": "Next step",
|
||||
"quickSettings": "Event settings",
|
||||
"publishToggle": "Live",
|
||||
"autoApproveToggle": "Auto",
|
||||
"pending": "Pending",
|
||||
"complete": "Done",
|
||||
"items": {
|
||||
|
||||
@@ -282,15 +282,14 @@ function LifecycleHero({
|
||||
const cardVariant = isEmbedded ? 'embedded' : 'default';
|
||||
const cardPadding = isEmbedded ? '$3' : '$3.5';
|
||||
const [isPublishing, setIsPublishing] = React.useState(false);
|
||||
const [isAutoApproving, setIsAutoApproving] = React.useState(false);
|
||||
const [published, setPublished] = React.useState(false);
|
||||
const [autoApproveUploads, setAutoApproveUploads] = React.useState(false);
|
||||
const [published, setPublished] = React.useState(() => event?.status === 'published');
|
||||
|
||||
if (!event) return null;
|
||||
const phase = getEventPhase(event);
|
||||
const pendingPhotos = stats?.pending_photos ?? event.pending_photo_count ?? 0;
|
||||
const isPostEvent = phase === 'post';
|
||||
const showQuickControls = canManage && !isPostEvent;
|
||||
const displayStatus = event.status === 'archived' ? 'archived' : published ? 'published' : 'draft';
|
||||
|
||||
// Header Row
|
||||
const Header = () => (
|
||||
@@ -300,7 +299,7 @@ function LifecycleHero({
|
||||
{formatEventDate(event.event_date, locale)}
|
||||
</Text>
|
||||
</YStack>
|
||||
<StatusBadge status={event.status} />
|
||||
<StatusBadge status={displayStatus} />
|
||||
</XStack>
|
||||
);
|
||||
|
||||
@@ -359,8 +358,6 @@ function LifecycleHero({
|
||||
|
||||
React.useEffect(() => {
|
||||
setPublished(event.status === 'published');
|
||||
const visibility = (event.settings?.guest_upload_visibility as string | undefined) ?? 'review';
|
||||
setAutoApproveUploads(visibility === 'immediate');
|
||||
}, [event.settings?.guest_upload_visibility, event.status]);
|
||||
|
||||
const handlePublishChange = React.useCallback(
|
||||
@@ -384,31 +381,6 @@ function LifecycleHero({
|
||||
[event.slug, onUpdated, published, t],
|
||||
);
|
||||
|
||||
const handleAutoApproveChange = React.useCallback(
|
||||
async (checked: boolean) => {
|
||||
if (!event.slug) return;
|
||||
const previous = autoApproveUploads;
|
||||
setAutoApproveUploads(checked);
|
||||
setIsAutoApproving(true);
|
||||
try {
|
||||
const nextSettings = {
|
||||
...(event.settings ?? {}),
|
||||
guest_upload_visibility: checked ? 'immediate' : 'review',
|
||||
};
|
||||
await updateEvent(event.slug, { settings: nextSettings });
|
||||
onUpdated?.();
|
||||
} catch (err) {
|
||||
setAutoApproveUploads(previous);
|
||||
toast.error(
|
||||
getApiErrorMessage(err, t('eventForm.errors.saveFailed', 'Event could not be saved.'))
|
||||
);
|
||||
} finally {
|
||||
setIsAutoApproving(false);
|
||||
}
|
||||
},
|
||||
[autoApproveUploads, event.settings, event.slug, onUpdated, t],
|
||||
);
|
||||
|
||||
if (phase === 'post') {
|
||||
return (
|
||||
<YStack space="$2">
|
||||
@@ -501,21 +473,6 @@ function LifecycleHero({
|
||||
<Switch.Thumb />
|
||||
</Switch>
|
||||
</YStack>
|
||||
|
||||
<YStack alignItems="center" space="$1">
|
||||
<Text fontSize="$xs" color={theme.muted} textTransform="uppercase" letterSpacing={0.8}>
|
||||
{t('dashboard:readiness.autoApproveToggle', 'Auto')}
|
||||
</Text>
|
||||
<Switch
|
||||
checked={autoApproveUploads}
|
||||
onCheckedChange={(checked) => handleAutoApproveChange(Boolean(checked))}
|
||||
size="$2"
|
||||
disabled={isAutoApproving}
|
||||
aria-label={t('eventForm.fields.uploadVisibility.label', 'Uploads visible immediately')}
|
||||
>
|
||||
<Switch.Thumb />
|
||||
</Switch>
|
||||
</YStack>
|
||||
</XStack>
|
||||
</XStack>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user