Simplify hero toggles
This commit is contained in:
@@ -53,7 +53,6 @@
|
|||||||
"nextStepTitle": "Nächster Schritt",
|
"nextStepTitle": "Nächster Schritt",
|
||||||
"quickSettings": "Event-Einstellungen",
|
"quickSettings": "Event-Einstellungen",
|
||||||
"publishToggle": "Live",
|
"publishToggle": "Live",
|
||||||
"autoApproveToggle": "Auto",
|
|
||||||
"pending": "Noch offen",
|
"pending": "Noch offen",
|
||||||
"complete": "Erledigt",
|
"complete": "Erledigt",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
"nextStepTitle": "Next step",
|
"nextStepTitle": "Next step",
|
||||||
"quickSettings": "Event settings",
|
"quickSettings": "Event settings",
|
||||||
"publishToggle": "Live",
|
"publishToggle": "Live",
|
||||||
"autoApproveToggle": "Auto",
|
|
||||||
"pending": "Pending",
|
"pending": "Pending",
|
||||||
"complete": "Done",
|
"complete": "Done",
|
||||||
"items": {
|
"items": {
|
||||||
|
|||||||
@@ -282,15 +282,14 @@ function LifecycleHero({
|
|||||||
const cardVariant = isEmbedded ? 'embedded' : 'default';
|
const cardVariant = isEmbedded ? 'embedded' : 'default';
|
||||||
const cardPadding = isEmbedded ? '$3' : '$3.5';
|
const cardPadding = isEmbedded ? '$3' : '$3.5';
|
||||||
const [isPublishing, setIsPublishing] = React.useState(false);
|
const [isPublishing, setIsPublishing] = React.useState(false);
|
||||||
const [isAutoApproving, setIsAutoApproving] = React.useState(false);
|
const [published, setPublished] = React.useState(() => event?.status === 'published');
|
||||||
const [published, setPublished] = React.useState(false);
|
|
||||||
const [autoApproveUploads, setAutoApproveUploads] = React.useState(false);
|
|
||||||
|
|
||||||
if (!event) return null;
|
if (!event) return null;
|
||||||
const phase = getEventPhase(event);
|
const phase = getEventPhase(event);
|
||||||
const pendingPhotos = stats?.pending_photos ?? event.pending_photo_count ?? 0;
|
const pendingPhotos = stats?.pending_photos ?? event.pending_photo_count ?? 0;
|
||||||
const isPostEvent = phase === 'post';
|
const isPostEvent = phase === 'post';
|
||||||
const showQuickControls = canManage && !isPostEvent;
|
const showQuickControls = canManage && !isPostEvent;
|
||||||
|
const displayStatus = event.status === 'archived' ? 'archived' : published ? 'published' : 'draft';
|
||||||
|
|
||||||
// Header Row
|
// Header Row
|
||||||
const Header = () => (
|
const Header = () => (
|
||||||
@@ -300,7 +299,7 @@ function LifecycleHero({
|
|||||||
{formatEventDate(event.event_date, locale)}
|
{formatEventDate(event.event_date, locale)}
|
||||||
</Text>
|
</Text>
|
||||||
</YStack>
|
</YStack>
|
||||||
<StatusBadge status={event.status} />
|
<StatusBadge status={displayStatus} />
|
||||||
</XStack>
|
</XStack>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -359,8 +358,6 @@ function LifecycleHero({
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
setPublished(event.status === 'published');
|
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]);
|
}, [event.settings?.guest_upload_visibility, event.status]);
|
||||||
|
|
||||||
const handlePublishChange = React.useCallback(
|
const handlePublishChange = React.useCallback(
|
||||||
@@ -384,31 +381,6 @@ function LifecycleHero({
|
|||||||
[event.slug, onUpdated, published, t],
|
[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') {
|
if (phase === 'post') {
|
||||||
return (
|
return (
|
||||||
<YStack space="$2">
|
<YStack space="$2">
|
||||||
@@ -501,21 +473,6 @@ function LifecycleHero({
|
|||||||
<Switch.Thumb />
|
<Switch.Thumb />
|
||||||
</Switch>
|
</Switch>
|
||||||
</YStack>
|
</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>
|
||||||
</XStack>
|
</XStack>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
Reference in New Issue
Block a user