feat: feedback form
This commit is contained in:
25
packages/db/src/repository/feedback.repo.ts
Normal file
25
packages/db/src/repository/feedback.repo.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import type { SupabaseClient } from "@supabase/supabase-js";
|
||||
|
||||
import type { Database } from "@kan/db/types/database.types";
|
||||
|
||||
export const create = async (
|
||||
db: SupabaseClient<Database>,
|
||||
feedbackInput: {
|
||||
feedback: string;
|
||||
createdBy: string;
|
||||
url: string;
|
||||
},
|
||||
) => {
|
||||
const { data } = await db
|
||||
.from("feedback")
|
||||
.insert({
|
||||
feedback: feedbackInput.feedback,
|
||||
createdBy: feedbackInput.createdBy,
|
||||
url: feedbackInput.url,
|
||||
})
|
||||
.select(`id`)
|
||||
.limit(1)
|
||||
.single();
|
||||
|
||||
return data;
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { relations } from "drizzle-orm";
|
||||
import {
|
||||
bigint,
|
||||
bigserial,
|
||||
boolean,
|
||||
index,
|
||||
integer,
|
||||
pgEnum,
|
||||
@@ -465,3 +466,22 @@ export const slugs = pgTable("workspace_slugs", {
|
||||
slug: varchar("slug", { length: 255 }).notNull().unique(),
|
||||
type: slugTypeEnum("type").notNull(),
|
||||
});
|
||||
|
||||
export const feedback = pgTable("feedback", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
feedback: text("feedback").notNull(),
|
||||
createdBy: uuid("createdBy")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
url: text("url").notNull(),
|
||||
reviewed: boolean("reviewed").default(false).notNull(),
|
||||
});
|
||||
|
||||
export const feedbackRelations = relations(feedback, ({ one }) => ({
|
||||
createdBy: one(users, {
|
||||
fields: [feedback.createdBy],
|
||||
references: [users.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
@@ -394,6 +394,44 @@ export type Database = {
|
||||
},
|
||||
]
|
||||
}
|
||||
feedback: {
|
||||
Row: {
|
||||
createdAt: string
|
||||
createdBy: string
|
||||
feedback: string
|
||||
id: number
|
||||
reviewed: boolean
|
||||
updatedAt: string | null
|
||||
url: string
|
||||
}
|
||||
Insert: {
|
||||
createdAt?: string
|
||||
createdBy: string
|
||||
feedback: string
|
||||
id?: number
|
||||
reviewed?: boolean
|
||||
updatedAt?: string | null
|
||||
url: string
|
||||
}
|
||||
Update: {
|
||||
createdAt?: string
|
||||
createdBy?: string
|
||||
feedback?: string
|
||||
id?: number
|
||||
reviewed?: boolean
|
||||
updatedAt?: string | null
|
||||
url?: string
|
||||
}
|
||||
Relationships: [
|
||||
{
|
||||
foreignKeyName: "feedback_createdBy_user_id_fk"
|
||||
columns: ["createdBy"]
|
||||
isOneToOne: false
|
||||
referencedRelation: "user"
|
||||
referencedColumns: ["id"]
|
||||
},
|
||||
]
|
||||
}
|
||||
import: {
|
||||
Row: {
|
||||
createdAt: string
|
||||
|
||||
Reference in New Issue
Block a user