Skip to content

Commit

Permalink
Clean up region state mapping in backend
Browse files Browse the repository at this point in the history
  • Loading branch information
nickviola committed Mar 20, 2024
1 parent 8fe2660 commit c9ed7d3
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 61 deletions.
61 changes: 61 additions & 0 deletions backend/src/api/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,67 @@ import { SES } from 'aws-sdk';
import * as nodemailer from 'nodemailer';
import * as handlebars from 'handlebars';

export const REGION_STATE_MAP = {
Alabama: '4',
Alaska: '10',
'American Samoa': '9',
Arkansas: '6',
Arizona: '9',
California: '9',
Colorado: '8',
'Commonwealth Northern Mariana Islands': '9',
Connecticut: '1',
Delaware: '3',
'District of Columbia': '3',
'Federal States of Micronesia': '9',
Florida: '4',
Georgia: '4',
Guam: '9',
Hawaii: '9',
Idaho: '10',
Illinois: '5',
Indiana: '5',
Iowa: '7',
Kansas: '7',
Kentucky: '4',
Louisiana: '6',
Maine: '1',
Maryland: '3',
Massachusetts: '1',
Michigan: '5',
Minnesota: '5',
Mississippi: '4',
Missouri: '7',
Montana: '8',
Nebraska: '7',
Nevada: '9',
'New Hampshire': '1',
'New Jersey': '2',
'New Mexico': '6',
'New York': '2',
'North Carolina': '4',
'North Dakota': '8',
Ohio: '5',
Oklahoma: '6',
Oregon: '10',
Pennsylvania: '3',
'Puerto Rico': '2',
'Republic of Marshall Islands': '9',
'Rhode Island': '1',
'South Carolina': '4',
'South Dakota': '8',
Tennessee: '4',
Texas: '6',
Utah: '8',
Vermont: '1',
'Virgin Islands': '2',
Virginia: '3',
Washington: '10',
'West Virginia': '3',
Wisconsin: '5',
Wyoming: '8'
};

export const validateBody = async <T>(
obj: ClassType<T>,
body: string | null,
Expand Down
62 changes: 1 addition & 61 deletions backend/src/api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
wrapHandler,
NotFound,
Unauthorized,
REGION_STATE_MAP,
sendEmail,
sendUserRegistrationEmail,
sendRegistrationApprovedEmail,
Expand Down Expand Up @@ -146,67 +147,6 @@ class UpdateUser {
role: string;
}

const REGION_STATE_MAP = {
Connecticut: '1',
Maine: '1',
Massachusetts: '1',
'New Hampshire': '1',
'Rhode Island': '1',
Vermont: '1',
'New Jersey': '2',
'New York': '2',
'Puerto Rico': '2',
'Virgin Islands': '2',
Delaware: '3',
Maryland: '3',
Pennsylvania: '3',
Virginia: '3',
'District of Columbia': '3',
'West Virginia': '3',
Alabama: '4',
Florida: '4',
Georgia: '4',
Kentucky: '4',
Mississippi: '4',
'North Carolina': '4',
'South Carolina': '4',
Tennessee: '4',
Illinois: '5',
Indiana: '5',
Michigan: '5',
Minnesota: '5',
Ohio: '5',
Wisconsin: '5',
Arkansas: '6',
Louisiana: '6',
'New Mexico': '6',
Oklahoma: '6',
Texas: '6',
Iowa: '7',
Kansas: '7',
Missouri: '7',
Nebraska: '7',
Colorado: '8',
Montana: '8',
'North Dakota': '8',
'South Dakota': '8',
Utah: '8',
Wyoming: '8',
Arizona: '9',
California: '9',
Hawaii: '9',
Nevada: '9',
Guam: '9',
'American Samoa': '9',
'Commonwealth Northern Mariana Islands': '9',
'Republic of Marshall Islands': '9',
'Federal States of Micronesia': '9',
Alaska: '10',
Idaho: '10',
Oregon: '10',
Washington: '10'
};

/**
* @swagger
*
Expand Down

0 comments on commit c9ed7d3

Please sign in to comment.