-
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.
added inactive school banner message
- Loading branch information
1 parent
e8c83df
commit f3cc307
Showing
3 changed files
with
27 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,14 +64,14 @@ def ordered_holds_details | |
# Calculate available copies from quantity saves in teacherset table. | ||
def create | ||
begin | ||
# If user's school is inactive, then display an error message and redirect to teacher set detail page. | ||
is_school_active = current_user.school_id.present? ? School.find(current_user.school_id).active : false | ||
if !is_school_active | ||
render json: { status: :error, message: "Your school is inactive. Please contact [email protected]" } | ||
# stop processing further code, so new hold is not created, | ||
# and double-render runtime error is not caused in the rescue exception block. | ||
return | ||
end | ||
# # If user's school is inactive, then display an error message and redirect to teacher set detail page. | ||
# is_school_active = current_user.school_id.present? ? School.find(current_user.school_id).active : false | ||
# if !is_school_active | ||
# render json: { status: :error, message: "Your school is inactive. Please contact [email protected]", is_school_active: is_school_active } | ||
# # stop processing further code, so new hold is not created, | ||
# # and double-render runtime error is not caused in the rescue exception block. | ||
# return | ||
# end | ||
|
||
Hold.transaction do | ||
set = TeacherSet.find(params[:teacher_set_id]) | ||
|
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 |
---|---|---|
|
@@ -55,6 +55,7 @@ export default function TeacherSetDetails(props) { | |
const [isLoading, setIsLoading] = useState(true); | ||
const [currentUserStatus, setCurrentUserStatus] = useState(); | ||
const [disabledButton, setDisabledButton] = useState(false); | ||
const [isSchoolActive, setIsSchoolActive] = useState(false); | ||
const heroBgColor = useColorModeValue( | ||
"var(--nypl-colors-brand-primary)", | ||
"var(--nypl-colors-dark-ui-bg-hover)" | ||
|
@@ -108,6 +109,8 @@ export default function TeacherSetDetails(props) { | |
setTeacherSetNotes(res.data.teacher_set_notes); | ||
let userStatus = res.data.user ? res.data.user.status : ""; | ||
setCurrentUserStatus(userStatus); | ||
setIsSchoolActive(res.data.is_school_active) | ||
setDisabledButton(!res.data.is_school_active) | ||
if (env.RAILS_ENV !== "test" && env.RAILS_ENV !== "development") { | ||
adobeAnalyticsForTeacherSet(res.data.teacher_set); | ||
} | ||
|
@@ -530,6 +533,14 @@ export default function TeacherSetDetails(props) { | |
} | ||
}; | ||
|
||
const inactiveSchoolMessage = () => { | ||
if (!isSchoolActive) { | ||
return (<Banner content={<> | ||
Your school is inactive, so your account is restricted. Please contact [email protected]. | ||
</>} type="warning" />) | ||
} | ||
} | ||
|
||
const teacherSetAvailability = () => { | ||
if (isLargerThanMobile && teacherSet.availability !== undefined) { | ||
return ( | ||
|
@@ -793,7 +804,12 @@ export default function TeacherSetDetails(props) { | |
/> | ||
</> | ||
} | ||
contentTop={errorMsg()} | ||
contentTop={ | ||
<> | ||
{errorMsg()} | ||
{inactiveSchoolMessage()} | ||
</> | ||
} | ||
contentPrimary={ | ||
<> | ||
<Flex alignItems="baseline"> | ||
|