-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first pass at pre-appointment questionnaire
- Loading branch information
1 parent
36cf3c6
commit d2e9eaa
Showing
13 changed files
with
1,680 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Format a yes/no/not answered response with optional additional details | ||
* @param {string|boolean} value - The response value to format | ||
* @param {Object} [options] - Formatting options | ||
* @param {string} [options.yesValue] - Additional details to show after "Yes -" for positive responses | ||
* @param {string} [options.noText="No"] - Text to show for negative responses | ||
* @param {string} [options.notAnsweredText="Not answered"] - Text to show when no response given | ||
* @param {string} [options.yesPrefix="Yes"] - Text to show for positive responses (before any yesValue) | ||
* @returns {string} Formatted response text | ||
* @example | ||
* formatAnswer("yes", { yesValue: "Details here" }) // Returns "Yes - Details here" | ||
* formatAnswer("no") // Returns "No" | ||
* formatAnswer(null) // Returns "Not answered" | ||
* formatAnswer("yes", { yesPrefix: "Currently" }) // Returns "Currently" | ||
*/ | ||
const formatAnswer = (value, options = {}) => { | ||
const { | ||
yesValue = null, | ||
noText = "No", | ||
notAnsweredText = "Not answered", | ||
yesPrefix = "Yes" | ||
} = options; | ||
|
||
// Handle null/undefined/empty string | ||
if (!value || value === "no" || value === "false") { | ||
return noText; | ||
} | ||
|
||
// For any truthy value (includes "yes", true, etc) | ||
return yesValue ? `${yesPrefix} - ${yesValue}` : yesPrefix; | ||
}; | ||
|
||
module.exports = { | ||
formatAnswer | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.