Skip to content

Commit

Permalink
added inactive school banner message
Browse files Browse the repository at this point in the history
  • Loading branch information
deepikagonuguntla committed Dec 18, 2024
1 parent e8c83df commit f3cc307
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
16 changes: 8 additions & 8 deletions app/controllers/holds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/teacher_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def index
teacher_sets, @facets, total_count = ElasticSearch.new.get_teacher_sets_from_es(params)
@teacher_sets = teacher_sets_from_elastic_search_doc(teacher_sets)
end

# Determine what facets are selected based on query string
@facets.each do |f|
f[:items].each do |v|
Expand Down Expand Up @@ -175,7 +174,8 @@ def show
user: current_user,
allowed_quantities: allowed_quantities,
books: ts_books,
teacher_set_notes: @set.teacher_set_notes
teacher_set_notes: @set.teacher_set_notes,
is_school_active: current_user.school_id.present? ? School.find(current_user.school_id).active : false
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -793,7 +804,12 @@ export default function TeacherSetDetails(props) {
/>
</>
}
contentTop={errorMsg()}
contentTop={
<>
{errorMsg()}
{inactiveSchoolMessage()}
</>
}
contentPrimary={
<>
<Flex alignItems="baseline">
Expand Down

0 comments on commit f3cc307

Please sign in to comment.