Skip to content

Commit

Permalink
Merge pull request #1317 from massenergize/BHN-cleanup
Browse files Browse the repository at this point in the history
Two issues: 1316 (resolve to custom URL) and API 986 (feature flag clean-up)
  • Loading branch information
archx3 committed May 14, 2024
2 parents 6be2a3a + f09136f commit 87ac5ee
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
19 changes: 14 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function App() {
// Update the document title using the browser API
if (!community) {
const hostname = window.location.hostname;
const pathname = window.location.pathname;
const slash = pathname.indexOf("/", 1);
const subdomain =
slash > 0 ? pathname.substring(1, slash) : pathname.substring(1);

let body = {};
if (URLS.NONE_CUSTOM_WEBSITE_LIST.has(hostname)) {
const pathname = window.location.pathname;
const slash = pathname.indexOf("/", 1);
const subdomain =
slash > 0 ? pathname.substring(1, slash) : pathname.substring(1);

// if no subdomain found, redirect to all communities page (NB: The all communities page does not exist on this side of the application. It is a page on the backend)
const thereIsNoSubdomain = [undefined, "", "/"].indexOf(subdomain) > -1;
if (thereIsNoSubdomain) {
Expand All @@ -70,11 +70,20 @@ function App() {
type: LOAD_COMMUNITY_INFORMATION,
payload: json.data,
});
if (json.data.website) {
dispatch({
type: SET_IS_CUSTOM_SITE,
payload: true,
});
const newURL = 'https://' + json.data.website + pathname.substring(slash);
window.location.href = newURL;
}
} else {
setError(json.error);
}
})
.catch((err) => setError(err.message));

}
}, [community, dispatch]);

Expand Down
1 change: 0 additions & 1 deletion src/components/Pages/FeatureFlags/flags.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const FLAGS = {
GUEST_AUTHENTICATION: "guest-authentication-feature-flag",
COMMUNICATION_PREFS: "communication-prefs-feature-flag",
USER_SUBMITTED_ACTIONS: "user-submitted-actions-feature-flag",
USER_SUBMITTED_EVENTS: "user-submitted-events-feature-flag",
USER_SUBMITTED_VENDORS: "user-submitted-vendors-feature-flag",
Expand Down
20 changes: 8 additions & 12 deletions src/components/Pages/ProfilePage/ProfileOptions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from "react";
import { FLAGS } from "../FeatureFlags/flags";
import Feature from "../FeatureFlags/Feature";

function ProfileOptions({
pathname,
Expand Down Expand Up @@ -69,16 +67,14 @@ function ProfileOptions({
</div>
)}

<Feature name={FLAGS.COMMUNICATION_PREFS}>
<div
className="link-to touchable-opacity"
onClick={() => history.push(`${links.profile}/settings`)}
>
<span className=" fa fa-bell" />
<p>Change communication preferences </p>
<i className=" fa fa-long-arrow-right" />
</div>
</Feature>
<div
className="link-to touchable-opacity"
onClick={() => history.push(`${links.profile}/settings`)}
>
<span className=" fa fa-bell" />
<p>Change communication preferences </p>
<i className=" fa fa-long-arrow-right" />
</div>

<div
className="link-to touchable-opacity"
Expand Down
50 changes: 23 additions & 27 deletions src/components/Pages/Settings/RenderOptions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React, {useState} from "react";
import { apiCall } from "../../../api/functions";
import Feature from "../FeatureFlags/Feature";
import { FLAGS } from "../FeatureFlags/flags";
import MEButton from "../Widgets/MEButton";
import RenderCheckboxes from "./RenderCheckboxes";
import RenderRadios from "./RenderRadios";
Expand Down Expand Up @@ -76,32 +74,30 @@ function RenderOptions({
<small>Save Settings</small>
</MEButton>

<Feature name={FLAGS.COMMUNICATION_PREFS}>
<MEButton
onClick={() => {
apiCall("/downloads.sample.user_report", { community_id }).then(
(res) => {
if (res?.data) {
toggleToast({
open: true,
type: "success",
message: "Your request has been sent to your email.",
});
} else {
toggleToast({
type: "error",
open: true,
message:
"An error occurred while processing your request. Try again later.",
});
}
<MEButton
onClick={() => {
apiCall("/downloads.sample.user_report", { community_id }).then(
(res) => {
if (res?.data) {
toggleToast({
open: true,
type: "success",
message: "Your request has been sent to your email.",
});
} else {
toggleToast({
type: "error",
open: true,
message:
"An error occurred while processing your request. Try again later.",
});
}
);
}}
>
<small>Send yourself a sample email</small>
</MEButton>
</Feature>
}
);
}}
>
<small>Send yourself a sample email</small>
</MEButton>
</div>
);
}
Expand Down

0 comments on commit 87ac5ee

Please sign in to comment.