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

Closed #864 and fixed error with check device screen size #873

Merged
merged 1 commit into from
Feb 23, 2024
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
8 changes: 4 additions & 4 deletions frontend/src/components/PredictionEventsDataGrid/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import useBreakpoint from '../../hooks/useBreakpoint';

function PredictEventToolbar({ }) {

const { viewLayoyt, setViewLayoyt } = useContext(PredictionEventsContext)
const currentBreakpoint = useBreakpoint()
const isMobile = ['xs', 'sm'].indexOf(currentBreakpoint.getBreakPointName()) !== -1 ? true : false

const { viewLayoyt, setViewLayoyt, isMobile } = useContext(PredictionEventsContext)
// const currentBreakpoint = useBreakpoint()
// const isMobile = ['xs', 'sm', 'md', 'lg'].indexOf(currentBreakpoint.getBreakPointName()) !== -1 ? true : false
// console.log("isMobile: %o", isMobile)
const handleChangeLayout = (e, value) => {
if (value !== null) {
setViewLayoyt(value)
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/contexts/PredictionContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import dayjs from "dayjs"
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import useBreakpoint from '../hooks/useBreakpoint';
dayjs.extend(utc);
dayjs.extend(timezone);
export const PredictionEventsContext = createContext({})
Expand Down Expand Up @@ -36,15 +37,19 @@ export function PredictionEventsProvider({ children }) {

const [queryOptions, setQueryOptions] = useState(setInitialFilter())

const currentBreakpoint = useBreakpoint()
const isMobile = ['xs', 'sm', 'md'].indexOf(currentBreakpoint.getBreakPointName()) !== -1 ? true : false
// console.log("isMobile: %o", isMobile)

// list ou grid
const [viewLayoyt, setViewLayoyt] = useState("list")
const [viewLayoyt, setViewLayoyt] = useState(isMobile ? "grid" : "list")

function clearFilter() {
setQueryOptions(setInitialFilter())
}

return <PredictionEventsContext.Provider value={{
queryOptions, setQueryOptions, clearFilter, viewLayoyt, setViewLayoyt
queryOptions, setQueryOptions, clearFilter, viewLayoyt, setViewLayoyt, isMobile
}}>{children}</PredictionEventsContext.Provider>
}

Expand Down
Loading