Skip to content
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

[Feature] Implement applicant deletion #310

Merged
merged 7 commits into from
Oct 2, 2023
Merged

Conversation

sherryhli
Copy link
Member

@sherryhli sherryhli commented Aug 28, 2023

Notion ticket link

Implement applicant deletion

Implementation description

Applicant deletion feature (note: applicant is called "Permit Holder" in user-facing text)

  • Created deleteApplicant GraphQL mutation
  • Created confirmation modal in frontend, triggered from menus in permit holder table and permit hold info page

Notes

Largely follows conventions used for setApplicantAsInactive / setApplicantAsActive and deleteEmployee.

Test Plan

Delete from table
Before deletion:

rcd=# select * from applicants where id = 4;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender |   phone    |          email          | receive_email_updates | address_line_1 | address_line_2 |  city  | province | country | postal_code | status | inactive_reason | accepted_tos 
| notes | guardian_id | medical_information_id |         created_at         |         updated_at
----+------------+-------------+-----------+---------------+--------+--------------+------------+-------------------------+-----------------------+----------------+----------------+--------+----------+---------+-------------+--------+-----------------+--------------+-------+-------------+------------------------+----------------------------+----------------------------
  4 | Applicant  |             | Four      | 1930-03-29    | FEMALE |              | 0987654321 | applicantfour@email.com | f                     | 421 Surrey St. |                | Surrey | BC       | Canada  | A1B2C3      | ACTIVE |                 |
|       |           3 |                      4 | 2023-09-01 07:09:44.941+00 | 2023-09-01 07:09:44.941+00
(1 row)

rcd=# select * from applications where applicant_id = 4;
 id | first_name | middle_name | last_name |   phone    |          email          | receive_email_updates | address_line_1 | address_line_2 |  city  | province | country | postal_code | permit_type | payment_method | processing_fee | donation_amount | paid_through_shopify | shopify_payment_status | shopify_confirmation_number | shopify_order_number | shipping_address_same_as_home_address | shipping_full_name | shipping_address_line_1 | shipping_address_line_2 | shipping_city | shipping_province | shipping_country | shipping_postal_code | billing_address_same_as_home_address | billing_full_name | billing_address_line_1 | billing_address_line_2 | billing_city | billing_province | billing_country | billing_postal_code |  type   | notes | applicant_id | application_processing_id |         cr  5 | Applicant  |             | Four      | 0987654321 | applicantfour@gmail.com | f                     | 421 Surrey St. | 264C           | Surrey | BC       | Canada  | A1B2C3      | PERMANENT   | SHOPIFY        |         $31.00 |          $20.00 | t
       | RECEIVED               | 4671298961430               | 1085                 | t                                     |                    |                         |                         |               |                   |                  |
          | t                                    |                   |                        |                        |              |                  |                 |                     | RENEWAL |       |            4 |                         5 | 2023-09-01 07:09:45.254+00 | 2023-09-01 07:09:45.254+00
(1 row)

rcd=# select * from permits where applicant_id = 4;
 rcd_permit_id |   type    | expiry_date | active | application_id | applicant_id |        created_at         |        updated_at
---------------+-----------+-------------+--------+----------------+--------------+---------------------------+---------------------------
             3 | PERMANENT | 2023-09-30  | t      |              5 |            4 | 2023-09-01 07:09:45.38+00 | 2023-09-01 07:09:45.38+00
(1 row)

rcd=# select * from guardians;
 id | first_name | middle_name | last_name |   phone    |  address_line_1  | address_line_2 |   city   | province | country | postal_code | relationship | poa_form_s3_object_key | notes |         created_at         |         updated_at
----+------------+-------------+-----------+------------+------------------+----------------+----------+----------+---------+-------------+--------------+------------------------+-------+----------------------------+----------------------------
  1 | Guardian   |             | One       | 1234567890 | 123 Richmond St. |                | Richmond | BC       | Canada  | X0X0X0      | Father       |                        |       | 2023-09-01 07:09:44.794+00 | 2023-09-01 07:09:44.794+00
  2 | Guardian   | Middle      | Two       | 0987654321 | 321 Surrey St.   |                | Surrey   | BC       | Canada  | A1B2C3      | Mother       |                        |       | 2023-09-01 07:09:44.875+00 | 2023-09-01 07:09:44.875+00
  3 | Guardian   | Middle      | Four      | 0987654322 | 321 Surrey St.   |                | Surrey   | BC       | Canada  | A1B2C3      | Brother      |                        |       | 2023-09-01 07:09:44.942+00 | 2023-09-01 07:09:44.942+00
