-
Notifications
You must be signed in to change notification settings - Fork 1
Integrate request feature #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Buuh2511
wants to merge
2
commits into
main
Choose a base branch
from
feat/request-functionality
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/backend/src/feature-request/feature-request.controller.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Controller, Get, Post, Body } from '@nestjs/common'; | ||
| import { ApiTags, ApiOperation, ApiResponse, ApiBody } from '@nestjs/swagger'; | ||
| import { FeatureRequestService } from './feature-request.service'; | ||
| import { CreateFeatureRequestDto } from '@polypay/shared'; | ||
|
|
||
| @ApiTags('feature-requests') | ||
| @Controller('feature-requests') | ||
| export class FeatureRequestController { | ||
| constructor(private readonly featureRequestService: FeatureRequestService) {} | ||
|
|
||
| @Post() | ||
| @ApiOperation({ summary: 'Submit a new feature request' }) | ||
| @ApiBody({ type: CreateFeatureRequestDto }) | ||
| @ApiResponse({ | ||
| status: 201, | ||
| description: 'Feature request submitted successfully', | ||
| }) | ||
| @ApiResponse({ status: 400, description: 'Bad request' }) | ||
| async create(@Body() dto: CreateFeatureRequestDto) { | ||
| return this.featureRequestService.create(dto); | ||
| } | ||
|
|
||
| @Get() | ||
| @ApiOperation({ summary: 'Get all feature requests (internal)' }) | ||
| @ApiResponse({ status: 200, description: 'List of feature requests' }) | ||
| async findAll() { | ||
| return this.featureRequestService.findAll(); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
packages/backend/src/feature-request/feature-request.module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { Module } from '@nestjs/common'; | ||
| import { FeatureRequestController } from './feature-request.controller'; | ||
| import { FeatureRequestService } from './feature-request.service'; | ||
| import { DatabaseModule } from '@/database/database.module'; | ||
|
|
||
| @Module({ | ||
| imports: [DatabaseModule], | ||
| controllers: [FeatureRequestController], | ||
| providers: [FeatureRequestService], | ||
| exports: [FeatureRequestService], | ||
| }) | ||
| export class FeatureRequestModule {} |
27 changes: 27 additions & 0 deletions
27
packages/backend/src/feature-request/feature-request.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Injectable, Logger } from '@nestjs/common'; | ||
| import { PrismaService } from '@/database/prisma.service'; | ||
| import { CreateFeatureRequestDto } from '@polypay/shared'; | ||
|
|
||
| @Injectable() | ||
| export class FeatureRequestService { | ||
| private readonly logger = new Logger(FeatureRequestService.name); | ||
|
|
||
| constructor(private prisma: PrismaService) {} | ||
|
|
||
| async create(dto: CreateFeatureRequestDto) { | ||
| const featureRequest = await this.prisma.featureRequest.create({ | ||
| data: { | ||
| content: dto.content, | ||
| }, | ||
| }); | ||
|
|
||
| this.logger.log(`Created feature request: ${featureRequest.id}`); | ||
| return featureRequest; | ||
| } | ||
|
|
||
| async findAll() { | ||
| return this.prisma.featureRequest.findMany({ | ||
| orderBy: { createdAt: 'desc' }, | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/nextjs/components/modals/RequestFeatureModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| import Image from "next/image"; | ||
| import ModalContainer from "./ModalContainer"; | ||
| import { zodResolver } from "@hookform/resolvers/zod"; | ||
| import { X } from "lucide-react"; | ||
| import { useForm } from "react-hook-form"; | ||
| import { toast } from "react-hot-toast"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import { FeatureRequestFormData, featureRequestSchema } from "~~/lib/form/schemas"; | ||
| import { featureRequestApi } from "~~/services/api"; | ||
| import { ModalProps } from "~~/types/modal"; | ||
|
|
||
| const BUTTON_BASE_CLASS = "text-main-black font-medium h-9 text-sm rounded-lg disabled:opacity-50"; | ||
|
|
||
| const RequestFeatureModal: React.FC<ModalProps> = ({ isOpen, onClose }) => { | ||
| const { | ||
| register, | ||
| handleSubmit, | ||
| formState: { errors, isSubmitting }, | ||
| reset, | ||
| watch, | ||
| } = useForm<FeatureRequestFormData>({ | ||
| resolver: zodResolver(featureRequestSchema), | ||
| mode: "onChange", | ||
| defaultValues: { content: "" }, | ||
| }); | ||
|
|
||
| const content = watch("content"); | ||
| const isDisabled = isSubmitting || !content?.trim(); | ||
|
|
||
| const onSubmit = async (data: FeatureRequestFormData) => { | ||
| try { | ||
| await featureRequestApi.create(data); | ||
| toast.success("Feature request submitted successfully!"); | ||
| reset(); | ||
| onClose(); | ||
| } catch (error) { | ||
| console.error("Error submitting feature request:", error); | ||
| toast.error("Failed to submit feature request"); | ||
| } | ||
| }; | ||
|
|
||
| const handleCancel = () => { | ||
| reset(); | ||
| onClose(); | ||
| }; | ||
|
|
||
| return ( | ||
| <ModalContainer | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| isCloseButton={false} | ||
| className="bg-white border border-white rounded-4xl max-w-xl p-0" | ||
| > | ||
| <div className="relative w-full h-full"> | ||
| <div className="p-4 relative"> | ||
| <Image | ||
| className="absolute w-full h-full top-0 left-0 z-10 rounded-t-4xl" | ||
| src="/dashboard/bg-request-feature.png" | ||
| alt="background" | ||
| width={512} | ||
| height={500} | ||
| /> | ||
| <div className="relative z-50 pt-3"> | ||
| <h3 className="text-2xl font-medium text-center text-main-black">Request a new feature</h3> | ||
| <button | ||
| type="button" | ||
| className="absolute h-9 w-9 right-2 top-1/2 transform -translate-y-1/2 flex items-center justify-center rounded-lg border border-grey-200 cursor-pointer" | ||
| onClick={handleCancel} | ||
| aria-label="Close" | ||
| > | ||
| <X width={14} height={14} /> | ||
| </button> | ||
| </div> | ||
| <form onSubmit={handleSubmit(onSubmit)}> | ||
| <div className="my-8 relative z-50"> | ||
| <textarea | ||
| {...register("content")} | ||
| className="w-full outline-none border border-grey-200 bg-[#FFFFFFCC] rounded-2xl p-4 h-[180px] resize-none" | ||
| placeholder="Describe the feature you'd like to see — what problem it solves and how you'd use it." | ||
| /> | ||
| {errors.content && <p className="text-red-500 text-sm mt-2">{errors.content.message}</p>} | ||
| </div> | ||
| </form> | ||
| </div> | ||
| <div className="flex items-center gap-2 w-full px-5 py-4 border-t border-grey-200 bg-grey-50 rounded-b-4xl"> | ||
| <button | ||
| type="button" | ||
| className={`${BUTTON_BASE_CLASS} w-[90px] text-center bg-grey-100`} | ||
| onClick={handleCancel} | ||
| disabled={isSubmitting} | ||
| > | ||
| Cancel | ||
| </button> | ||
| <button | ||
| type="submit" | ||
| className={`${BUTTON_BASE_CLASS} w-full bg-main-pink disabled:cursor-not-allowed`} | ||
| onClick={handleSubmit(onSubmit)} | ||
| disabled={isDisabled} | ||
| > | ||
| {isSubmitting ? "Submitting..." : "Submit"} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </ModalContainer> | ||
| ); | ||
| }; | ||
|
|
||
| export default RequestFeatureModal; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { apiClient } from "./apiClient"; | ||
| import { API_ENDPOINTS } from "@polypay/shared"; | ||
| import { CreateFeatureRequestDto, FeatureRequest } from "@polypay/shared"; | ||
|
|
||
| export const featureRequestApi = { | ||
| create: async (dto: CreateFeatureRequestDto): Promise<FeatureRequest> => { | ||
| const { data } = await apiClient.post<FeatureRequest>(API_ENDPOINTS.featureRequests.base, dto); | ||
| return data; | ||
| }, | ||
|
|
||
| getAll: async (): Promise<FeatureRequest[]> => { | ||
| const { data } = await apiClient.get<FeatureRequest[]>(API_ENDPOINTS.featureRequests.base); | ||
| return data; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,7 +167,7 @@ | |
| h2, | ||
| h3, | ||
| h4 { | ||
| margin-bottom: 0.5rem; | ||
| /* margin-bottom: 0.5rem; */ | ||
| line-height: 1; | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/shared/src/dto/feature-request/create-feature-request.dto.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { IsNotEmpty, IsString } from "class-validator"; | ||
|
|
||
| export class CreateFeatureRequestDto { | ||
| @IsNotEmpty() | ||
| @IsString() | ||
| content: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "./create-feature-request.dto"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface FeatureRequest { | ||
| id: string; | ||
| content: string; | ||
| createdAt: string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you're not running: 'npx prisma migrate dev' to generate migration file? And if you are running, you should remove old migration files to consolidate migration files
