Initialize playwright, fix file upload issue, show publication status and delete website dir on website deletion

This commit is contained in:
thiloho
2024-08-30 15:48:15 +02:00
parent 8915a7cfd9
commit bb73c2350d
15 changed files with 284 additions and 41 deletions

View File

@@ -54,6 +54,22 @@ export const actions: Actions = {
const websiteOverview = await websiteOverviewData.json();
generateStaticFiles(websiteOverview, false);
const res = await fetch(`${API_BASE_PREFIX}/website?id=eq.${params.websiteId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${cookies.get("session_token")}`
},
body: JSON.stringify({
is_published: true
})
});
if (!res.ok) {
const response = await res.json();
return { success: false, message: response.message };
}
return { success: true, message: "Successfully published website" };
}
};

View File

@@ -5,6 +5,8 @@
import type { ActionData, PageServerData } from "./$types";
const { data, form }: { data: PageServerData; form: ActionData } = $props();
const prodWebsiteUrl = data.websitePreviewUrl.replace("/previews", "");
</script>
<SuccessOrError success={form?.success} message={form?.message} />
@@ -28,5 +30,18 @@
<form method="POST" action="?/publishWebsite" use:enhance>
<button type="submit">Publish</button>
</form>
{#if data.website.is_published}
<section>
<h3>
<a href="#publication-status">Publication status</a>
</h3>
<p>
Your website is published at:
<br />
<a href={prodWebsiteUrl}>{prodWebsiteUrl}</a>
</p>
</section>
{/if}
</section>
</WebsiteEditor>