mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
feat: add 24/7 toggle (also make label optional)
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -5,7 +5,7 @@ import { schemaDb } from './UniversalForm';
|
||||
|
||||
export type FormFieldConfig = {
|
||||
name: string;
|
||||
label: string;
|
||||
label?: string;
|
||||
type?: HTMLInputTypeAttribute;
|
||||
placeholder?: string;
|
||||
description?: string;
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
Reference in New Issue
Block a user