Skip to content

Commit

Permalink
Updated db schema for details and added fixed some minor things in UI…
Browse files Browse the repository at this point in the history
… panel
  • Loading branch information
fayazara committed Sep 2, 2023
1 parent 220fe85 commit 9c465da
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 42 deletions.
10 changes: 5 additions & 5 deletions components/Dashboard/Feedback/Details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-2.5 flex items-center gap-x-3"
>
<div
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-950"
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-950"
>
<UIcon
name="i-heroicons-arrow-down-on-square-20-solid"
Expand All @@ -90,7 +90,7 @@
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-2.5 flex items-center gap-x-3"
>
<div
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-950"
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-950"
>
<!-- <UIcon name="i-heroicons-globe-alt" class="h-6 w-6"/> -->
<span class="text-2xl">🇮🇳</span>
Expand All @@ -108,7 +108,7 @@
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-2.5 flex items-center gap-x-3"
>
<div
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-950"
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-950"
>
<Icon name="logos:chrome" class="h-6 w-6" />
</div>
Expand All @@ -125,7 +125,7 @@
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-2.5 flex items-center gap-x-3"
>
<div
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-950"
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-950"
>
<Icon
name="heroicons:device-phone-mobile-20-solid"
Expand All @@ -145,7 +145,7 @@
class="bg-gray-50 dark:bg-gray-900 rounded-lg p-2.5 flex items-center gap-x-3"
>
<div
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-950"
class="h-10 w-10 rounded-full flex items-center justify-center bg-gray-200 dark:bg-gray-950"
>
<Icon name="heroicons:arrows-pointing-out" class="h-6 w-6" />
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/Dashboard/Onboard/CategoryOption.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</template>

<script lang="ts" setup>
const props = defineProps<{
defineProps<{
description: string;
title: string;
checked: boolean;
Expand Down
4 changes: 1 addition & 3 deletions components/Dashboard/Onboard/IdeaForm.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<template>
<div class="max-w-lg w-full">
<div class="mb-12">
<h2 class="text-2xl font-bold tracking-tight">
Add an idea {{ projectId }}
</h2>
<h2 class="text-2xl font-bold tracking-tight">Add your first idea</h2>
<p class="text-sm">
An idea, bug or suggestion. This is optional, you can always add it
later.
Expand Down
16 changes: 2 additions & 14 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import "dotenv/config";
import { Config } from "drizzle-kit";
const { NODE_ENV, TURSO_DB_URL, TURSO_DB_TOKEN } = process.env;
const isDev = NODE_ENV === "development";
const { TURSO_DB_URL, TURSO_DB_TOKEN } = process.env;

// Local
const sqlite = {
driver: "better-sqlite",
dbCredentials: {
url: "./server/db/db.sqlite",
},
};

// Turso
const turso = {
driver: "turso",
dbCredentials: {
Expand All @@ -20,10 +10,8 @@ const turso = {
},
};

const dbCreds = isDev ? sqlite : turso;

export default {
schema: "./server/db/schema.ts",
out: "./server/db/migrations",
...dbCreds,
...turso,
} satisfies Config;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"migrate": "drizzle-kit generate:sqlite",
"push": "drizzle-kit push:sqlite"
"db:migrate": "drizzle-kit generate:sqlite",
"db:deploy": "drizzle-kit push:sqlite"
},
"devDependencies": {
"@nuxt/devtools": "0.7.4",
Expand Down
1 change: 0 additions & 1 deletion pages/dashboard/index/[projectId]/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import { formatTimeAgo } from "@vueuse/core";
const route = useRoute();
const { projectId } = route.params;
const { data: project } = await useFetch(`/api/projects/${projectId}/overview`);
console.log(project.value);
const feedbackStylesBase = {
base: "relative flex-1 flex flex-col w-full focus:outline-none m-2 rounded-xl",
};
Expand Down
1 change: 0 additions & 1 deletion server/api/projects/[id]/overview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default eventHandler(async (event) => {
const feedbackCount = await getFeedbackCountOfProject(filterBy);
const countByStatusQs = await feedbackCountByStatus(filterBy);
const countByCategoryQs = await feedbackCountByCategory(filterBy);
console.log(countByStatusQs);
let countByStatus: any = {};
for (const entry of countByStatusQs) {
const { status, count } = entry;
Expand Down
6 changes: 3 additions & 3 deletions server/db/migrations/0000_marvelous_madrox.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE `feedbacks` (
CREATE TABLE IF NOT EXISTS `feedbacks` (
`id` integer PRIMARY KEY NOT NULL,
`project_id` integer NOT NULL,
`message` text NOT NULL,
Expand All @@ -14,7 +14,7 @@ CREATE TABLE `feedbacks` (
FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `projects` (
CREATE TABLE IF NOT EXISTS `projects` (
`id` integer PRIMARY KEY NOT NULL,
`user_id` integer NOT NULL,
`name` text NOT NULL,
Expand All @@ -27,7 +27,7 @@ CREATE TABLE `projects` (
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE TABLE `users` (
CREATE TABLE IF NOT EXISTS `users` (
`id` integer PRIMARY KEY NOT NULL,
`github_id` integer NOT NULL,
`login` text,
Expand Down
15 changes: 3 additions & 12 deletions server/utils/db.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import { createClient as createLibSQLClient } from "@libsql/client/http";
import { drizzle as drizzleLibSQL, LibSQLDatabase } from "drizzle-orm/libsql";
import { drizzle, BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
// @ts-ignore
import Database from "better-sqlite3";
import { join } from "pathe";

export * as tables from "~/server/db/schema";

let _db: BetterSQLite3Database | LibSQLDatabase | null = null;
let _db: LibSQLDatabase | null = null;

export const useDb = () => {
if (!_db) {
if (process.dev) {
// local sqlite in development
const { dbDir } = useRuntimeConfig();
const sqlite = new Database(join(dbDir, "./db.sqlite"));
_db = drizzle(sqlite);
} else if (process.env.TURSO_DB_URL && process.env.TURSO_DB_TOKEN) {
// Turso in production
if (process.env.TURSO_DB_URL && process.env.TURSO_DB_TOKEN) {
// TURSO in production
_db = drizzleLibSQL(
createLibSQLClient({
url: process.env.TURSO_DB_URL,
Expand Down

0 comments on commit 9c465da

Please sign in to comment.