-
Notifications
You must be signed in to change notification settings - Fork 0
Roko/fly talks be #533
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
rokoperki
wants to merge
4
commits into
main
Choose a base branch
from
roko/fly-talks-be
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
Roko/fly talks be #533
Changes from all commits
Commits
Show all changes
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import { | ||
EventDto, | ||
EventModifyDto, | ||
EventWithCompanyDto, | ||
EventWithSpeakerDto, | ||
UserToEventDto, | ||
} from '@ddays-app/types'; | ||
import { | ||
BadRequestException, | ||
Body, | ||
Controller, | ||
Delete, | ||
|
@@ -12,8 +15,11 @@ import { | |
ParseIntPipe, | ||
Patch, | ||
Post, | ||
UploadedFile, | ||
UseGuards, | ||
UseInterceptors, | ||
} from '@nestjs/common'; | ||
import { FileInterceptor } from '@nestjs/platform-express'; | ||
import { AdminGuard } from 'src/auth/admin.guard'; | ||
|
||
import { EventService } from './event.service'; | ||
|
@@ -28,11 +34,30 @@ export class EventController { | |
return await this.eventService.create(dto); | ||
} | ||
|
||
@Post('apply-to-flytalk') | ||
async applyToFlyTalk(@Body() dto: UserToEventDto): Promise<UserToEventDto> { | ||
return await this.eventService.applyToFlyTalk(dto); | ||
} | ||
|
||
@Post('upload-cv') | ||
@UseInterceptors(FileInterceptor('file')) | ||
async uploadCV(@UploadedFile() file: Express.Multer.File): Promise<string> { | ||
if (!file) { | ||
throw new BadRequestException('File is required'); | ||
} | ||
return await this.eventService.uploadCV(file); | ||
} | ||
|
||
@Get('with-speaker') | ||
async getAllWithSpeakerAnd(): Promise<EventWithSpeakerDto[]> { | ||
return await this.eventService.getAllWithSpeaker(); | ||
} | ||
|
||
@Get('with-company') | ||
async GetAllWithCompany(): Promise<EventWithCompanyDto[]> { | ||
return await this.eventService.getAllWithCompany(); | ||
} | ||
|
||
@Get(':id') | ||
async findOne(@Param('id', ParseIntPipe) id: number): Promise<EventDto> { | ||
return await this.eventService.getOne(id); | ||
|
@@ -43,6 +68,13 @@ export class EventController { | |
return await this.eventService.getAll(); | ||
} | ||
|
||
@Delete('delete-flytalk-application') | ||
async deleteFlyTalkApplication( | ||
@Body() { userId, eventId }: UserToEventDto, | ||
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. |
||
): Promise<UserToEventDto> { | ||
return await this.eventService.deleteFlyTalkApplication(userId, eventId); | ||
} | ||
|
||
@UseGuards(AdminGuard) | ||
@Delete(':id') | ||
async remove(@Param('id', ParseIntPipe) id: number): Promise<EventDto> { | ||
|
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { BlobService } from 'src/blob/blob.service'; | ||
import { PrismaService } from 'src/prisma.service'; | ||
|
||
import { EventController } from './event.controller'; | ||
import { EventService } from './event.service'; | ||
|
||
@Module({ | ||
controllers: [EventController], | ||
providers: [EventService, PrismaService], | ||
providers: [EventService, PrismaService, BlobService], | ||
}) | ||
export class EventModule {} |
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,32 @@ | ||
import { QueryClient, useMutation } from 'react-query'; | ||
import axios from '../base'; | ||
import { QUERY_KEYS } from '@/constants/queryKeys'; | ||
import toast from 'react-hot-toast'; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
const deleteFlyTalkApplication = async (data: { | ||
userId: number; | ||
eventId: number; | ||
}): Promise<{ userId: number; eventId: number }> => { | ||
return axios.delete('/event/delete-flytalk-application', { | ||
data: data , | ||
}); | ||
}; | ||
|
||
export const useDeleteFlyTalkApplication = () => { | ||
return useMutation(deleteFlyTalkApplication, { | ||
onSuccess: () => { | ||
queryClient.invalidateQueries([QUERY_KEYS.applyFlyTalk]); | ||
toast.success('Successfully deleted the application.'); | ||
}, | ||
onError: (error: import('axios').AxiosError<{ message?: string }>) => { | ||
console.error('Error deleting FlyTalk application:', error); | ||
const errorMessage = | ||
error?.response?.data?.message || | ||
error?.message || | ||
'An unexpected error occurred.'; | ||
toast.error(errorMessage); | ||
}, | ||
}); | ||
}; |
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 axios from '../base'; | ||
import { useQuery } from 'react-query'; | ||
import { QUERY_KEYS } from '@/constants/queryKeys'; | ||
import { EventWithCompanyDto } from '@ddays-app/types'; | ||
|
||
const getAllFlyTalkGroups = async (): Promise<EventWithCompanyDto[]> => { | ||
return axios.get('/event/with-company'); | ||
}; | ||
|
||
export const useGetAllFlyTalkGroups = () => { | ||
return useQuery<EventWithCompanyDto[]>( | ||
[QUERY_KEYS.events], | ||
getAllFlyTalkGroups, | ||
); | ||
}; |
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,28 @@ | ||
import { QUERY_KEYS } from "@/constants/queryKeys"; | ||
import { UserToEventDto } from "@ddays-app/types"; | ||
import axios from "../base"; | ||
import toast from "react-hot-toast"; | ||
import { useMutation, QueryClient } from "react-query"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
|
||
const postApplyToFlyTalks = async (data: UserToEventDto): Promise<UserToEventDto> => { | ||
return axios.post<UserToEventDto, UserToEventDto>('/event/apply-to-flytalk', data); | ||
} | ||
|
||
export const usePostApplyToFlyTalks = () => { | ||
return useMutation( | ||
postApplyToFlyTalks, { | ||
onSuccess: () => { | ||
queryClient.invalidateQueries([QUERY_KEYS.applyFlyTalk]); | ||
}, | ||
onError: (error: import("axios").AxiosError<{ message?: string }>) => { | ||
console.error("Error applying to FlyTalk:", error); | ||
const errorMessage = error?.response?.data?.message || error?.message || "An unexpected error occurred."; | ||
toast.error(errorMessage); | ||
}, | ||
} | ||
|
||
); | ||
}; |
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,23 @@ | ||
import { useMutation } from 'react-query'; | ||
import axios from '../base'; | ||
import toast from 'react-hot-toast'; | ||
|
||
const uploadCV = async (file: File): Promise<string> => { | ||
const formData = new FormData(); | ||
formData.append('file', file); | ||
|
||
return await axios.post('event/upload-cv', formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
responseType: 'text', | ||
}); | ||
}; | ||
|
||
export const useUploadCV = () => { | ||
return useMutation((file: File) => uploadCV(file), { | ||
onError: () => { | ||
toast.error('Greška prilikom slanja CV-a'); | ||
}, | ||
}); | ||
}; |
File renamed without changes.
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.
jel ovaj "And" osta ili je samo malo cudno ime?