Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashyap1ankit committed Dec 22, 2024
2 parents a395895 + de30736 commit 9f52e9d
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 78 deletions.
2 changes: 1 addition & 1 deletion app/action/sendContactEmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export async function sendContactEmail(username, fromEmail, message, subject) {
subject: subject,
html: ContactEmailTemplate({ username, message, fromEmail }),
});
console.log(res);

if (!res.data) throw new Error(res.error.name);

return {
Expand Down
2 changes: 1 addition & 1 deletion app/api/teams/create-team/route.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dbConnect from "../../../../lib/dbConnect";
import { teamSchema } from "../../../../model/Schema/teamSchema";
import { TeamModel } from "../../../../model/Team";
import { UserModel } from "../../../../model/User";
import UserModel from "../../../../model/User";

export async function POST(request) {
await dbConnect();
Expand Down
2 changes: 1 addition & 1 deletion app/api/teams/send-request/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dbConnect from "../../../../lib/dbConnect";
import { TeamModel } from "../../../../model/Team";
import { UserModel } from "../../../../model/User";
import UserModel from "../../../../model/User";

export async function POST(req) {
await dbConnect();
Expand Down
35 changes: 30 additions & 5 deletions model/User.js → model/User.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
import mongoose, { models, model } from "mongoose";
const { Schema } = mongoose;
import mongoose, { Document, Model, Schema } from "mongoose";

const userSchema = new Schema({
interface IUser extends Document {
username: string;
name?: string;
email: string;
bio?: string;
discordId?: string;
googleId?: string;
twoFactorActivated: boolean;
createdAt: Date;
verifyCode: string;
verifyCodeExpiry: Date;
password: string;
eventsRegistered: Array<mongoose.Types.ObjectId>;
}

interface IUserMethods {
updatePassword(newPassword: string): Promise<void>;
}

interface IUserModel extends Model<IUser, {}, IUserMethods> {
findByEmail(email: string): Promise<IUser | null>;
}

// Created the User Schema
const userSchema = new Schema<IUser, IUserModel, IUserMethods>({
_id: {
type: Schema.Types.ObjectId,
required: true,
Expand Down Expand Up @@ -62,6 +85,8 @@ const userSchema = new Schema({
],
});

const UserModel = models.UserModel || model("UserModel", userSchema);

// Created the User Model
const UserModel =
mongoose.models.UserModel ||
mongoose.model<IUser, IUserModel>("UserModel", userSchema);
export default UserModel;
161 changes: 91 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@eslint/js": "^9.17.0",
"@tailwindcss/typography": "0.5.13",
"@types/bcryptjs": "^2.4.6",
"@types/mongoose": "^5.11.97",
"@types/node": "20.11.24",
"@types/react": "18.2.61",
"@types/react-dom": "18.2.19",
Expand Down

0 comments on commit 9f52e9d

Please sign in to comment.