Skip to content

Commit 262348f

Browse files
committed
Prefix protocol to lms url when missing, show success msg on success only.
1 parent bc1e25b commit 262348f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/moodle-lms-integration/src/webapp/ui/components/SendToMoodle.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ export const SendToMoodle: FC<SendToMoodleProps> = ({
5050
})
5151

5252
const handleOnSendToMoodleClick = () => {
53+
const site = form.values.site
54+
if (site?.trim() !== '' && site?.substring(0, 4).toLowerCase() !== 'http') {
55+
form.setFieldValue('site', `https://${site}`)
56+
}
5357
if (form.isValid) {
5458
form.submitForm()
5559
setIsAddingToMoodleLms(false)
5660
setShouldShowSendToMoodleLmsError(false)
61+
showSendSuccess()
5762
} else {
5863
setShouldShowSendToMoodleLmsError(true)
5964
}
@@ -94,15 +99,13 @@ export const SendToMoodle: FC<SendToMoodleProps> = ({
9499
<PrimaryButton
95100
onClick={() => {
96101
handleOnSendToMoodleClick()
97-
showSendSuccess()
98102
}}
99103
>
100104
Send
101105
</PrimaryButton>
102106
}
103107
onPressEnter={() => {
104108
handleOnSendToMoodleClick()
105-
showSendSuccess()
106109
}}
107110
onClose={() => {
108111
setIsAddingToMoodleLms(false)

0 commit comments

Comments
 (0)