(3 rows)

rcd=# select * from medical_information;
 id |   disability   | disability_certification_date |    patient_condition    | mobility_aids  | other_patient_condition | notes | physician_msp_number |         created_at         |         updated_at
----+----------------+-------------------------------+-------------------------+----------------+-------------------------+-------+----------------------+----------------------------+----------------------------
  1 | Fractured knee | 2021-01-01                    | {AFFECTS_MOBILITY}      | {}             |                         |       | 12345                | 2023-09-01 07:09:44.795+00 | 2023-09-01 07:09:44.795+00
  2 | Sprained ankle | 2021-02-02                    | {MOBILITY_AID_REQUIRED} | {WALKER}       |                         |       | 12346                | 2023-09-01 07:09:44.876+00 | 2023-09-01 07:09:44.876+00
  3 | Sprained ankle | 2021-03-03                    | {CANNOT_WALK_100M}      | {SCOOTER,CANE} |                         |       | 12346                | 2023-09-01 07:09:44.912+00 | 2023-09-01 07:09:44.912+00
  4 | Broken ankle   | 2021-04-04                    | {MOBILITY_AID_REQUIRED} | {WALKER}       |                         |       | 12344                | 2023-09-01 07:09:44.942+00 | 2023-09-01 07:09:44.942+00
(4 rows)

delete-applicant-from-table

After deletion:

rcd=# select * from applicants where id = 4;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender | phone | email | receive_email_updates | address_line_1 | address_line_2 | city | province | country | postal_code | status | inactive_reason | accepted_tos | notes | guardian_id | medical_information_id | created_at | updated_at
----+------------+-------------+-----------+---------------+--------+--------------+-------+-------+-----------------------+----------------+----------------+------+----------+---------+-------------+--------+-----------------+--------------+-------+-------------+------------------------+------------+------------
(0 rows)

rcd=# select * from applications where applicant_id = 4;
 id | first_name | middle_name | last_name | phone | email | receive_email_updates | address_line_1 | address_line_2 | city | province | country | postal_code | permit_type | payment_method | processing_fee | donation_amount | paid_through_shopify | shopify_payment_status | shopify_confirmation_number | shopify_order_number | shipping_address_same_as_home_address | shipping_full_name | shipping_address_line_1 | shipping_address_line_2 | shipping_city | shipping_province | shipping_country | shipping_postal_code | billing_address_same_as_home_address | billing_full_name | billing_address_line_1 | billing_address_line_2 | billing_city | billing_province | billing_country | billing_postal_code | type | notes | applicant_id | application_processing_id | created_at | updated_at
----+------------+-------------+-----------+-------+-------+-----------------------+----------------+----------------+------+----------+---------+-------------+-------------+----------------+----------------+-----------------+----------------------+------------------------+-----------------------------+----------------------+---------------------------------------+--------------------+-------------------------+-------------------------+---------------+-------------------+------------------+----------------------+--------------------------------------+-------------------+------------------------+------------------------+--------------+------------------+-----------------+---------------------+------+-------+--------------+---------------------------+------------+------------
(0 rows)

rcd=# select * from permits where applicant_id = 4;
 rcd_permit_id | type | expiry_date | active | application_id | applicant_id | created_at | updated_at 
---------------+------+-------------+--------+----------------+--------------+------------+------------
(0 rows)

rcd=# select * from guardians;
 id | first_name | middle_name | last_name |   phone    |  address_line_1  | address_line_2 |   city   | province | country | postal_code | relationship | poa_form_s3_object_key | notes |         created_at         |         updated_at
