Skip to content

Release/june #1697

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
125 changes: 76 additions & 49 deletions src/components/Search/SearchLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PropTypes from "prop-types";
import { Accordion, Card } from "react-bootstrap";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Swal from "sweetalert2";
import { setSearchTypeAction } from "store/actions/search";

const SearchLibrary = (props) => {
const {
Expand Down Expand Up @@ -44,6 +45,8 @@ const SearchLibrary = (props) => {
noWords,
setisLoader,
activeModel,
searchTypeNew,
setSearchActivityNew,
} = props;

const onSubmit = async () => {
Expand All @@ -54,10 +57,10 @@ const SearchLibrary = (props) => {
setActiveTab(fromTeam ? "projects" : "Independent activities");
if (searchInput?.length > 255) {
Swal.fire("Character limit should be less than 255.");
} else if (
activeMainSearchType === "Projects" ||
activeMainSearchType === "projects"
) {
return;
}

if (true) {
// Swal.fire({
// title: 'Searching...', // add html attribute if you want or remove
// html: 'We are fetching results for you!',
Expand All @@ -66,28 +69,33 @@ const SearchLibrary = (props) => {
// Swal.showLoading();
// },
// });
const dataSend = {
phrase: searchInput?.trim(),
let dataSend;
// eslint-disable-next-line prefer-const
dataSend = {
query: searchInput?.trim(),
subjectArray: activeSubject,
gradeArray: activeEducation,
authorTagsArray: activeAuthorTag,
authors: authorName || undefined,
standardArray: activeType,
author: authorName || undefined,
fromDate: fromdate || undefined,
toDate: todate || undefined,
type: searchType,
from: 0,
model:
activeModel === "total"
? undefined
: activeModel || undefined,
size: 20,
model: "projects",
no_words: noWords || undefined,
};
console.log("dataSend", dataSend);
const result = await dispatch(simpleSearchAction(dataSend));
setTotalCount(result.meta?.projects);
const result = await dispatch(
searchIndependentActivitiesAction(
dataSend,
"showcase_activities"
)
);
setTotalCount(result?.meta?.total);
const tempEducation = [];
const tempSubject = [];
const tempTag = [];
const tempAuthor = [];
if (activeEducation) {
activeEducation.forEach((edu) => {
if (String(edu).includes("&")) {
Expand All @@ -114,12 +122,12 @@ const SearchLibrary = (props) => {
activeAuthorTag.forEach((sub) => {
if (String(sub).includes("&")) {
const temp = String(sub).replace("&", "and");
tempAuthor.push(temp);
tempTag.push(temp);
} else {
tempAuthor.push(sub);
tempTag.push(sub);
}
});
setActiveAuthorTag(tempAuthor);
setActiveAuthorTag(tempTag);
}
if (!fromTeam) {
// eslint-disable-next-line max-len
Expand All @@ -129,7 +137,9 @@ const SearchLibrary = (props) => {
// }/search?q=${searchInput.trim()}&type=${searchType}&grade=${tempSubject}&education=${tempEducation}&authorTag=${tempTag}&h5p=${activeType}&author=${authorName}`,
// );
}
} else if (activeMainSearchType === "Independent activities") {
}

if (true) {
// Swal.fire({
// title: 'Searching...', // add html attribute if you want or remove
// html: 'We are fetching results for you!',
Expand All @@ -138,33 +148,33 @@ const SearchLibrary = (props) => {
// Swal.showLoading();
// },
// });
let dataSend;
// eslint-disable-next-line prefer-const
dataSend = {
query: searchInput?.trim(),
const dataSend = {
phrase: searchInput?.trim(),
subjectArray: activeSubject,
gradeArray: activeEducation,
authorTagsArray: activeAuthorTag,
authors: authorName || undefined,
standardArray: activeType,
author: authorName || undefined,
fromDate: fromdate || undefined,
toDate: todate || undefined,
type: "projects",
from: 0,
model:
activeModel === "total"
? undefined
: activeModel || undefined,
size: 20,
model: "projects",
no_words: noWords || undefined,
};
const result = await dispatch(
searchIndependentActivitiesAction(
dataSend,
"showcase_activities",
),
);
setTotalCount(result?.meta?.total);
//if (searchTypeNew === "Independent activities") {
dispatch(setSearchTypeAction("projects"));
// } else {
// dispatch(setSearchTypeAction("Independent activities"));
// }

const result = await dispatch(simpleSearchAction(dataSend));
setTotalCount(result.meta?.projects);
const tempEducation = [];
const tempSubject = [];
const tempTag = [];
const tempAuthor = [];
if (activeEducation) {
activeEducation.forEach((edu) => {
if (String(edu).includes("&")) {
Expand All @@ -191,12 +201,12 @@ const SearchLibrary = (props) => {
activeAuthorTag.forEach((sub) => {
if (String(sub).includes("&")) {
const temp = String(sub).replace("&", "and");
tempTag.push(temp);
tempAuthor.push(temp);
} else {
tempTag.push(sub);
tempAuthor.push(sub);
}
});
setActiveAuthorTag(tempTag);
setActiveAuthorTag(tempAuthor);
}
if (!fromTeam) {
// eslint-disable-next-line max-len
Expand All @@ -207,26 +217,25 @@ const SearchLibrary = (props) => {
// );
}
}
dispatch(setSearchTypeAction("Independent activities"));
// setModalShow(true);
};

const clearFilters = async () => {
setSearchInput("");
setNoWords("");
setAuthor("");
setSearch([]);
setSearchActivityNew([]);
setActiveEducation([]);
setActiveSubject([]);
setActiveAuthorTag([]);
setActiveType([]);
// onSubmit();
const result = await dispatch(simpleSearchAction({}));
const result1 = await dispatch(
searchIndependentActivitiesAction(
{},
"showcase_activities",
),
);

// const result = await dispatch(simpleSearchAction({}));
// const result1 = await dispatch(
// searchIndependentActivitiesAction({}, "showcase_activities")
// );
};
return (
<Accordion defaultActiveKey="0">
Expand Down Expand Up @@ -311,11 +320,29 @@ const SearchLibrary = (props) => {
}}
/>
</div>
<div style={{ display: "flex", justifyContent: "space-between", color: "#1E68BF", alignItem: "center", alignItems: "center"}}>
<div style={{ cursor: "pointer", textDecoration: "underline" }} onClick={() => clearFilters()}>
<div
style={{
display: "flex",
justifyContent: "space-between",
color: "#1E68BF",
alignItem: "center",
alignItems: "center",
}}
>
<div
style={{
cursor: "pointer",
textDecoration: "underline",
}}
onClick={() => clearFilters()}
>
Clear All
</div>
<div className="src-btn" style={{marginBottom: "unset"}} onClick={() => onSubmit()}>
<div
className="src-btn"
style={{ marginBottom: "unset" }}
onClick={() => onSubmit()}
>
<FontAwesomeIcon icon="search" />
Search
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function MsTeamsActivityContainer({ match, history }) {
const params = new URLSearchParams();
params.append('client_id', config.teamsClientId);
params.append('response_type', 'code');
params.append('scope', 'offline_access user.read mail.read');
params.append('scope', 'offline_access user.read');
params.append('redirect_uri', `https://${window.location.hostname}/msteams/callback`);
params.append('state', window.location.href);
url.search = params.toString();
Expand Down
3 changes: 2 additions & 1 deletion src/containers/MsTeams/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ const MsTeamsCallBack = () => {
const params = new URLSearchParams(useLocation().search);
const code = params.get('code');
const state = params.get('state');
const tenantId = state.split('msteam/')[1].split('/launch')[0];
const [error, setError] = useState(null);

// Get app context and auth token
useEffect(() => {
MsTeamsService.msTeamsToken(code)
MsTeamsService.msTeamsToken(code, tenantId)
.then((response) => {
localStorage.setItem('msteams_token', response.access_token);
localStorage.setItem('msteams_refresh_token', response.refresh_token);
Expand Down
Loading