Skip to content

Commit

Permalink
feat(app): add simple subscription for Supso Cloud
Browse files Browse the repository at this point in the history
mrcnk committed Feb 19, 2024
1 parent 141ba90 commit 470e9aa
Showing 28 changed files with 810 additions and 272 deletions.
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ CREATE TABLE `comment` (
`event_id` text NOT NULL,
`user_id` text NOT NULL,
`content` text NOT NULL,
`edited` numeric DEFAULT 'false',
`created_at` text,
`updated_at` text,
FOREIGN KEY (`event_id`) REFERENCES `event`(`id`) ON UPDATE no action ON DELETE cascade,
@@ -67,6 +68,7 @@ CREATE TABLE `project` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`user_id` text NOT NULL,
`subscription_tier` text,
`created_at` text,
`updated_at` text,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
17 changes: 16 additions & 1 deletion drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "5",
"dialect": "sqlite",
"id": "6f0c003b-0d0a-48b6-b80a-f31d1d667ea1",
"id": "5ff1945a-c0a1-46fa-92d8-6b6b317a86c2",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"access_token": {
@@ -180,6 +180,14 @@
"notNull": true,
"autoincrement": false
},
"edited": {
"name": "edited",
"type": "numeric",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'false'"
},
"created_at": {
"name": "created_at",
"type": "text",
@@ -475,6 +483,13 @@
"notNull": true,
"autoincrement": false
},
"subscription_tier": {
"name": "subscription_tier",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"created_at": {
"name": "created_at",
"type": "text",
4 changes: 2 additions & 2 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "5",
"when": 1708010108881,
"tag": "0000_reflective_korg",
"when": 1708289370361,
"tag": "0000_smiling_wallop",
"breakpoints": true
}
]
180 changes: 91 additions & 89 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
{
"name": "supso",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "bunx --bun vite dev",
"build": "bunx vite build",
"preview": "bunx vite preview",
"start": "npm run db:migrate && node build/index.js",
"test": "bun run test:integration && bun run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest",
"db:generate": "npx drizzle-kit generate:sqlite",
"db:push": "bunx --bun drizzle-kit push:sqlite",
"db:migrate": "bun ./scripts/migrate.ts"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^2.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
"@types/pg": "^8.10.9",
"@types/swagger-jsdoc": "^6.0.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.16",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.20.13",
"esbuild": "^0.19.12",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"sass": "^1.70.0",
"svelte": "^4.2.8",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.3.6",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vitest": "^1.0.0"
},
"type": "module",
"dependencies": {
"@carbon/charts-svelte": "^1.13.18",
"@cartamd/plugin-code": "^3.0.1",
"@cartamd/plugin-emoji": "^3.1.0",
"@cartamd/plugin-slash": "^3.1.0",
"@internationalized/date": "^3.5.1",
"@libsql/client": "^0.3.6",
"@lucia-auth/adapter-drizzle": "^1.0.1",
"bits-ui": "^0.13.0",
"carta-md": "^3.5.0",
"clsx": "^2.1.0",
"cmdk-sv": "^0.0.12",
"date-fns": "^3.0.6",
"dedent": "^1.5.1",
"drizzle-orm": "^0.29.2",
"drizzle-zod": "^0.5.1",
"feed": "^4.2.2",
"formsnap": "^0.4.2",
"isomorphic-dompurify": "^2.3.0",
"lucia": "^3.0.1",
"lucide-svelte": "^0.303.0",
"mode-watcher": "^0.1.2",
"rambda": "^8.6.0",
"shiki": "^1.0.0",
"sse.js": "^2.2.0",
"superjson": "^2.2.1",
"svelte-dnd-list": "^0.1.8",
"svelte-highlight": "^7.4.7",
"svelte-sonner": "^0.3.11",
"sveltekit-superforms": "^1.13.1",
"swagger-jsdoc": "^6.2.8",
"tailwind-merge": "^2.2.0",
"tailwind-variants": "^0.1.19",
"tsx": "^4.7.0",
"ua-parser-js": "2.0.0-beta.1",
"unique-names-generator": "^4.7.1",
"zod": "^3.22.4"
}
"name": "supso",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "bunx --bun vite dev",
"build": "bunx vite build",
"preview": "bunx vite preview",
"start": "npm run db:migrate && node build/index.js",
"test": "bun run test:integration && bun run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest",
"db:generate": "npx drizzle-kit generate:sqlite",
"db:push": "bunx --bun drizzle-kit push:sqlite",
"db:migrate": "bun ./scripts/migrate.ts"
},
"devDependencies": {
"@playwright/test": "^1.28.1",
"@sveltejs/adapter-node": "^2.0.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "8.56.0",
"@types/pg": "^8.10.9",
"@types/swagger-jsdoc": "^6.0.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"autoprefixer": "^10.4.16",
"dotenv": "^16.3.1",
"drizzle-kit": "^0.20.13",
"esbuild": "^0.19.12",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"postcss": "^8.4.32",
"postcss-load-config": "^5.0.2",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"prettier-plugin-tailwindcss": "^0.5.9",
"sass": "^1.70.0",
"svelte": "^4.2.8",
"svelte-check": "^3.6.0",
"tailwindcss": "^3.3.6",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vitest": "^1.0.0"
},
"type": "module",
"dependencies": {
"@carbon/charts-svelte": "^1.13.18",
"@cartamd/plugin-code": "^3.0.1",
"@cartamd/plugin-emoji": "^3.1.0",
"@cartamd/plugin-slash": "^3.1.0",
"@internationalized/date": "^3.5.1",
"@libsql/client": "^0.3.6",
"@lucia-auth/adapter-drizzle": "^1.0.1",
"bits-ui": "^0.13.0",
"carta-md": "^3.5.0",
"clsx": "^2.1.0",
"cmdk-sv": "^0.0.12",
"crypto": "^1.0.1",
"date-fns": "^3.0.6",
"dedent": "^1.5.1",
"drizzle-orm": "^0.29.2",
"drizzle-zod": "^0.5.1",
"feed": "^4.2.2",
"formsnap": "^0.4.2",
"isomorphic-dompurify": "^2.3.0",
"lemonsqueezy.ts": "^0.1.7",
"lucia": "^3.0.1",
"lucide-svelte": "^0.303.0",
"mode-watcher": "^0.1.2",
"rambda": "^8.6.0",
"shiki": "^1.0.0",
"sse.js": "^2.2.0",
"superjson": "^2.2.1",
"svelte-dnd-list": "^0.1.8",
"svelte-highlight": "^7.4.7",
"svelte-sonner": "^0.3.11",
"sveltekit-superforms": "^1.13.1",
"swagger-jsdoc": "^6.2.8",
"tailwind-merge": "^2.2.0",
"tailwind-variants": "^0.1.19",
"tsx": "^4.7.0",
"ua-parser-js": "2.0.0-beta.1",
"unique-names-generator": "^4.7.1",
"zod": "^3.22.4"
}
}
24 changes: 24 additions & 0 deletions src/lib/components/alerts/delete-comment-alert.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script lang="ts">
import * as AlertDialog from '$lib/components/ui/alert-dialog';
import type { Writable } from 'svelte/store';
export let open: Writable<string | null>;
</script>

