Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-rt committed Apr 14, 2024
1 parent 3d4229d commit d004a45
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 170 deletions.
16 changes: 5 additions & 11 deletions frontend/plan/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,9 +670,7 @@ export const createScheduleOnBackend = (name, sections = []) => (dispatch) => {
.then(({ id }) => {
dispatch(createScheduleOnFrontend(name, id, sections));
})
.catch((error) => {
return error.json();
});
.catch((error) => console.log(error));
};

export const deleteScheduleOnBackend = (user, scheduleName, scheduleId) => (
Expand Down Expand Up @@ -705,9 +703,7 @@ export const deleteScheduleOnBackend = (user, scheduleName, scheduleId) => (
})
);
})
.catch((error) => {
return error.json();
});
.catch((error) => console.log(error));
};

export const findOwnPrimarySchedule = (user) => (dispatch) => {
Expand All @@ -724,9 +720,7 @@ export const findOwnPrimarySchedule = (user) => (dispatch) => {
setPrimaryScheduleIdOnFrontend(foundSched?.schedule.id)
);
})
.catch((error) => {
return error.json();
})
.catch((error) => console.log(error))
);
};

Expand All @@ -752,7 +746,7 @@ export const setCurrentUserPrimarySchedule = (user, scheduleId) => (
.then(() => {
dispatch(findOwnPrimarySchedule(user));
})
.catch((error) => error.json());
.catch((error) => console.log(error));
};

export const registerAlertItem = (sectionId) => (dispatch) => {
Expand Down Expand Up @@ -879,7 +873,7 @@ export const fetchAlerts = () => (dispatch) => {
);
});
})
.catch((error) => error.json());
.catch((error) => console.log(error));
};

export const fetchContactInfo = () => (dispatch) => {
Expand Down
219 changes: 61 additions & 158 deletions frontend/plan/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useRef, useEffect } from "react";
import Head from "next/head";
import { Provider } from "react-redux";
import { applyMiddleware, compose, createStore } from "redux";
import { applyMiddleware, createStore } from "redux";
import thunkMiddleware from "redux-thunk";
import SwipeableViews from "react-swipeable-views";
import Tabs from "@material-ui/core/Tabs";
Expand All @@ -10,7 +10,6 @@ import LoginModal from "pcx-shared-components/src/accounts/LoginModal";
import styled, { createGlobalStyle } from "styled-components";
import Schedule from "../components/schedule/Schedule";
import { toast } from "react-toastify";
import { useRouter } from "next/router";

import {
initGA,
Expand All @@ -22,15 +21,15 @@ import SearchBar from "../components/search/SearchBar";
import Selector from "../components/selector/Selector";
import Footer from "../components/footer";
import Cart from "../components/Cart";
import Alerts from "../components/alert/Alerts";
import ModalContainer from "../components/modals/generic_modal_container";
import SearchSortDropdown from "../components/search/SearchSortDropdown";
import { openModal } from "../actions";
import { preventMultipleTabs } from "../components/syncutils";
import { DISABLE_MULTIPLE_TABS } from "../constants/sync_constants";
import { User } from "../types";
import { ToastContainer } from "react-toastify";
import Alerts from "../components/alert/Alerts";
import { set } from "react-ga";
import { useRouter } from "next/router";

const GlobalStyle = createGlobalStyle`
html {
Expand Down Expand Up @@ -68,6 +67,15 @@ const CustomTabs = styled(Tabs)`
}
`;

const CartTab = styled.a<{ active: boolean }>`
display: inline-flex;
font-weight: bold;
margin-bottom: 0.5rem;
cursor: pointer;
margin-right: 1rem;
color: ${(props) => (props.active ? "black" : "gray")};
`;

const Box = styled.div`
height: calc(100vh - 9em - 3em);
border-radius: 4px;
Expand Down Expand Up @@ -95,15 +103,6 @@ const Toast = styled(ToastContainer)`
}
`;

const CartTab = styled.a<{ active: boolean }>`
display: inline-flex;
font-weight: bold;
margin-bottom: 0.5rem;
cursor: pointer;
margin-right: 1rem;
color: ${(props) => (props.active ? "black" : "gray")};
`;

