feat: add 24/7 toggle (also make label optional)

This commit is contained in:
2025-09-03 22:37:07 +02:00
parent d327da90ef
commit 31fa5f36de
5 changed files with 26 additions and 2 deletions

View File

@@ -61,6 +61,7 @@ interface ChannelSettingsClientProps {
streamKey: StreamKey | null;
followers: (Follow & { user: { id: string; slack_id: string } })[];
followerPersonalChannels: (Channel | null)[];
is247: boolean;
};
isOwner: boolean;
currentUser: User;
@@ -306,6 +307,27 @@ export default function ChannelSettingsClient({
</div>
),
},
{
name: 'is247',
value: channel.is247,
component: ({ field }) => (
<div className="flex items-center justify-between mt-2">
<div>
<label className="text-sm font-medium">24/7 Channel</label>
<p className="text-xs text-muted-foreground">
Mark this channel as always live. It will disable notifications on #hctv-streams.
</p>
</div>
<Switch
checked={field.value}
onCheckedChange={(checked) => {
field.onChange(checked);
}}
/>
<input type="hidden" {...field} value={field.value ? 'true' : 'false'} />
</div>
),
}
]}
schemaName="updateChannelSettings"
action={updateChannelSettings}

View File

@@ -82,7 +82,7 @@ export function UniversalForm<T extends z.ZodType>({
name={field.name as Path<FormData>}
render={({ field: formField }) => (
<FormItem>
{field.type !== 'hidden' && <FormLabel>{field.label}</FormLabel>}
{(field.type !== 'hidden' || field.label) && <FormLabel>{field.label}</FormLabel>}
<FormControl>
{field.component ? (
field.component({ field: formField, ...field.componentProps })

View File

@@ -5,7 +5,7 @@ import { schemaDb } from './UniversalForm';
export type FormFieldConfig = {
name: string;
label: string;
label?: string;
type?: HTMLInputTypeAttribute;
placeholder?: string;
description?: string;

View File

@@ -202,6 +202,7 @@ export async function updateChannelSettings(prev: any, formData: FormData) {
data: {
description: zod.data.description || undefined,
pfpUrl: zod.data.pfpUrl,
is247: zod.data.is247,
},
});

View File

@@ -24,4 +24,5 @@ export const updateChannelSettingsSchema = z.object({
channelId: z.string().min(1),
pfpUrl: z.string(),
description: z.string().min(1).max(500),
is247: z.boolean(),
});