mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
add onboarding and feedback models
This commit is contained in:
18
dashboard/server/api/feedback/add.post.ts
Normal file
18
dashboard/server/api/feedback/add.post.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
import { FeedbackModel } from '@schema/FeedbackSchema';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event);
|
||||
if (!data) return;
|
||||
|
||||
const { text } = await readBody(event);
|
||||
|
||||
const save = await FeedbackModel.create({
|
||||
user_id: data.user.id,
|
||||
project_id: data.project_id,
|
||||
text
|
||||
});
|
||||
|
||||
return { ok: true }
|
||||
|
||||
});
|
||||
19
dashboard/server/api/onboarding/add.post.ts
Normal file
19
dashboard/server/api/onboarding/add.post.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
import { OnboardingModel } from '@schema/OnboardingSchema';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event);
|
||||
if (!data) return;
|
||||
|
||||
const { job, analytics } = await readBody(event);
|
||||
|
||||
|
||||
const save = await OnboardingModel.create({
|
||||
user_id: data.user.id,
|
||||
job,
|
||||
analytics
|
||||
});
|
||||
|
||||
return { ok: true }
|
||||
|
||||
});
|
||||
9
dashboard/server/api/onboarding/exist.ts
Normal file
9
dashboard/server/api/onboarding/exist.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
import { OnboardingModel } from '@schema/OnboardingSchema';
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
const data = await getRequestData(event);
|
||||
if (!data) return;
|
||||
const exist = await OnboardingModel.exists({ user_id: data.user.id });
|
||||
return { exist }
|
||||
});
|
||||
16
shared/schema/FeedbackSchema.ts
Normal file
16
shared/schema/FeedbackSchema.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TFeedback = {
|
||||
user_id: Types.ObjectId,
|
||||
project_id: Types.ObjectId,
|
||||
text: string
|
||||
}
|
||||
|
||||
const FeedbackSchema = new Schema<TFeedback>({
|
||||
user_id: { type: Schema.Types.ObjectId, required: true },
|
||||
project_id: { type: Schema.Types.ObjectId, required: true },
|
||||
text: { type: String, required: true },
|
||||
});
|
||||
|
||||
export const FeedbackModel = model<TFeedback>('feedbacks', FeedbackSchema);
|
||||
|
||||
16
shared/schema/OnboardingSchema.ts
Normal file
16
shared/schema/OnboardingSchema.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { model, Schema, Types } from 'mongoose';
|
||||
|
||||
export type TOnboarding = {
|
||||
user_id: Types.ObjectId,
|
||||
analytics: string,
|
||||
job: string
|
||||
}
|
||||
|
||||
const OnboardingSchema = new Schema<TOnboarding>({
|
||||
user_id: { type: Schema.Types.ObjectId, required: true },
|
||||
analytics: { type: String, required: false },
|
||||
job: { type: String, required: false },
|
||||
});
|
||||
|
||||
export const OnboardingModel = model<TOnboarding>('onboardings', OnboardingSchema);
|
||||
|
||||
Reference in New Issue
Block a user