----+------------+-------------+-----------+------------+------------------+----------------+----------+----------+---------+-------------+--------------+------------------------+-------+----------------------------+----------------------------
  1 | Guardian   |             | One       | 1234567890 | 123 Richmond St. |                | Richmond | BC       | Canada  | X0X0X0      | Father       |                        |       | 2023-09-01 07:09:44.794+00 | 2023-09-01 07:09:44.794+00 
  2 | Guardian   | Middle      | Two       | 0987654321 | 321 Surrey St.   |                | Surrey   | BC       | Canada  | A1B2C3      | Mother       |                        |       | 2023-09-01 07:09:44.875+00 | 2023-09-01 07:09:44.875+00 
(2 rows)

rcd=# select * from medical_information;
 id |   disability   | disability_certification_date |    patient_condition    | mobility_aids  | other_patient_condition | notes | physician_msp_number |         created_at         |         updated_at
----+----------------+-------------------------------+-------------------------+----------------+-------------------------+-------+----------------------+----------------------------+----------------------------
  1 | Fractured knee | 2021-01-01                    | {AFFECTS_MOBILITY}      | {}             |                         |       | 12345                | 2023-09-01 07:09:44.795+00 | 2023-09-01 07:09:44.795+00 
  2 | Sprained ankle | 2021-02-02                    | {MOBILITY_AID_REQUIRED} | {WALKER}       |                         |       | 12346                | 2023-09-01 07:09:44.876+00 | 2023-09-01 07:09:44.876+00 
  3 | Sprained ankle | 2021-03-03                    | {CANNOT_WALK_100M}      | {SCOOTER,CANE} |                         |       | 12346                | 2023-09-01 07:09:44.912+00 | 2023-09-01 07:09:44.912+00 
(3 rows)

Delete from permit holder page
Before deletion:

rcd=# select * from applicants where id = 3;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender |   phone    |          email           | receive_email_updates | address_line_1 | address_line_2 |   city    | province | country | postal_code |  status  | inactive_reason | accepted_tos | notes | guardian_id | medical_information_id |         created_at         |         updated_at
----+------------+-------------+-----------+---------------+--------+--------------+------------+--------------------------+-----------------------+----------------+----------------+-----------+----------+---------+-------------+----------+-----------------+--------------+-------+-------------+------------------------+----------------------------+----------------------------
  3 | Applicant  |             | Three     | 1970-01-01    | MALE   |              | 4567891234 | applicantthree@email.com | t                     | 456 BC Way     |                | Vancouver | BC       | Canada  | B1C2D3      | INACTIVE |                 |        
      |       |             |                      3 | 2023-09-01 07:09:44.912+00 | 2023-09-01 07:09:44.912+00
(1 row)

rcd=# select * from applications where applicant_id = 3;
 id | first_name | middle_name | last_name |   phone    |          email           | receive_email_updates |  address_line_1   | address_line_2 |   city    | province | country | postal_code | permit_type | payment_method | processing_fee | donation_amount | paid_through_shopify | shopify_payment_status | shopify_confirmation_number | shopify_order_number | shipping_address_same_as_home_address | shipping_full_name | shipping_address_line_1 | shipping_address_line_2 | shipping_city | shipping_province | shipping_country | shipping_postal_code | billing_address_same_as_home_address | billing_full_name | billing_address_line_1 | billing_address_line_2 | billing_city | billing_province | billing_country | billing_postal_code |    type     | notes | applicant_id | application_processing_id |         created_at         |         updated_at
----+------------+-------------+-----------+------------+--------------------------+-----------------------+-------------------+----------------+-----------+----------+---------+-------------+-------------+----------------+----------------+-----------------+----------------------+------------------------+-----------------------------+----------------------+---------------------------------------+--------------------+-------------------------+-------------------------+---------------+-------------------+------------------+----------------------+--------------------------------------+-------------------+------------------------+------------------------+--------------+------------------+-----------------+---------------------+-------------+-------+--------------+---------------------------+----------------------------+----------------------------
  3 | Applicant  |             | Three     | 0987654321 | applicantthree@gmail.com | f                     | 789 Vancouver Rd. |                | Vancouver | BC       | Canada  | B1C2D3      | PERMANENT   | CHEQUE         |         $31.00 |         $100.00 | f      
              |                        |                             |                      | t                                     |                    |                         |                         |               |                   |                  |     
                 | t                                    |                   |                        |                        |              |                  |                 |                     | REPLACEMENT |       |            3 |                         3 | 2023-09-01 07:09:45.092+00 | 2023-09-01 07:09:45.092+00