let middlewares = [thunkMiddleware, analyticsMiddleware];
if (process.env.NODE_ENV === "development") {
// eslint-disable-next-line
Expand Down Expand Up @@ -155,15 +154,15 @@ function Index() {
const scrollTop = () => window.scrollTo(0, 0);
const isExpanded = view === 1;

const [showLoginModal, setShowLoginModal] = useState<boolean>(true);
const [user, setUser] = useState<User | null>(null);

const [selectedTab, setSelectedTab] = useState<TabItem>(TabItem.Cart);
useEffect(() => {
setSelectedTab(router.asPath.split("#")[1] === TabItem.Alerts ? TabItem.Alerts : TabItem.Cart);
}, []);


const [showLoginModal, setShowLoginModal] = useState(true);

const [user, setUser] = useState<User | null>(null);
const TabContent = tabItems.find(({item}) => item === selectedTab)?.component

useEffect(() => {
setInnerWidth(window.innerWidth);
Expand Down Expand Up @@ -211,8 +210,6 @@ function Index() {
}
}, [store]);

const TabContent = tabItems.find(({item}) => item === selectedTab)?.component

const headPreamble = (
<Head>
<meta charSet="utf-8" />
Expand Down Expand Up @@ -283,95 +280,30 @@ function Index() {
isExpanded={isExpanded}
setShowLoginModal={setShowLoginModal}
/>
<Tab
className="topTab"
label="Cart"
onClick={() => setTab(1)}
/>
<Tab
className="topTab"
label="Alerts"
onClick={() => setTab(2)}
/>
<Tab
className="topTab"
label="Schedule"
onClick={() => setTab(3)}
/>
</CustomTabs>
<SwipeableViews
index={tab}
// @ts-ignore
ref={containerRef}
enableMouseEvents
onSwitching={scrollTop}
onChangeIndex={setTab}
>
<div
style={{
paddingLeft: "10px",
paddingRight: "10px",
}}
>
<div>
<div
style={{
display: "flex",
flexDirection: "row",
justifyContent: "space-around",
margin: "10px",
}}
>
<SearchSortDropdown />
</div>
<Box
style={{
paddingLeft: 0,
paddingRight: 0,
}}
>
<Selector mobileView={true} view={0} />
</Box>
</div>
</div>
<div style={{ padding: "10px" }}>
<Cart setTab={setTab} mobileView={true} />
</div>
<div style={{ padding: "10px" }}>
<Alerts mobileView={true} />
</div>
<div style={{ padding: "10px" }}>
{/* Unfortunately running into a weird issue with connected components and TS. */}
{/* @ts-ignore */}
<Schedule setTab={setTab} mobileView={true} />
</div>
</SwipeableViews>
</>
) : (
<>
<SearchBar
storeLoaded={storeLoaded}
store={store}
setView={setView}
setTab={setTab}
mobileView={false}
isExpanded={isExpanded}
setShowLoginModal={setShowLoginModal}
/>
<div style={{ padding: "0px 2em 0px 2em" }}>
<div
className="App columns is-mobile main smooth-transition"
style={
isExpanded
? {
padding: 0,
width: "123%",
}
: {
padding: 0,
width: "129%",
}
}
<CustomTabs value={tab} centered>
<Tab
className="topTab"
label="Search"
onClick={() => setTab(0)}
/>
<Tab
className="topTab"
label="Cart"
onClick={() => setTab(1)}
/>
<Tab
className="topTab"
label="Schedule"
onClick={() => setTab(2)}
/>
</CustomTabs>
<SwipeableViews
index={tab}
// @ts-ignore
ref={containerRef}
enableMouseEvents
onSwitching={scrollTop}
onChangeIndex={setTab}
>
<div
style={{
Expand Down Expand Up @@ -403,6 +335,9 @@ function Index() {
<div style={{ padding: "10px" }}>
<Cart setTab={setTab} mobileView={true} />
</div>
<div style={{ padding: "10px" }}>
<Alerts mobileView={true} />
</div>
<div style={{ padding: "10px" }}>
{/* Unfortunately running into a weird issue with connected components and TS. */}
{/* @ts-ignore */}
Expand Down Expand Up @@ -487,16 +422,18 @@ function Index() {
flexDirection: "column",
}}
>
<h3
style={{
display: "flex",
fontWeight: "bold",
marginBottom: "0.5rem",
}}
>
Cart
</h3>
<Cart mobileView={false} />
<div>
{tabItems.map(({item, name}) => (
<CartTab
key={item}
href={`/#${item}`}
active={selectedTab === item}
onClick={() => setSelectedTab(item)}
>
{name}
</CartTab>))}
</div>
{typeof TabContent !== "undefined" && <TabContent mobileView={false} />}
</div>
<div
style={{
Expand All @@ -510,46 +447,12 @@ function Index() {
: "smooth-transition column is-5"
}
>
<Selector mobileView={false} view={view} />
</Box>
</div>
<div
className="column is-2"
style={{
display: "flex",
flexDirection: "column",
}}
>
<div>
{tabItems.map(({item, name}) => (
<CartTab
key={item}
href={`/#${item}`}
active={selectedTab === item}
onClick={() => setSelectedTab(item)}
>
{name}
</CartTab>))}
<Toast
autoClose={1000}
hideProgressBar={true}
/>
<Schedule />
</div>
{typeof TabContent !== "undefined" && <TabContent mobileView={false} />}
</div>
<div
style={{
zIndex: 2,
paddingRight: "0px",
marginRight: "15px",
}}
className={
isExpanded
? "smooth-transition column is-5 hidden"
: "smooth-transition column is-5"
}
>
<Toast
autoClose={1000}
hideProgressBar={true}
/>
<Schedule />
</div>
</div>
</>
Expand All @@ -561,4 +464,4 @@ function Index() {
);
}

export default Index;
export default Index;
2 changes: 1 addition & 1 deletion frontend/shared-components/src/accounts/LoginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const LoginButtonContainer = styled.div`

interface LoginModalProps {
pathname: string;
siteName: String;
siteName: string;
}

const LoginModal = ({pathname, siteName}: LoginModalProps) => (
Expand Down
Loading

0 comments on commit d004a45

Please sign in to comment.