33 if (!form.isValid()) return
34 const formValues = form.getTransformedValues()
35 const { orgLocationId, orgServiceId, isPrimary, published } = formValues
36 switch (role) { 37 case 'email': { 38 const { emailAddress: email, firstName, lastName } = formValues 39 if (!email) return 40 saveEmail.mutate({ 41 orgId: orgId ?? '', 42 data: { email, firstName, lastName, locationOnly: false, serviceOnly: false }, 43 }) 44 break 45 } 46 case 'phone': { 47 const { phoneNumber: number, phoneCountryId: countryId, phoneTypeId, customPhoneType } = formValues 48 if (!number || !countryId) return 49 50 savePhone.mutate({ orgId: orgId ?? '', data: { number, countryId, phoneTypeId } }) 51 52 break 53 } 54 } 55 }
56
57 return (
150 case 'tpop':
151 case 'eligibility': {
152 const type = tsKey.split('.').pop() as string
153 switch (type) {154 case 'elig-age': {155 const { data } = attribute156 const parsed = attributeSupplementSchema.numMinMaxOrRange.safeParse(data)157 if (!parsed.success) break158 const { min, max } = parsed.data159 const context = min && max ? 'range' : min ? 'min' : 'max'160 output.eligibility.age = (161 <ModalText key={id}>{t('service.elig-age', { ns: 'common', context, min, max })}</ModalText>162 )163 break164 }165 case 'other':166 case 'other-describe': {167 const { text } = attribute168 if (!text) break169 const { key, options } = getFreeText(text)170 output.clientsServed.targetPop.push(<ModalText key={id}>{t(key, options)}</ModalText>)171172 break173 }174 }175
176 break
177 }
49 const parsed = accessInstructions.getAll().safeParse(data)
50 if (parsed.success) {
51 const { access_type, access_value } = parsed.data
52 switch (access_type) { 53 case 'publicTransit': { 54 if (!text) break 55 const { key, options } = getFreeText(text) 56 output.publicTransit = <ModalText key={id}>{t(key, options)}</ModalText> 57 break 58 } 59 case 'email': { 60 if (access_value) 61 output.getHelp.emails.push({ 62 id, 63 title: null, 64 description: null, 65 email: access_value, 66 // legacyDesc: parsed.data.instructions, 67 // firstName: null, 68 // lastName: null, 69 primary: false, 70 locationOnly: false, 71 serviceOnly: false, 72 }) 73 break 74 } 75 case 'phone': { 76 const country = locations.find(({ location }) => Boolean(location.country))?.location?.country?.cca2 77 if (!country) break 78 if (access_value) 79 output.getHelp.phones.push({ 80 id, 81 number: access_value, 82 phoneType: null, 83 country, 84 primary: false, 85 locationOnly: false, 86 ext: null, 87 description: null, 88 }) 89 break 90 } 91 case 'link': 92 case 'file': { 93 if (access_value) 94 output.getHelp.websites.push({ 95 id, 96 description: null, 97 isPrimary: false, 98 // orgLocationId: null, 99 orgLocationOnly: false,100 url: access_value,101 })102 }103 }104 }
105 }
106
267 const filterListExclude: JSX.Element[] = []
268
269 for (const [i, filter] of Object.entries(form.values)) {
270 switch (filter.filterType) {271 case 'INCLUDE': {272 filterListInclude.push(273 <Checkbox274 // className={classes.itemChild}275 label={t(filter.tsKey, { ns: 'attribute' })}276 key={filter.id}277 {...form.getInputProps(`${i}.checked`, { type: 'checkbox' })}278 />279 )280 break281 }282 case 'EXCLUDE': {283 filterListExclude.push(284 <Checkbox285 className={classes.itemChild}286 label={t(filter.tsKey, { ns: 'attribute' })}287 key={filter.id}288 {...form.getInputProps(`${i}.checked`, { type: 'checkbox' })}289 />290 )291 break292 }293 }294 }
295
296 const selectedItems = (function () {
222 orgBadges: getTRPCMock({
223 path: ['fieldOpt', 'orgBadges'],
224 response: async (input) => {
225 switch (input.badgeType) {226 case 'organization-leadership': {227 const { default: data } = await import('./json/fieldOpt.orgBadges.organization-leadership.json')228 return data229 }230 case 'service-focus': {231 const { default: data } = await import('./json/fieldOpt.orgBadges.service-focus.json')232 return data233 }234 }235 },
236 }),
237 ccaMap: getTRPCMock({
Some code conventions require that all switch statements have a default case, even if the default case is empty. The idea is to always explicitly state what the default behavior should be so that it's clear that the developer didn't forget to handle the default fallback case.
switch (a) {
case 1:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
default:
/* code */
break;
}
switch (a) {
case 1:
/* code */
break;
// no default
}
switch (a) {
case 1:
/* code */
break;
// No Default
}