(1 row)

rcd=# select * from permits where applicant_id = 3;
 rcd_permit_id |   type    | expiry_date | active | application_id | applicant_id |         created_at         |         updated_at
---------------+-----------+-------------+--------+----------------+--------------+----------------------------+----------------------------
             2 | PERMANENT | 2025-01-01  | t      |              3 |            3 | 2023-09-01 07:09:45.348+00 | 2023-09-01 07:09:45.348+00 
(1 row)

rcd=# select * from guardians;
 id | first_name | middle_name | last_name |   phone    |  address_line_1  | address_line_2 |   city   | province | country | postal_code | relationship | poa_form_s3_object_key | notes |         created_at         |         updated_at
----+------------+-------------+-----------+------------+------------------+----------------+----------+----------+---------+-------------+--------------+------------------------+-------+----------------------------+----------------------------
  1 | Guardian   |             | One       | 1234567890 | 123 Richmond St. |                | Richmond | BC       | Canada  | X0X0X0      | Father       |                        |       | 2023-09-01 07:09:44.794+00 | 2023-09-01 07:09:44.794+00 
  2 | Guardian   | Middle      | Two       | 0987654321 | 321 Surrey St.   |                | Surrey   | BC       | Canada  | A1B2C3      | Mother       |                        |       | 2023-09-01 07:09:44.875+00 | 2023-09-01 07:09:44.875+00 
(2 rows)

rcd=# select * from medical_information;
 id |   disability   | disability_certification_date |    patient_condition    | mobility_aids  | other_patient_condition | notes | physician_msp_number |         created_at         |         updated_at
----+----------------+-------------------------------+-------------------------+----------------+-------------------------+-------+----------------------+----------------------------+----------------------------
  1 | Fractured knee | 2021-01-01                    | {AFFECTS_MOBILITY}      | {}             |                         |       | 12345                | 2023-09-01 07:09:44.795+00 | 2023-09-01 07:09:44.795+00 
  2 | Sprained ankle | 2021-02-02                    | {MOBILITY_AID_REQUIRED} | {WALKER}       |                         |       | 12346                | 2023-09-01 07:09:44.876+00 | 2023-09-01 07:09:44.876+00 
  3 | Sprained ankle | 2021-03-03                    | {CANNOT_WALK_100M}      | {SCOOTER,CANE} |                         |       | 12346                | 2023-09-01 07:09:44.912+00 | 2023-09-01 07:09:44.912+00 
(3 rows)

delete-applicant

After deletion:

rcd=# select * from applicants where id = 3;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender | phone | email | receive_email_updates | address_line_1 | address_line_2 | city | province | country | postal_code | status | inactive_reason | accepted_tos | notes | guardian_id | medical_information_id | created_at | updated_at
----+------------+-------------+-----------+---------------+--------+--------------+-------+-------+-----------------------+----------------+----------------+------+----------+---------+-------------+--------+-----------------+--------------+-------+-------------+------------------------+------------+------------
(0 rows)

rcd=# select * from applications where applicant_id = 3;
 id | first_name | middle_name | last_name | phone | email | receive_email_updates | address_line_1 | address_line_2 | city | province | country | postal_code | permit_type | payment_method | processing_fee | donation_amount | paid_through_shopify | shopify_payment_status | shopify_confirmation_number | shopify_order_number | shipping_address_same_as_home_address | shipping_full_name | shipping_address_line_1 | shipping_address_line_2 | shipping_city | shipping_province | shipping_country | shipping_postal_code | billing_address_same_as_home_address | billing_full_name | billing_address_line_1 | billing_address_line_2 | billing_city | billing_province | billing_country | billing_postal_code | type | notes | applicant_id | application_processing_id | created_at | updated_at
----+------------+-------------+-----------+-------+-------+-----------------------+----------------+----------------+------+----------+---------+-------------+-------------+----------------+----------------+-----------------+----------------------+------------------------+-----------------------------+----------------------+---------------------------------------+--------------------+-------------------------+-------------------------+---------------+-------------------+------------------+----------------------+--------------------------------------+-------------------+------------------------+------------------------+--------------+------------------+-----------------+---------------------+------+-------+--------------+---------------------------+------------+------------
(0 rows)

