Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions packages/api/src/review/review.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Controller, Get, Inject, Middleware, Post } from "@outwalk/firefly";
import { Request } from "express";
import { ReviewService } from "./review.service";
import { session } from "@/_middleware/session";
import sendToWebhook from "@/logging/webhook";
import { BadRequest } from "@outwalk/firefly/errors";

@Controller()
@Middleware(session)
export class ReviewController {

@Inject()
reviewService: ReviewService;

@Post()
async createReview({ body, session }: Request) {
const rating = Number(body?.rating);
if (!Number.isFinite(rating) || rating < 1 || rating > 5) {
throw new BadRequest("Rating must be between 1 and 5.");
}

const message = typeof body?.message === "string" ? body.message.trim() : "";
const review = await this.reviewService.createReview({
rating,
message,
userId: session?.user?.id
});

await sendToWebhook({
embeds: [
{
title: "New Review Submitted",
description: `Rating: **${rating}/5**${message ? `\\nMessage: ${message}` : ""}`,
footer: {
text: review.userEmail ? `From ${review.userEmail}` : "From an authenticated user"
},
timestamp: new Date()
}
]
});

return { success: true };
}

@Get()
async listReviews() {
return this.reviewService.listReviews();
}
}
20 changes: 20 additions & 0 deletions packages/api/src/review/review.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Entity, Model, Prop } from "@/_lib/mongoose";
import mongoose from "mongoose";
import { User } from "@/user/user.entity";

@Entity({ timestamps: true })
export class Review extends Model {
id: string;

@Prop({ type: Number, required: true, min: 1, max: 5 })
rating: number;

@Prop({ type: String, default: "" })
message: string;

@Prop({ type: mongoose.Schema.Types.ObjectId, ref: "User", required: false })
user?: User | string;

@Prop({ type: String, default: "" })
userEmail?: string;
}
29 changes: 29 additions & 0 deletions packages/api/src/review/review.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Injectable, Inject } from "@outwalk/firefly";
import { Review } from "./review.entity";
import { UserService } from "@/user/user.service";

@Injectable()
export class ReviewService {
@Inject()
userService: UserService;

async createReview({
rating,
message,
userId
}: { rating: number; message?: string; userId?: string }) {
const doc: Partial<Review> = { rating, message: message ?? "" };

if (userId) {
doc.user = userId;
const user = await this.userService.getUserById(userId);
if (user?.email) doc.userEmail = user.email;
}

return Review.create(doc);
}

async listReviews(): Promise<Review[]> {
return Review.find().sort({ createdAt: -1 }).lean<Review[]>().exec();
}
}
8 changes: 4 additions & 4 deletions packages/app/ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B9UMLF8BH7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = App/Info.plist;
Expand All @@ -393,7 +393,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = "com.ottegi.sequenced-app";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -417,7 +417,7 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = B9UMLF8BH7;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
INFOPLIST_FILE = App/Info.plist;
Expand All @@ -428,7 +428,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.0;
MARKETING_VERSION = 2.0.1;
PRODUCT_BUNDLE_IDENTIFIER = "com.ottegi.sequenced-app";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/assets/social_icons/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/app/src/components/calendar/ActiveCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ export default function ActiveCalendar({ skeleton }: ActiveCalendarProps) {
<span className="text-lg font-semibold text-primary">This Week</span>
</div>
</div>
<div className="flex flex-row w-44 md:w-56">
<div className="flex justify-center w-full rounded-2xl border border-accent-blue/20 bg-accent-blue-50/60 shadow-inner dark:bg-[rgba(99,102,241,0.12)]">
<div className="flex flex-row w-48 md:w-60">
<div className="flex justify-center w-full rounded-2xl border border-accent-blue/30 bg-white shadow-sm ring-1 ring-accent-blue/10 focus-within:ring-2 focus-within:ring-accent-blue/30 dark:bg-[rgba(15,23,42,0.85)] dark:border-accent-blue/40">
<input
type="date"
value={formatDate(appData.activeDate)}
onChange={changeActiveMonth}
className="w-full h-full rounded-2xl border-none bg-transparent px-2 py-1 text-center text-sm font-semibold text-primary focus:outline-none"
className="w-full h-full rounded-2xl border-none bg-transparent px-3 py-2 text-center text-sm font-semibold text-primary focus:outline-none"
/>
</div>
</div>
Expand Down
Loading