hid freebie image

This commit is contained in:
Omer Sabic 2024-05-30 12:27:59 +02:00
parent c0563306e3
commit 9e53d6b374
2 changed files with 43 additions and 31 deletions

View File

@ -20,7 +20,7 @@
if (e.result.type == 'success') { if (e.result.type == 'success') {
toast.success('Website configuration successfully updated!'); toast.success('Website configuration successfully updated!');
} else { } else {
console.log(e.result) console.log(e.result);
toast.error('Error when updating website.'); toast.error('Error when updating website.');
} }
} }
@ -71,9 +71,9 @@
<div class="w-full max-w-7xl"> <div class="w-full max-w-7xl">
<form method="post" use:enhance enctype="multipart/form-data"> <form method="post" use:enhance enctype="multipart/form-data">
<input type="text" value={data.blog_info.id} name="id" readonly class="hidden" /> <input type="text" value={data.blog_info.id} name="id" readonly class="hidden" />
<div class="grid grid-cols-2 gap-16"> <div class="grid grid-cols-1 gap-16 md:grid-cols-2 md:grid-rows-1">
<div> <div>
<h2 class="font-bold text-2xl mb-4">Basics</h2> <h2 class="mb-4 text-2xl font-bold">Basics</h2>
<Form.Field {form} name="name"> <Form.Field {form} name="name">
<Form.Control let:attrs> <Form.Control let:attrs>
<Form.Label>Blog name</Form.Label> <Form.Label>Blog name</Form.Label>
@ -98,7 +98,7 @@
<Form.Description /> <Form.Description />
<Form.FieldErrors /> <Form.FieldErrors />
</Form.Field> </Form.Field>
<Form.Field {form} name="primary_color_hex"> <Form.Field {form} name="primary_color_hex">
<Form.Control let:attrs> <Form.Control let:attrs>
<Form.Label>Primary color</Form.Label> <Form.Label>Primary color</Form.Label>
@ -147,14 +147,19 @@
<Input {...attrs} bind:value={$formData.domain} /> <Input {...attrs} bind:value={$formData.domain} />
</Form.Control> </Form.Control>
{#if data.blog_info.subdomain_slug} {#if data.blog_info.subdomain_slug}
<Form.Description>You can also access your website at <a href="http://{data.blog_info.subdomain_slug}.{config.sites_url}" class="underline font-semibold">{data.blog_info.subdomain_slug}.{config.sites_url}</a></Form.Description> <Form.Description
>You can also access your website at <a
href="http://{data.blog_info.subdomain_slug}.{config.sites_url}"
class="font-semibold underline"
>{data.blog_info.subdomain_slug}.{config.sites_url}</a
></Form.Description
>
{/if} {/if}
<Form.FieldErrors /> <Form.FieldErrors />
</Form.Field> </Form.Field>
</div> </div>
<div> <div>
<h2 class="font-bold text-2xl mb-4">Freebies</h2> <h2 class="mb-4 text-2xl font-bold">Freebies</h2>
<Form.Field {form} name="use_freebie"> <Form.Field {form} name="use_freebie">
<Form.Control let:attrs> <Form.Control let:attrs>
<Form.Label class="text-right">Send freebie</Form.Label> <Form.Label class="text-right">Send freebie</Form.Label>
@ -198,36 +203,43 @@
</Form.Control> </Form.Control>
<Form.FieldErrors /> <Form.FieldErrors />
</Form.Field> </Form.Field>
<Form.Field {form} name="freebie_image_url"> <div class="hidden">
<Form.Control let:attrs> <Form.Field {form} name="freebie_image_url">
<Form.Label class="text-right">Freebie image</Form.Label> <Form.Control let:attrs>
<div class="flex items-center justify-start"> <Form.Label class="text-right">Freebie image</Form.Label>
<Input <div class="flex items-center justify-start">
type="file" <Input
accept="png,jpg,webp,jpeg" type="file"
on:input={(e) => accept="png,jpg,webp,jpeg"
handleFileChange(e, $formData.freebie_image_url).then( on:input={(e) =>
(x) => ($formData.freebie_image_url = x) handleFileChange(e, $formData.freebie_image_url).then(
)} (x) => ($formData.freebie_image_url = x)
bind:disabled={disable_freebies} )}
/> bind:disabled={disable_freebies}
<Input {...attrs} class="hidden" bind:value={$formData.freebie_image_url} readonly /> />
</div> <Input
</Form.Control> {...attrs}
<Form.FieldErrors /> class="hidden"
</Form.Field> bind:value={$formData.freebie_image_url}
readonly
/>
</div>
</Form.Control>
<Form.FieldErrors />
</Form.Field>
</div>
<Form.Field {form} name="freebie_text"> <Form.Field {form} name="freebie_text">
<Form.Control let:attrs> <Form.Control let:attrs>
<Form.Label class="text-right">Freebie text</Form.Label> <Form.Label class="text-right">Freebie text</Form.Label>
<div class="flex items-center justify-start"> <div class="flex items-center justify-start">
<Textarea <Textarea {...attrs} bind:value={$formData.freebie_text} />
{...attrs}
bind:value={$formData.freebie_text}
/>
</div> </div>
</Form.Control> </Form.Control>
<Form.FieldErrors /> <Form.FieldErrors />
<Form.Description>The text displayed next to the signup form on your blog.</Form.Description> <Form.Description
>The text displayed next to the signup form on your blog.</Form.Description
>
</Form.Field> </Form.Field>
</div> </div>
</div> </div>

View File

@ -7,7 +7,7 @@ export const schema = z.object({
secondary_color_hex: z.string().length(7), secondary_color_hex: z.string().length(7),
text_color_hex: z.string().length(7), text_color_hex: z.string().length(7),
domain: z.string().optional(), domain: z.string().optional(),
use_freebie: z.boolean(), use_freebie: z.boolean().default(false),
freebie_name: z.string().optional(), freebie_name: z.string().optional(),
freebie_url: z.string().optional(), freebie_url: z.string().optional(),
freebie_image_url: z.string().optional(), freebie_image_url: z.string().optional(),