Skip to content

Commit

Permalink
fix: CE-812 - Add missing complaint updates (#484)
Browse files Browse the repository at this point in the history
Co-authored-by: Mike Sears <[email protected]>
Co-authored-by: afwilcox <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2024
1 parent 0f8df14 commit 7a94abd
Show file tree
Hide file tree
Showing 21 changed files with 517 additions and 133 deletions.
15 changes: 15 additions & 0 deletions backend/db/migrations/R__reset-complaint-templates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--
-- Reset the CDOGS template hashes every time the database scripts run
-- this is to make sure that the most up to date template is used
--
UPDATE "configuration"
SET
configuration_value = ''
WHERE
configuration_code = 'HWCTMPLATE';

UPDATE "configuration"
SET
configuration_value = ''
WHERE
configuration_code = 'ERSTMPLATE';
188 changes: 188 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"passport": "^0.6.0",
"passport-jwt": "^4.0.1",
"pg": "^8.7.3",
"react-phone-number-input": "^3.4.3",
"reflect-metadata": "^0.1.13",
"rimraf": "^4.0.0",
"rxjs": "^7.8.0",
Expand Down
27 changes: 27 additions & 0 deletions backend/src/common/methods.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { format } from "date-fns";
import { formatPhoneNumber } from "react-phone-number-input/input";

export const formatDate = (input: string | undefined): string => {
if (!input) {
Expand Down Expand Up @@ -34,3 +35,29 @@ export const formatDateTime = (input: string | undefined): string => {

return format(Date.parse(input), "yyyy-MM-dd HH:mm:ss");
};

//--
//-- attempt to format a phone number using the 10 digit NA format
//-- if the number can't be formatted return the value provided
//--
export const formatPhonenumber = (input: string): string => {
//-- check the incoming phone number to see if its been formatted
//-- correctly. Expecting input to be formatted as: +12505551234
//-- if this is correct format the number and return it
if (input.match(/\+1\d{7,10}/g)) {
return formatPhoneNumber(input);
}

//-- if the number isn't in the correct format try and fix the formatting
//-- by sanitizing the number and adding the +1 prefix
const sanitized = input.replace(/\D/g, "");
if (sanitized.length <= 10) {
const padded = `+1${sanitized.padStart(10, "0")}`;

return formatPhoneNumber(padded);
}

//-- we can't format the input into the format needed
//-- return the phone number as its stored
return input;
};
Loading

0 comments on commit 7a94abd

Please sign in to comment.