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') {
toast.success('Website configuration successfully updated!');
} else {
console.log(e.result)
console.log(e.result);
toast.error('Error when updating website.');
}
}
@ -71,9 +71,9 @@
<div class="w-full max-w-7xl">
<form method="post" use:enhance enctype="multipart/form-data">
<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>
<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.Control let:attrs>
<Form.Label>Blog name</Form.Label>
@ -98,7 +98,7 @@
<Form.Description />
<Form.FieldErrors />
</Form.Field>
<Form.Field {form} name="primary_color_hex">
<Form.Control let:attrs>
<Form.Label>Primary color</Form.Label>
@ -147,14 +147,19 @@
<Input {...attrs} bind:value={$formData.domain} />
</Form.Control>
{#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}
<Form.FieldErrors />
</Form.Field>
</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.Control let:attrs>
<Form.Label class="text-right">Send freebie</Form.Label>
@ -198,36 +203,43 @@
</Form.Control>
<Form.FieldErrors />
</Form.Field>
<Form.Field {form} name="freebie_image_url">
<Form.Control let:attrs>
<Form.Label class="text-right">Freebie image</Form.Label>
<div class="flex items-center justify-start">
<Input
type="file"
accept="png,jpg,webp,jpeg"
on:input={(e) =>
handleFileChange(e, $formData.freebie_image_url).then(
(x) => ($formData.freebie_image_url = x)
)}
bind:disabled={disable_freebies}
/>
<Input {...attrs} class="hidden" bind:value={$formData.freebie_image_url} readonly />
</div>
</Form.Control>
<Form.FieldErrors />
</Form.Field>
<div class="hidden">
<Form.Field {form} name="freebie_image_url">
<Form.Control let:attrs>
<Form.Label class="text-right">Freebie image</Form.Label>
<div class="flex items-center justify-start">
<Input
type="file"
accept="png,jpg,webp,jpeg"
on:input={(e) =>
handleFileChange(e, $formData.freebie_image_url).then(
(x) => ($formData.freebie_image_url = x)
)}
bind:disabled={disable_freebies}
/>
<Input
{...attrs}
class="hidden"
bind:value={$formData.freebie_image_url}
readonly
/>
</div>
</Form.Control>
<Form.FieldErrors />
</Form.Field>
</div>
<Form.Field {form} name="freebie_text">
<Form.Control let:attrs>
<Form.Label class="text-right">Freebie text</Form.Label>
<div class="flex items-center justify-start">
<Textarea
{...attrs}
bind:value={$formData.freebie_text}
/>
<Textarea {...attrs} bind:value={$formData.freebie_text} />
</div>
</Form.Control>
<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>
</div>
</div>

View File

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