youtuber-blog-frontend/build/server/chunks/7-DRmBp3gN.js

119 lines
4.0 KiB
JavaScript
Raw Normal View History

2024-05-29 18:43:41 +00:00
import { c as config } from './config-DeQcbWtq.js';
import './stores-D9BZZahs.js';
import './index-k1TR3EJq.js';
import './index-Ddp2AB5f.js';
import { s as superValidate, z as zod, f as fail } from './zod-BtM9a6Uj.js';
import { z } from 'zod';
const schema = z.object({
id: z.string(),
name: z.string().min(4).max(16),
primary_color_hex: z.string().length(7),
secondary_color_hex: z.string().length(7),
text_color_hex: z.string().length(7),
domain: z.string(),
use_freebie: z.boolean(),
freebie_name: z.string(),
freebie_url: z.string(),
freebie_image_url: z.string(),
freebie_text: z.string(),
title: z.string(),
subtitle: z.string()
}).superRefine((data, ctx) => {
console.log(data);
if (data.use_freebie) {
if (!data.freebie_name || data.freebie_name.length === 0) {
ctx.addIssue({
path: ["freebie_name"],
message: "A freebie name' is required when 'Use freebie' is true.",
code: "custom"
});
}
if (!data.freebie_url) {
ctx.addIssue({
path: ["freebie_url"],
message: "A freebie file is required when 'Use freebie' is true.",
code: "custom"
});
}
if (!data.freebie_image_url) {
ctx.addIssue({
path: ["freebie_image"],
message: "'freebie_image' is required when 'use_freebie' is true.",
code: "custom"
});
}
}
});
const load = async ({ fetch }) => {
const blogRes = await fetch(config.api_url + "/blog?mine=true", {
credentials: "include"
});
const { site } = await blogRes.json();
site.primary_color_hex = "#" + site.primary_color_hex;
site.secondary_color_hex = "#" + site.secondary_color_hex;
site.text_color_hex = "#" + site.text_color_hex;
return {
blog_info: site,
form: await superValidate(site, zod(schema))
};
};
const actions = {
default: async (event) => {
const form = await superValidate(event, zod(schema));
if (!form.valid) {
return fail(400, {
form
});
}
let data = structuredClone(form.data);
data.primary_color_hex = data.primary_color_hex.slice(1);
data.secondary_color_hex = data.secondary_color_hex.slice(1);
data.text_color_hex = data.text_color_hex.slice(1);
const res = await event.fetch(config.api_url + "/dashboard/website", {
method: "PUT",
body: JSON.stringify(data),
headers: {
"content-type": "application/json"
}
});
const res_data = await res.json();
if (!res_data.success)
return fail(res.status, {
form
});
return {
form
};
}
};
var _page_server = /*#__PURE__*/Object.freeze({
__proto__: null,
actions: actions,
load: load
});
2024-05-29 19:16:25 +00:00
const index = 7;
2024-05-29 18:43:41 +00:00
let component_cache;
2024-05-29 19:16:25 +00:00
const component = async () => component_cache ??= (await import('./_page.svelte-C5jUJaVp.js')).default;
const server_id = "src/routes/(app)/website/+page.server.js";
const imports = ["_app/immutable/nodes/7.CKzNBIvd.js","_app/immutable/chunks/scheduler.ncJpckHt.js","_app/immutable/chunks/index.DNKwBhZH.js","_app/immutable/chunks/spread.CgU5AtxT.js","_app/immutable/chunks/textarea.CdBkX6LG.js","_app/immutable/chunks/button.Dry7Ezxz.js","_app/immutable/chunks/index.Bf9t7sah.js","_app/immutable/chunks/index.BHY_2Zs4.js","_app/immutable/chunks/Toaster.svelte_svelte_type_style_lang.C_CyLwr0.js","_app/immutable/chunks/each.C-Vm-bAH.js","_app/immutable/chunks/stores.DOGWYuMr.js","_app/immutable/chunks/entry.Cu4pHBTQ.js","_app/immutable/chunks/forms.zRWRS9EP.js","_app/immutable/chunks/_commonjsHelpers.IkB594pC.js","_app/immutable/chunks/config.ah9CROzn.js"];
const stylesheets = ["_app/immutable/assets/7.BXHCoMPH.css","_app/immutable/assets/textarea.Crp_yK76.css","_app/immutable/assets/Toaster.CZzI-Nh6.css"];
2024-05-29 18:43:41 +00:00
const fonts = [];
2024-05-29 19:16:25 +00:00
var _7 = /*#__PURE__*/Object.freeze({
2024-05-29 18:43:41 +00:00
__proto__: null,
component: component,
fonts: fonts,
imports: imports,
index: index,
server: _page_server,
server_id: server_id,
stylesheets: stylesheets
});
2024-05-29 19:16:25 +00:00
export { _7 as _, schema as s };
//# sourceMappingURL=7-DRmBp3gN.js.map