-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from dump-hr/interview-notes
Implemented interview notes
- Loading branch information
Showing
17 changed files
with
247 additions
and
59 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
apps/api/prisma/migrations/20231017225019_move_interview_notes/migration.sql
This file contains 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,11 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `notes` on the `InterviewSlot` table. All the data in the column will be lost. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "Intern" ADD COLUMN "notes" TEXT NOT NULL DEFAULT ''; | ||
|
||
-- AlterTable | ||
ALTER TABLE "InterviewSlot" DROP COLUMN "notes"; |
This file contains 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 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 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 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 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 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,26 @@ | ||
import { CreateNoteRequest } from '@internship-app/types'; | ||
import toast from 'react-hot-toast'; | ||
import { useMutation, useQueryClient } from 'react-query'; | ||
|
||
import { api } from '.'; | ||
|
||
const createNote = async (req: CreateNoteRequest) => { | ||
return await api.post<CreateNoteRequest, never>( | ||
`/intern/note/${req.internId}`, | ||
req, | ||
); | ||
}; | ||
|
||
export const useCreateNote = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation(createNote, { | ||
onSuccess: (_data, variables) => { | ||
toast.success('Nota uspješno dodana!'); | ||
queryClient.invalidateQueries(['intern', variables.internId]); | ||
}, | ||
onError: (error: string) => { | ||
toast.error(`Greška pri izvođenju akcije: ${error}`); | ||
}, | ||
}); | ||
}; |
This file contains 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 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 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 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,57 @@ | ||
import { Intern } from '@internship-app/types'; | ||
import { Button, TextField } from '@mui/material'; | ||
import { useState } from 'react'; | ||
|
||
import { useCreateNote } from '../../api/useCreateNote'; | ||
import styles from './index.module.css'; | ||
|
||
type InternNotesProps = { | ||
intern: Intern; | ||
}; | ||
|
||
const InternNotes: React.FC<InternNotesProps> = ({ intern }) => { | ||
const [newNote, setNewNote] = useState(''); | ||
const createNote = useCreateNote(); | ||
|
||
const handleCreateNote = () => { | ||
createNote.mutate( | ||
{ | ||
internId: intern.id, | ||
note: newNote, | ||
}, | ||
{ | ||
onSuccess: () => setNewNote(''), | ||
}, | ||
); | ||
}; | ||
|
||
return ( | ||
<div className={styles.notesWrapper}> | ||
{intern.notes && ( | ||
<div className={styles.notes}> | ||
<b>Notes: </b>{' '} | ||
{intern.notes.split('\n').map((i) => ( | ||
<p>{i}</p> | ||
))} | ||
</div> | ||
)} | ||
<div className={styles.noteInput}> | ||
<TextField | ||
value={newNote} | ||
size="small" | ||
onChange={(e) => setNewNote(e.target.value)} | ||
label="Add note" | ||
/> | ||
<Button | ||
variant="contained" | ||
onClick={handleCreateNote} | ||
disabled={!newNote} | ||
> | ||
Dodaj | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InternNotes; |
Oops, something went wrong.