rcd=# select * from permits where applicant_id = 3;
 rcd_permit_id | type | expiry_date | active | application_id | applicant_id | created_at | updated_at 
---------------+------+-------------+--------+----------------+--------------+------------+------------
(0 rows)

rcd=# select * from guardians;
 id | first_name | middle_name | last_name |   phone    |  address_line_1  | address_line_2 |   city   | province | country | postal_code | relationship | poa_form_s3_object_key | notes |         created_at         |         updated_at
----+------------+-------------+-----------+------------+------------------+----------------+----------+----------+---------+-------------+--------------+------------------------+-------+----------------------------+----------------------------
  1 | Guardian   |             | One       | 1234567890 | 123 Richmond St. |                | Richmond | BC       | Canada  | X0X0X0      | Father       |                        |       | 2023-09-01 07:09:44.794+00 | 2023-09-01 07:09:44.794+00 
  2 | Guardian   | Middle      | Two       | 0987654321 | 321 Surrey St.   |                | Surrey   | BC       | Canada  | A1B2C3      | Mother       |                        |       | 2023-09-01 07:09:44.875+00 | 2023-09-01 07:09:44.875+00 
(2 rows)

rcd=# select * from medical_information;
 id |   disability   | disability_certification_date |    patient_condition    | mobility_aids | other_patient_condition | notes | physician_msp_number |         created_at         |         updated_at
----+----------------+-------------------------------+-------------------------+---------------+-------------------------+-------+----------------------+----------------------------+----------------------------
  1 | Fractured knee | 2021-01-01                    | {AFFECTS_MOBILITY}      | {}            |                         |       | 12345                | 2023-09-01 07:09:44.795+00 | 2023-09-01 07:09:44.795+00 
  2 | Sprained ankle | 2021-02-02                    | {MOBILITY_AID_REQUIRED} | {WALKER}      |                         |       | 12346                | 2023-09-01 07:09:44.876+00 | 2023-09-01 07:09:44.876+00 
(2 rows)

Checklist

  • My PR name is descriptive, is in imperative tense and starts with one of the following: [Feature],[Improvement] or [Fix],
  • I have run the appropriate linter(s)
  • I have requested a review from the RCD team on GitHub, or specific people who are associated with this ticket

@sherryhli sherryhli changed the title Implement applicant deletion [Feature] Implement applicant deletion Aug 31, 2023
@sherryhli sherryhli marked this pull request as ready for review September 1, 2023 07:38
lib/applicants/resolvers.ts Show resolved Hide resolved
Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think we should schedule a meeting to discuss schema updates in the near future.

