forked from Code-4-Community/scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 0
314 add internal admin notes field to application records #332
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
cheangie
wants to merge
3
commits into
main
Choose a base branch
from
314-add-internal-admin-notes-field-to-application-records
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
3 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
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
17 changes: 17 additions & 0 deletions
17
apps/backend/src/applications/dto/update-application-internal-notes.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,17 @@ | ||
| import { IsOptional, IsString } from 'class-validator'; | ||
|
|
||
| /** | ||
| * Defines the expected shape of data for updating an application's internal notes. | ||
| * | ||
| * DTO - data transfer object (defines and validates the structure of data sent over the network). | ||
| */ | ||
| export class UpdateApplicationInternalNotesDto { | ||
| /** | ||
| * Internal notes about the application, only visible to admins. | ||
| * | ||
| * Example: "Applicant is potentially a good fit." | ||
| */ | ||
| @IsString() | ||
| @IsOptional() | ||
| internalNotes?: string; | ||
| } |
19 changes: 19 additions & 0 deletions
19
apps/backend/src/migrations/1781306552405-AddInternalNotesToApplications.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,19 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
|
||
| export class AddInternalNotesToApplications1781306552405 | ||
| implements MigrationInterface | ||
| { | ||
| name = 'AddInternalNotesToApplications1781306552405'; | ||
|
|
||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE "application" ADD "internalNotes" character varying`, | ||
| ); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE "application" DROP COLUMN "internalNotes"`, | ||
|
Collaborator
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. Same comment as above but just specifically for the down one ^ |
||
| ); | ||
| } | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -4,10 +4,12 @@ import apiClient from '@api/apiClient'; | |
| import { | ||
| Badge, | ||
| Box, | ||
| Button, | ||
| Flex, | ||
| Heading, | ||
| Spinner, | ||
| Text, | ||
| Textarea, | ||
| VStack, | ||
| } from '@chakra-ui/react'; | ||
| import AvailabilityTable from '@components/AvailabilityTable'; | ||
|
|
@@ -189,6 +191,26 @@ const AdminViewApplication: React.FC = () => { | |
| setApplication(updatedApplication); | ||
| }; | ||
|
|
||
| const [internalNotes, setInternalNotes] = useState<string>( | ||
| application?.internalNotes ?? '', | ||
| ); | ||
| const [notesSaving, setNotesSaving] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| setInternalNotes(application?.internalNotes ?? ''); | ||
| }, [application]); | ||
|
|
||
| const handleInternalNotesUpdate = async () => { | ||
| if (!application) return; | ||
| setNotesSaving(true); | ||
| const updatedApplication = await apiClient.updateApplicationInternalNotes( | ||
| application.appId, | ||
| internalNotes, | ||
| ); | ||
| setApplication(updatedApplication); | ||
| setNotesSaving(false); | ||
| }; | ||
|
|
||
| if (loading) { | ||
| return ( | ||
| <Flex direction="row"> | ||
|
|
@@ -445,6 +467,30 @@ const AdminViewApplication: React.FC = () => { | |
| phone={application.emergencyContactPhone} | ||
| relationship={application.emergencyContactRelationship} | ||
| /> | ||
|
|
||
| <Box borderWidth="1px" borderRadius="lg" p={6} bg="white"> | ||
| <Heading as="h2" size="md" mb={1}> | ||
| Internal Notes | ||
| </Heading> | ||
| <Text fontSize="sm" color="orange.700" mb={3}> | ||
|
Collaborator
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. I do think this text being this color is good though. |
||
| Admin only — not visible to applicants. | ||
| </Text> | ||
| <Textarea | ||
| value={internalNotes} | ||
| onChange={(e) => setInternalNotes(e.target.value)} | ||
| placeholder="Add internal notes about this applicant..." | ||
| bg="white" | ||
| rows={4} | ||
| /> | ||
| <Button | ||
| mt={3} | ||
| colorScheme="orange" | ||
| loading={notesSaving} | ||
| onClick={handleInternalNotesUpdate} | ||
| > | ||
| Save Notes | ||
| </Button> | ||
| </Box> | ||
| </Box> | ||
| </Flex> | ||
| ); | ||
|
|
||
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.
Remove everything else from this migration but this query please - we only want to put in the migration what is relevant to the goal you are trying to achieve