feafa
This commit is contained in:
parent
7be5673a54
commit
f45bad52b7
@ -116,8 +116,8 @@
|
||||
<DropdownMenu.Content align="end">
|
||||
<DropdownMenu.Label>My Account</DropdownMenu.Label>
|
||||
<DropdownMenu.Separator />
|
||||
<DropdownMenu.Item href={config.api_url + "/me/billing"}>Billing</DropdownMenu.Item>
|
||||
<DropdownMenu.Item>Support</DropdownMenu.Item>
|
||||
<!-- <DropdownMenu.Item href={config.api_url + "/me/billing"}>Billing</DropdownMenu.Item> -->
|
||||
<DropdownMenu.Item><a href="mailto:osabic2004@gmail.com?Subject=Youpage.ai support">Support</a></DropdownMenu.Item>
|
||||
<DropdownMenu.Separator />
|
||||
<DropdownMenu.Item on:click={logout}>Logout</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
|
@ -23,7 +23,7 @@
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<div class="text-2xl font-bold">{data.dashboard_info.totalArticles}</div>
|
||||
<p class="text-xs text-muted-foreground">7 remaining this month</p>
|
||||
<!-- <p class="text-xs text-muted-foreground">7 remaining this month</p> -->
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
<!-- <Card.Root>
|
||||
|
@ -86,7 +86,7 @@ export const actions = {
|
||||
return {
|
||||
form
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,8 @@
|
||||
import { ChevronLeft } from 'svelte-radix';
|
||||
import { onMount } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import {config} from '$lib';
|
||||
|
||||
|
||||
/** @type {import("./$types").PageData} */
|
||||
export let data;
|
||||
@ -41,7 +43,18 @@
|
||||
}
|
||||
|
||||
currentPage = Number(pageQuery.get("page"));
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
*/
|
||||
async function deleteArticle(id) {
|
||||
await fetch("/articles/delete?id="+id, {
|
||||
method: "DELETE"
|
||||
});
|
||||
|
||||
document.querySelector(`tr[name="article-row-${id}"]`)?.remove()
|
||||
}
|
||||
|
||||
$: {
|
||||
if(data) {
|
||||
@ -76,7 +89,7 @@
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each data.articles as article, i (i)}
|
||||
<Table.Row>
|
||||
<Table.Row name="article-row-{article.id}">
|
||||
<Table.Cell class="font-medium">
|
||||
{#if article.is_public}
|
||||
<Eye class="mx-auto h-5 w-5" />
|
||||
@ -95,7 +108,7 @@
|
||||
variant="outline"
|
||||
size="icon"
|
||||
tip="Preview"
|
||||
on:click={() => window.open('/site/' + data.site.id + '/' + article.seo_slug)}
|
||||
on:click={() => window.location.href = `http://${data.site.subdomain_slug}.${config.sites_url}/${article.seo_slug}`}
|
||||
>
|
||||
<ExternalLink size="1rem" />
|
||||
</TooltipButton>
|
||||
@ -107,7 +120,7 @@
|
||||
>
|
||||
<Pen size="1rem" />
|
||||
</TooltipButton>
|
||||
<TooltipButton class="hover:bg-red-600" variant="outline" size="icon" tip="Delete">
|
||||
<TooltipButton class="hover:bg-red-600" variant="outline" size="icon" tip="Delete" on:click={() => deleteArticle(article.id)}>
|
||||
<Trash size="1rem" />
|
||||
</TooltipButton>
|
||||
</Table.Cell>
|
||||
|
13
src/routes/(app)/articles/delete/+server.js
Normal file
13
src/routes/(app)/articles/delete/+server.js
Normal file
@ -0,0 +1,13 @@
|
||||
import { config } from '$lib';
|
||||
import { error, json, text } from '@sveltejs/kit';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function DELETE(event) {
|
||||
if(!event.url.searchParams.has("id")) return error(400);
|
||||
const id = event.url.searchParams.get("id");
|
||||
|
||||
const response = await event.fetch(config.api_url + "/dashboard/article?id=" + id, {
|
||||
method: "DELETE"
|
||||
}).then(x=>x.json());
|
||||
return json(response);
|
||||
}
|
@ -44,7 +44,7 @@
|
||||
<Table.Row>
|
||||
<Table.Head class="max-w-[300px]">Email</Table.Head>
|
||||
<Table.Head class="text-end">Date and Time</Table.Head>
|
||||
<Table.Head class="text-end">Actions</Table.Head>
|
||||
<!-- <Table.Head class="text-end">Actions</Table.Head> -->
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
|
@ -1,12 +1,22 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const domain_regex = /^[a-z0-9\.\-]*$/;
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isValidDomain = key => domain_regex.test(key);
|
||||
|
||||
export 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().optional(),
|
||||
domain: z.string().refine(isValidDomain, {
|
||||
message: "Invalid domain"
|
||||
}).optional(),
|
||||
use_freebie: z.boolean().default(false),
|
||||
freebie_name: z.string().optional(),
|
||||
freebie_url: z.string().optional(),
|
||||
|
Loading…
Reference in New Issue
Block a user