-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Adds Employee Profile Goals and Work Style form (#12433)
* Allow employeeProfile to be optional * Add messages * Add validator * Add GoalsWorkStyleSection * Add GoalsWorkStyleSection * Allow employeeProfile to be nullable * Add NotFoundError conditional * Remove hasError * Rename function * Add translations
- Loading branch information
Showing
6 changed files
with
470 additions
and
4 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,26 @@ | ||
import { defineMessages } from "react-intl"; | ||
|
||
const messages = defineMessages({ | ||
aboutYou: { | ||
defaultMessage: "About you", | ||
id: "tSvuK1", | ||
description: "Label for a employee profile about you field", | ||
}, | ||
careerGoals: { | ||
defaultMessage: "Your career goals", | ||
id: "NlcepR", | ||
description: "Label for a employee profile career goals field", | ||
}, | ||
learningGoals: { | ||
defaultMessage: "Your learning goals", | ||
id: "j5Fwi6", | ||
description: "Label for a employee profile learning goals field", | ||
}, | ||
workStyle: { | ||
defaultMessage: "How you work best", | ||
id: "9pYZOU", | ||
description: "Label for a employee profile work style field", | ||
}, | ||
}); | ||
|
||
export default messages; |
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
84 changes: 84 additions & 0 deletions
84
apps/web/src/pages/EmployeeProfile/components/GoalsWorkStyleSection/Display.tsx
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,84 @@ | ||
import { useIntl } from "react-intl"; | ||
|
||
import { commonMessages } from "@gc-digital-talent/i18n"; | ||
import { RichTextRenderer, htmlToRichTextJSON } from "@gc-digital-talent/forms"; | ||
import { EmployeeProfileGoalsWorkStyleFragment } from "@gc-digital-talent/graphql"; | ||
import { Well } from "@gc-digital-talent/ui"; | ||
|
||
import ToggleForm from "~/components/ToggleForm/ToggleForm"; | ||
import employeeProfileMessages from "~/messages/employeeProfileMessages"; | ||
import { hasAnyEmptyFields } from "~/validators/employeeProfile/goalsWorkStyle"; | ||
|
||
interface DisplayProps { | ||
employeeProfile: EmployeeProfileGoalsWorkStyleFragment; | ||
} | ||
|
||
const Display = ({ | ||
employeeProfile: { aboutYou, careerGoals, learningGoals, workStyle }, | ||
}: DisplayProps) => { | ||
const intl = useIntl(); | ||
const notProvided = intl.formatMessage(commonMessages.notProvided); | ||
|
||
return ( | ||
<div | ||
data-h2-display="base(flex)" | ||
data-h2-flex-direction="base(column)" | ||
data-h2-gap="base(x1)" | ||
> | ||
{hasAnyEmptyFields({ | ||
aboutYou, | ||
careerGoals, | ||
learningGoals, | ||
workStyle, | ||
}) && ( | ||
<Well> | ||
{intl.formatMessage({ | ||
defaultMessage: | ||
'There are currently unanswered optional questions in this section. Use the "Edit" button to review and answer any relevant fields.', | ||
id: "PEH7og", | ||
description: | ||
"Message for unanswered optional questions in this section", | ||
})} | ||
</Well> | ||
)} | ||
<ToggleForm.FieldDisplay | ||
label={intl.formatMessage(employeeProfileMessages.aboutYou)} | ||
> | ||
{aboutYou ? ( | ||
<RichTextRenderer node={htmlToRichTextJSON(aboutYou)} /> | ||
) : ( | ||
notProvided | ||
)} | ||
</ToggleForm.FieldDisplay> | ||
<ToggleForm.FieldDisplay | ||
label={intl.formatMessage(employeeProfileMessages.careerGoals)} | ||
> | ||
{careerGoals ? ( | ||
<RichTextRenderer node={htmlToRichTextJSON(careerGoals)} /> | ||
) : ( | ||
notProvided | ||
)} | ||
</ToggleForm.FieldDisplay> | ||
<ToggleForm.FieldDisplay | ||
label={intl.formatMessage(employeeProfileMessages.learningGoals)} | ||
> | ||
{learningGoals ? ( | ||
<RichTextRenderer node={htmlToRichTextJSON(learningGoals)} /> | ||
) : ( | ||
notProvided | ||
)} | ||
</ToggleForm.FieldDisplay> | ||
<ToggleForm.FieldDisplay | ||
label={intl.formatMessage(employeeProfileMessages.workStyle)} | ||
> | ||
{workStyle ? ( | ||
<RichTextRenderer node={htmlToRichTextJSON(workStyle)} /> | ||
) : ( | ||
notProvided | ||
)} | ||
</ToggleForm.FieldDisplay> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Display; |
Oops, something went wrong.