<AlertDialog.Root open={!!$open} onOpenChange={() => open.set(null)}>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
This action cannot be undone. This will permanently delete the comment.
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<form action="?/deleteComment" method="POST">
<input type="hidden" name="id" value={$open} />
<AlertDialog.Action type="submit">Continue</AlertDialog.Action>
</form>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>
62 changes: 62 additions & 0 deletions src/lib/components/dashboard/comment-card.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script lang="ts">
import * as Card from '$lib/components/ui/card';
import * as Avatar from '$lib/components/ui/avatar';
import { Button } from '$lib/components/ui/button';
import { type Comment } from '$lib/db/schema';
import { formatDateShort } from '$lib/format/date';
import { writable, type Writable } from 'svelte/store';
import { Textarea } from '$lib/components/ui/textarea';
import { page } from '$app/stores';
export let comment: Comment;
export let deleteCommentAlertId: Writable<string | null> | undefined;
export let onReply: ((username: string) => void) | undefined;
export let hideActions: boolean = false;
export let editing = writable<boolean>(false);
export const author = comment.userId === $page.data.user.id;
</script>

<Card.Root class="flex gap-2 p-4">
<Avatar.Root class="h-8 w-8 text-sm">
<Avatar.Fallback>{comment.user.username[0].toUpperCase()}</Avatar.Fallback>
</Avatar.Root>
<div class="flex flex-1 flex-col gap-2">
<div class="flex gap-2">
<div class="text-sm">{comment.user.username}</div>
<div class="text-muted-foreground text-sm">{formatDateShort(comment.createdAt)}</div>
</div>
<div class="text-sm">
{comment.content}
</div>
{#if !hideActions && !$editing}
<div class="flex gap-2">
{#if onReply}
<Button
variant="link"
class="text-muted-foreground h-5 p-0 text-sm"
on:click={() => onReply?.(comment.user.username)}>Reply</Button
>
{/if}
{#if author}
<Button
variant="link"
class="text-muted-foreground h-5 p-0 text-sm"
on:click={() => editing.set(true)}>Edit</Button
>
{/if}
<Button
variant="link"
class="text-muted-foreground h-5 p-0 text-sm"
on:click={() => deleteCommentAlertId?.set(comment.id)}>Delete</Button
>
</div>
{/if}
{#if $editing}
<form action="?/updateComment" method="POST" class="flex flex-col gap-2">
<input type="hidden" name="id" value={comment.id} />
<Textarea name="content" value={comment.content} />
<Button type="submit" variant="secondary" size="sm" class="self-end">Save</Button>
</form>
{/if}
</div>
</Card.Root>
27 changes: 27 additions & 0 deletions src/lib/components/dashboard/event-comment-editor.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import { CartaEditor, Carta } from 'carta-md';
import { emoji } from '@cartamd/plugin-emoji';
import { code } from '@cartamd/plugin-code';
import 'carta-md/dark.css';
import '$lib/styles/discord.scss';
export let value: string;
export let onChange: (value: string) => void;
export const carta = new Carta({
disableIcons: true,
extensions: [
emoji(),
code(),
{ listeners: [['change', (event) => onChange(event.target.value)]] }
]
});
</script>

<CartaEditor
bind:value
placeholder="Leave a comment for this event"
mode="tabs"
theme="discord"
{carta}
></CartaEditor>
Loading

0 comments on commit 470e9aa

Please sign in to comment.