Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added inactive school message in all the tabs #1483

Merged
merged 3 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/holds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def show
render json: {
hold: @hold.as_json,
teacher_set: @hold.teacher_set.as_json,
teacher_set_notes: @hold.teacher_set.teacher_set_notes
teacher_set_notes: @hold.teacher_set.teacher_set_notes,
is_school_active: current_user.present? ? current_user.is_school_active? : nil
}
end

Expand All @@ -43,7 +44,8 @@ def cancel_details
render json: {
hold: @hold.as_json,
teacher_set: @hold.teacher_set.as_json,
teacher_set_notes: @hold.teacher_set.teacher_set_notes
teacher_set_notes: @hold.teacher_set.teacher_set_notes,
is_school_active: current_user.present? ? current_user.is_school_active? : nil
}
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def index
end.flatten, :current_password => User.default_password.to_s}
end
orders_not_present_msg = @holds.length <= 0 ? "You have not yet placed any orders." : ""
render json: { accountdetails: resp, ordersNotPresentMsg: orders_not_present_msg }
render json: { accountdetails: resp, ordersNotPresentMsg: orders_not_present_msg,
is_school_active: current_user.present? ? current_user.is_school_active? : nil }
end

def acccount_details
Expand Down
9 changes: 7 additions & 2 deletions app/javascript/components/Accounts/Accounts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
import AppBreadcrumbs from "../AppBreadcrumbs";
import HaveQuestions from "../HaveQuestions/HaveQuestions";
import axios from "axios";

