feafa
This commit is contained in:
parent
7be5673a54
commit
f45bad52b7
@ -116,8 +116,8 @@
|
|||||||
<DropdownMenu.Content align="end">
|
<DropdownMenu.Content align="end">
|
||||||
<DropdownMenu.Label>My Account</DropdownMenu.Label>
|
<DropdownMenu.Label>My Account</DropdownMenu.Label>
|
||||||
<DropdownMenu.Separator />
|
<DropdownMenu.Separator />
|
||||||
<DropdownMenu.Item href={config.api_url + "/me/billing"}>Billing</DropdownMenu.Item>
|
<!-- <DropdownMenu.Item href={config.api_url + "/me/billing"}>Billing</DropdownMenu.Item> -->
|
||||||
<DropdownMenu.Item>Support</DropdownMenu.Item>
|
<DropdownMenu.Item><a href="mailto:osabic2004@gmail.com?Subject=Youpage.ai support">Support</a></DropdownMenu.Item>
|
||||||
<DropdownMenu.Separator />
|
<DropdownMenu.Separator />
|
||||||
<DropdownMenu.Item on:click={logout}>Logout</DropdownMenu.Item>
|
<DropdownMenu.Item on:click={logout}>Logout</DropdownMenu.Item>
|
||||||
</DropdownMenu.Content>
|
</DropdownMenu.Content>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
</Card.Header>
|
</Card.Header>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<div class="text-2xl font-bold">{data.dashboard_info.totalArticles}</div>
|
<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.Content>
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
<!-- <Card.Root>
|
<!-- <Card.Root>
|
||||||
|
@ -86,7 +86,7 @@ export const actions = {
|
|||||||
return {
|
return {
|
||||||
form
|
form
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
import { ChevronLeft } from 'svelte-radix';
|
import { ChevronLeft } from 'svelte-radix';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
|
import {config} from '$lib';
|
||||||
|
|
||||||
|
|
||||||
/** @type {import("./$types").PageData} */
|
/** @type {import("./$types").PageData} */
|
||||||
export let data;
|
export let data;
|
||||||
@ -41,7 +43,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentPage = Number(pageQuery.get("page"));
|
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) {
|
if(data) {
|
||||||
@ -76,7 +89,7 @@
|
|||||||
</Table.Header>
|
</Table.Header>
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
{#each data.articles as article, i (i)}
|
{#each data.articles as article, i (i)}
|
||||||
<Table.Row>
|
<Table.Row name="article-row-{article.id}">
|
||||||
<Table.Cell class="font-medium">
|
<Table.Cell class="font-medium">
|
||||||
{#if article.is_public}
|
{#if article.is_public}
|
||||||
<Eye class="mx-auto h-5 w-5" />
|
<Eye class="mx-auto h-5 w-5" />
|
||||||
@ -95,7 +108,7 @@
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="icon"
|
size="icon"
|
||||||
tip="Preview"
|
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" />
|
<ExternalLink size="1rem" />
|
||||||
</TooltipButton>
|
</TooltipButton>
|
||||||
@ -107,7 +120,7 @@
|
|||||||
>
|
>
|
||||||
<Pen size="1rem" />
|
<Pen size="1rem" />
|
||||||
</TooltipButton>
|
</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" />
|
<Trash size="1rem" />
|
||||||
</TooltipButton>
|
</TooltipButton>
|
||||||
</Table.Cell>
|
</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.Row>
|
||||||
<Table.Head class="max-w-[300px]">Email</Table.Head>
|
<Table.Head class="max-w-[300px]">Email</Table.Head>
|
||||||
<Table.Head class="text-end">Date and Time</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.Row>
|
||||||
</Table.Header>
|
</Table.Header>
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
import { z } from "zod";
|
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({
|
export const schema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
name: z.string().min(4).max(16),
|
name: z.string().min(4).max(16),
|
||||||
primary_color_hex: z.string().length(7),
|
primary_color_hex: z.string().length(7),
|
||||||
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().refine(isValidDomain, {
|
||||||
|
message: "Invalid domain"
|
||||||
|
}).optional(),
|
||||||
use_freebie: z.boolean().default(false),
|
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(),
|
||||||
|
Loading…
Reference in New Issue
Block a user