Skip to content

Commit a90665d

Browse files
committed
Extract getStringFormValue helper
1 parent 8f311ea commit a90665d

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

app/components/calls/recording-form.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getErrorForNotes,
1010
getErrorForTitle,
1111
} from '#app/utils/call-kent.ts'
12+
import { getStringFormValue } from '#app/utils/misc.ts'
1213
import { useRootData } from '#app/utils/use-root-data.ts'
1314

1415
export const recordingFormActionPath = '/resources/calls/save'
@@ -379,9 +380,3 @@ export function RecordingForm({
379380
</div>
380381
)
381382
}
382-
383-
function getStringFormValue(formData: FormData, key: string) {
384-
const value = formData.get(key)
385-
return typeof value === 'string' ? value : null
386-
}
387-

app/routes/resources/calls/save.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
getDomainUrl,
2121
getErrorMessage,
2222
getOptionalTeam,
23+
getStringFormValue,
2324
} from '#app/utils/misc.ts'
2425
import { prisma } from '#app/utils/prisma.server.ts'
2526
import { sendEmail } from '#app/utils/send-email.server.ts'
@@ -30,11 +31,6 @@ import { type Route } from './+types/save'
3031

3132
type ActionData = RecordingFormData
3233

33-
function getStringFormValue(formData: FormData, key: string) {
34-
const value = formData.get(key)
35-
return typeof value === 'string' ? value : null
36-
}
37-
3834
function getCheckboxFormValue(formData: FormData, key: string) {
3935
const value = formData.get(key)
4036
// HTML checkboxes submit the value only when checked (default "on").

app/utils/misc.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ export function getErrorMessage(
8888
return fallback
8989
}
9090

91+
export function getStringFormValue(formData: FormData, key: string) {
92+
const value = formData.get(key)
93+
return typeof value === 'string' ? value : null
94+
}
95+
9196
export function getErrorStack(
9297
error: unknown,
9398
fallback: string = 'Unknown Error',

0 commit comments

Comments
 (0)