import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import {
TextInput,
Form,
Expand Down Expand Up @@ -41,6 +41,7 @@ export default function Accounts() {
const [altEmailIsvalid, setAltEmailIsvalid] = useState(false);
const [notificationType, setNotificationType] = useState("neutral");
const [displayNotification, setDisplayNotification] = useState("");
const [isSchoolActive, setIsSchoolActive] = useState("");
const tableHeaderBgColor = useColorModeValue(
"ui.bg.default",
"dark.ui.bg.default"
Expand Down Expand Up @@ -77,6 +78,7 @@ export default function Accounts() {
setPassword(accountDetails.current_password);
setTotalPages(accountDetails.total_pages);
setOrdersNotPresentMsg(accountDetails.ordersNotPresentMsg);
setIsSchoolActive(res.data.is_school_active)
}
})
.catch(function (error) {
Expand Down Expand Up @@ -328,7 +330,10 @@ export default function Accounts() {
return (
<TemplateAppContainer
breakout={<AppBreadcrumbs />}
contentTop={AccountUpdatedMessage()}
contentTop={<>
{renderInactiveSchoolMessage(isSchoolActive)}
{AccountUpdatedMessage()}
</>}
contentPrimary={
<>
<Heading
Expand Down
11 changes: 0 additions & 11 deletions app/javascript/components/AppBreadcrumbs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Heading,
Hero,
useColorModeValue,
Banner
} from "@nypl/design-system-react-components";

export default function AppBreadcrumbs(props) {
Expand Down Expand Up @@ -83,15 +82,6 @@ export default function AppBreadcrumbs(props) {
}
};

const inactiveSchoolMessage = () => {
console.log(props.is_school_active)
if (props.is_school_active === false) {
return (<Banner className="inactiveSchool" content={<>
Your school is inactive, so your account is restricted. Please contact [email protected].
</>} type="warning"/>)
}
}

const HeroDataValue = (levelString) => {
switch (levelString) {
case "participating-schools":
Expand Down Expand Up @@ -146,7 +136,6 @@ export default function AppBreadcrumbs(props) {
/>
}
/>
{inactiveSchoolMessage()}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
useColorMode,
} from "@nypl/design-system-react-components";
import { useParams, useNavigate } from "react-router-dom";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';

export default function TeacherSetOrder() {
const params = useParams();
Expand All @@ -24,6 +25,7 @@ export default function TeacherSetOrder() {
const [comment, setComment] = useState("");
const { colorMode } = useColorMode();
const [disabledButton, setDisabledButton] = useState(false);
const [isSchoolActive, setIsSchoolActive] = useState("");

useEffect(() => {
document.title = "Cancel Order | MyLibraryNYC";
Expand All @@ -34,6 +36,7 @@ export default function TeacherSetOrder() {
.then((res) => {
setTeacherSet(res.data.teacher_set);
setHold(res.data.hold);
setIsSchoolActive(res.data.is_school_active);
})
.catch(function (error) {
console.log(error);
Expand Down Expand Up @@ -129,6 +132,7 @@ export default function TeacherSetOrder() {
return (
<TemplateAppContainer
breakout={<AppBreadcrumbs />}
contentTop={renderInactiveSchoolMessage(isSchoolActive)}
contentPrimary={
<>
<Heading
Expand Down
4 changes: 3 additions & 1 deletion app/javascript/components/Contact/Contact.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import AppBreadcrumbs from "./../AppBreadcrumbs";
import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import {
TemplateAppContainer,
Heading,
Expand Down Expand Up @@ -33,7 +34,8 @@ function Contact() {

return (
<TemplateAppContainer
breakout={<AppBreadcrumbs is_school_active={isSchoolActive}/>}
breakout={<AppBreadcrumbs />}
contentTop={renderInactiveSchoolMessage(isSchoolActive)}
contentPrimary={
<div id="contacts-page">
<Heading
Expand Down
9 changes: 7 additions & 2 deletions app/javascript/components/Faqs/Faqs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AppBreadcrumbs from "./../AppBreadcrumbs";
import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import SignedInMsg from "./../SignedInMsg";
import axios from "axios";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import {
Accordion,
TemplateAppContainer,
Expand Down Expand Up @@ -54,8 +55,12 @@ export default function Faqs(props) {

return (
<TemplateAppContainer
breakout={<AppBreadcrumbs is_school_active={isSchoolActive} />}
contentTop={<SignedInMsg signInDetails={props} />}
breakout={<AppBreadcrumbs />}
contentTop={
<>
{renderInactiveSchoolMessage(isSchoolActive)}
{<SignedInMsg signInDetails={props} />}
</>}
contentPrimary={
<>
{skeletonLoaderForFaqs()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import AppBreadcrumbs from "./../AppBreadcrumbs";
import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import SignedInMsg from "./../SignedInMsg";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import axios from "axios";
import {
TextInput,
Expand Down Expand Up @@ -199,8 +200,12 @@ export default function ParticipatingSchools(props) {

return (
<TemplateAppContainer
breakout={<AppBreadcrumbs is_school_active={isSchoolActive} />}
contentTop={<SignedInMsg signInDetails={props} />}
breakout={<AppBreadcrumbs />}
contentTop={ <>
{renderInactiveSchoolMessage(isSchoolActive)}
{<SignedInMsg signInDetails={props} />}
</>
}
contentPrimary={
<>
<Heading
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import SignedInMsg from "./../SignedInMsg";
import SignUpMsg from "./../SignUp/SignUpMsg";
import axios from "axios";
import { titleCase } from "title-case";
import { capitalizeFirstLetter } from "./../Utils";
import { capitalizeFirstLetter } from "../Utils/Utils";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';

import {
Button,
ButtonGroup,
Expand Down Expand Up @@ -1263,10 +1265,11 @@ export default function SearchTeacherSets(props) {

return (
<TemplateAppContainer
breakout={<AppBreadcrumbs is_school_active={isSchoolActive} />}
breakout={<AppBreadcrumbs />}
contentTop={
<>
{<SignedInMsg signInDetails={props} />}
{renderInactiveSchoolMessage(isSchoolActive)}
{<SignUpMsg signUpDetails={props} />}
<Heading
id="search-and-find-teacher-sets-header"
Expand Down
1 change: 1 addition & 0 deletions app/javascript/components/SignedInMsg.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function SignedInMsg(props) {
content="You have signed in successfully!"
type="informative"
mb="l"
marginBottom="s"
/>
);
} else {
Expand Down
14 changes: 3 additions & 11 deletions app/javascript/components/TeacherSetBooks/TeacherSetBooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import { Link as ReactRouterLink, useParams, useLocation } from "react-router-dom";
import axios from "axios";
import { titleCase } from "title-case";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import {
Card,
CardHeading,
Expand Down Expand Up @@ -231,15 +232,6 @@ export default function TeacherSetBooks() {
);
};

const inactiveSchoolMessage = () => {
console.log(isSchoolActive === false)
if (isSchoolActive === false) {
return (<Banner className="inactiveSchool" content={<>
Your school is inactive, so your account is restricted. Please contact [email protected].
</>} type="warning"/>)
}
}

const BookImage = (data) => {
if (isLoading) {
return (
Expand Down Expand Up @@ -313,9 +305,9 @@ export default function TeacherSetBooks() {
/>
}
/>
{inactiveSchoolMessage()}
</>
</>
}
contentTop={renderInactiveSchoolMessage(isSchoolActive)}
contentPrimary={
<>
<Flex alignItems="baseline">
Expand Down
12 changes: 2 additions & 10 deletions app/javascript/components/TeacherSetDetails/TeacherSetDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import ShowBookImage from "./../ShowBookImage";
import BookTitles from "./../BookTitles";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';
import {
Link as ReactRouterLink,
useParams,
Expand Down Expand Up @@ -533,14 +534,6 @@ export default function TeacherSetDetails(props) {
}
};

const inactiveSchoolMessage = () => {
if (currentUserStatus && isSchoolActive === false) {
return (<Banner className="inactiveSchool" 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 @@ -802,11 +795,10 @@ export default function TeacherSetDetails(props) {
/>
}
/>
{inactiveSchoolMessage()}
</>
}
contentTop={
<>
<>{renderInactiveSchoolMessage(isSchoolActive)}
{errorMsg()}
</>
}
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/components/TeacherSetOrder/TeacherSetOrder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import HaveQuestions from "./../HaveQuestions/HaveQuestions";
import TeacherSetOrderDetails from "./../TeacherSetOrderDetails";
import axios from "axios";
import { useParams, useNavigate } from "react-router-dom";
import { renderInactiveSchoolMessage } from '../Utils/SchoolStatusMessage';

import {
Button,
Expand All @@ -21,6 +22,7 @@ export default function TeacherSetOrder(props) {
const [hold, setHold] = useState(props.holddetails);
const [teacherSet, setTeacherSet] = useState(props.teachersetdetails);
const { colorMode } = useColorMode();
const [isSchoolActive, setIsSchoolActive] = useState("");

useEffect(() => {
if (env.RAILS_ENV !== "test") {
Expand All @@ -40,6 +42,7 @@ export default function TeacherSetOrder(props) {
} else {
setTeacherSet(res.data.teacher_set);
setHold(res.data.hold);
setIsSchoolActive(res.data.is_school_active)
if (res.data.hold && res.data.hold.status === "cancelled") {
document.title = "Order Cancelled | MyLibraryNYC";
} else {
Expand Down Expand Up @@ -98,6 +101,7 @@ export default function TeacherSetOrder(props) {
return (
<TemplateAppContainer
breakout={<AppBreadcrumbs />}
contentTop={renderInactiveSchoolMessage(isSchoolActive)}
contentPrimary={
<>
<Heading
Expand Down
17 changes: 17 additions & 0 deletions app/javascript/components/Utils/SchoolStatusMessage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { Banner } from "@nypl/design-system-react-components";

export const renderInactiveSchoolMessage = (isSchoolActive) => {
if (isSchoolActive === false) {
return (
<Banner
content={<>
Your school is inactive, so your account is restricted. Please contact [email protected].
</>}
type="warning"
/>
);
}
return null; // Return null if the school is active
};

Loading