isOpen={isDeleteApplicantModalOpen}
applicantId={id}
refetch={() => {
/* Do not refetch, redirect to permit holders page */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we redirect it seems to repopulate the correct list without it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without redirecting we'd stay on the info page of the permit holder who'd just been deleted. The redirect returns us to the page with the table of all permit holders.

@ChinemeremChigbo
Copy link
Member

ChinemeremChigbo commented Sep 27, 2023

Tested pretty thoroughly, applicant deletion, changing branches, generating reports etc. and everything seems to work as intended. The only tricky bit is reseeding after having deleted all applications. Upon which I get the following error:
image

This happens for me after I delete any amount of applicants and then try to reseed the database with npx prisma db seed --preview-feature. To escape this state I run npx prisma db push --force-reset before re-running npx prisma db seed --preview-feature. Here is a video, (split into 2 parts due to length) showing the issue. Please ignore any background noise.

sherry_pr_1.mp4
sherry_pr_2.mp4

Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@sherryhli
Copy link
Member Author

Thanks @ChinemeremChigbo for your help with testing, appreciate the thoroughness! 🙌

I verified the hypothesis I shared on Discord and it seems to be correct. To summarize, when running the seed script a second time after deleting all applicants, new applicants are created. These new applicants have IDs different from those of the original applicants (auto-incremented by the DB).

Applicants after running the seed script again (IDs were initially 1-4):

rcd=# select * from applicants;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender |   phone    |          email           | receive_email_updates |  address_line_1  | address_line_2 |   city    | province | country | postal_code |  status  | inactive_reason | accepted_tos | notes | guardian_id | medical_information_id |         created_at         |         updated_at
----+------------+-------------+-----------+---------------+--------+--------------+------------+--------------------------+-----------------------+------------------+----------------+-----------+----------+---------+-------------+----------+-----------------+--------------+-------+-------------+------------------------+----------------------------+----------------------------
  5 | Applicant  | Middle-One  | One       | 2001-01-01    | MALE   |              | 1234567890 | applicantone@email.com   | t                     | 123 Richmond St. |                | Richmond  | BC       | Canada  | X0X0X0      | ACTIVE   |                 |              |       |           4 |                      5 | 2023-09-30 05:22:20.116+00 | 2023-09-30 05:22:20.116+00
  6 | Applicant  |             | Two       | 1930-03-29    | FEMALE |              | 0987654321 | applicanttwo@email.com   | f                     | 321 Surrey St.   |                | Surrey    | BC       | Canada  | A1B2C3      | ACTIVE   |                 |              |       |           5 |                      6 | 2023-09-30 05:22:20.201+00 | 2023-09-30 05:22:20.201+00
  7 | Applicant  |             | Three     | 1970-01-01    | MALE   |              | 4567891234 | applicantthree@email.com | t                     | 456 BC Way       |                | Vancouver | BC       | Canada  | B1C2D3      | INACTIVE |                 |              |       |             |                      7 | 2023-09-30 05:22:20.248+00 | 2023-09-30 05:22:20.248+00
  8 | Applicant  |             | Four      | 1930-03-29    | FEMALE |              | 0987654321 | applicantfour@email.com  | f                     | 421 Surrey St.   |                | Surrey    | BC       | Canada  | A1B2C3      | ACTIVE   |                 |              |       |           6 |                      8 | 2023-09-30 05:22:20.282+00 | 2023-09-30 05:22:20.282+00
(4 rows)

However, the seed script assumes that applicants have IDs 1-4, so when inserting applications when seeding the second time, we get an error as the previous applicants no longer exist

The "No 'Applicant' record(s) (needed to inline the relation on 'Application' record(s)) was found for a nested connect on one-to-many relation 'applicantsToapplications'." error is expected when trying to link an application to a non-existent applicant. The issue is in the seed script, not the deletion logic.

@ChinemeremChigbo
Copy link
Member

Thanks @ChinemeremChigbo for your help with testing, appreciate the thoroughness! 🙌

I verified the hypothesis I shared on Discord and it seems to be correct. To summarize, when running the seed script a second time after deleting all applicants, new applicants are created. These new applicants have IDs different from those of the original applicants (auto-incremented by the DB).

Applicants after running the seed script again (IDs were initially 1-4):

rcd=# select * from applicants;
 id | first_name | middle_name | last_name | date_of_birth | gender | other_gender |   phone    |          email           | receive_email_updates |  address_line_1  | address_line_2 |   city    | province | country | postal_code |  status  | inactive_reason | accepted_tos | notes | guardian_id | medical_information_id |         created_at         |         updated_at
----+------------+-------------+-----------+---------------+--------+--------------+------------+--------------------------+-----------------------+------------------+----------------+-----------+----------+---------+-------------+----------+-----------------+--------------+-------+-------------+------------------------+----------------------------+----------------------------
  5 | Applicant  | Middle-One  | One       | 2001-01-01    | MALE   |              | 1234567890 | applicantone@email.com   | t                     | 123 Richmond St. |                | Richmond  | BC       | Canada  | X0X0X0      | ACTIVE   |                 |              |       |           4 |                      5 | 2023-09-30 05:22:20.116+00 | 2023-09-30 05:22:20.116+00
  6 | Applicant  |             | Two       | 1930-03-29    | FEMALE |              | 0987654321 | applicanttwo@email.com   | f                     | 321 Surrey St.   |                | Surrey    | BC       | Canada  | A1B2C3      | ACTIVE   |                 |              |       |           5 |                      6 | 2023-09-30 05:22:20.201+00 | 2023-09-30 05:22:20.201+00
  7 | Applicant  |             | Three     | 1970-01-01    | MALE   |              | 4567891234 | applicantthree@email.com | t                     | 456 BC Way       |                | Vancouver | BC       | Canada  | B1C2D3      | INACTIVE |                 |              |       |             |                      7 | 2023-09-30 05:22:20.248+00 | 2023-09-30 05:22:20.248+00
  8 | Applicant  |             | Four      | 1930-03-29    | FEMALE |              | 0987654321 | applicantfour@email.com  | f                     | 421 Surrey St.   |                | Surrey    | BC       | Canada  | A1B2C3      | ACTIVE   |                 |              |       |           6 |                      8 | 2023-09-30 05:22:20.282+00 | 2023-09-30 05:22:20.282+00
(4 rows)

However, the seed script assumes that applicants have IDs 1-4, so when inserting applications when seeding the second time, we get an error as the previous applicants no longer exist

The "No 'Applicant' record(s) (needed to inline the relation on 'Application' record(s)) was found for a nested connect on one-to-many relation 'applicantsToapplications'." error is expected when trying to link an application to a non-existent applicant. The issue is in the seed script, not the deletion logic.

This makes sense. Thanks for the explanation!!! LGTM.

@sherryhli sherryhli merged commit 97b8590 into staging Oct 2, 2023
1 check passed
@sherryhli sherryhli deleted the sl/applicant-deletion branch October 2, 2023 05:21
leogjhuang pushed a commit that referenced this pull request Oct 4, 2023
* Create deleteApplicant resolver

* Improve error message in deleteApplicant resolver

* Implement delete applicant UI

* Remove TODO comment

* Change delete permit holder button text

* Add doc string for deleteApplicant resolver

* Cleanup newApplication, renewalApplication, and replacementApplication records when deleting applicant
@leogjhuang leogjhuang mentioned this pull request Oct 4, 2023
3 tasks
leogjhuang added a commit that referenced this pull request Oct 4, 2023
* [Fix] Save poaFormS3ObjectKey when updating guardian information in permit holders page (#319)
* [Fix] Postal Code Space Issue (#316)
* Set other gender field on permit holders page (#318)
* Add .nvmrc file (#317)
* [Feature] Implement applicant deletion (#310)
* [Feature] Implement application deletion (#315)
* Display other gender field on permit holders page (#314)
* Move wallet card task in application processing (#313)
* [Feature] Tax receipt (#311)
* [Fix] Fix expiry date for in-progress replacement applications (#274)
* [Fix] Fix APP history permit type badge (#273)
* [Improvement] Adjust spacing of address in invoice (#272)
* [Fix] Show validation error messages on form mount (#271)
leogjhuang pushed a commit that referenced this pull request Oct 10, 2023
* Create deleteApplicant resolver

* Improve error message in deleteApplicant resolver

* Implement delete applicant UI

* Remove TODO comment

* Change delete permit holder button text

* Add doc string for deleteApplicant resolver

* Cleanup newApplication, renewalApplication, and replacementApplication records when deleting applicant
@leogjhuang leogjhuang mentioned this pull request Oct 10, 2023
3 tasks
leogjhuang pushed a commit that referenced this pull request Oct 10, 2023
* Create deleteApplicant resolver

* Improve error message in deleteApplicant resolver

* Implement delete applicant UI

* Remove TODO comment

* Change delete permit holder button text

* Add doc string for deleteApplicant resolver

* Cleanup newApplication, renewalApplication, and replacementApplication records when deleting applicant
@leogjhuang leogjhuang mentioned this pull request Oct 10, 2023
3 tasks
leogjhuang added a commit that referenced this pull request Oct 10, 2023
* [Feature] Create setEmployeeAsActive GraphQL endpoint (#322)
* [Fix] Save poaFormS3ObjectKey when updating guardian information in permit holders page (#319)
* [Fix] Postal Code Space Issue (#316)
* Set other gender field on permit holders page (#318)
* Add .nvmrc file (#317)
* [Feature] Implement applicant deletion (#310)
* [Feature] Implement application deletion (#315)
* Display other gender field on permit holders page (#314)
* Move wallet card task in application processing (#313)
* [Feature] Tax receipt (#311)
* [Fix] Fix expiry date for in-progress replacement applications (#274)
* [Fix] Fix APP history permit type badge (#273)
* [Improvement] Adjust spacing of address in invoice (#272)
* [Fix] Show validation error messages on form mount (#271)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants