forked from intrig-unicamp/paths-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41d3f38
commit 3c36049
Showing
11 changed files
with
174 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
REACT_APP_GOOGLE_API_KEY = "string" | ||
NEXT_PUBLIC_GOOGLE_API_KEY = "string" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { TypedUseSelectorHook, useDispatch, useSelector } from "react-redux"; | ||
import type { AppDispatch, AppState } from "./store"; | ||
|
||
export const useAppDispatch = () => useDispatch<AppDispatch>(); | ||
|
||
export const useAppSelector: TypedUseSelectorHook<AppState> = useSelector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Action, configureStore, ThunkAction } from "@reduxjs/toolkit"; | ||
import filesReducer from "../features/files/slice"; | ||
|
||
export function makeStore() { | ||
return configureStore({ | ||
reducer: { files: filesReducer }, | ||
}); | ||
} | ||
|
||
const store = makeStore(); | ||
|
||
export type AppState = ReturnType<typeof store.getState>; | ||
|
||
export type AppDispatch = typeof store.dispatch; | ||
|
||
export type AppThunk<ReturnType = void> = ThunkAction< | ||
ReturnType, | ||
AppState, | ||
unknown, | ||
Action<string> | ||
>; | ||
|
||
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; | ||
import type { AppState } from "../../config/store"; | ||
import { IFile } from "../../pages/_app"; | ||
|
||
export interface FilesState { | ||
files: IFile[]; | ||
} | ||
|
||
const initialState: FilesState = { | ||
files: [], | ||
}; | ||
|
||
export const filesSlice = createSlice({ | ||
name: "files", | ||
initialState, | ||
reducers: { | ||
add: (state, action: PayloadAction<IFile>) => { | ||
const currentFiles = [...state.files]; | ||
currentFiles.push(action.payload); | ||
state.files = currentFiles; | ||
}, | ||
remove: (state, action: PayloadAction<number>) => { | ||
const currentFiles = [...state.files]; | ||
currentFiles.splice(action.payload); | ||
state.files = currentFiles; | ||
}, | ||
changeColor: ( | ||
state, | ||
action: PayloadAction<{ index: number; color: string }> | ||
) => { | ||
const currentFiles = [...state.files]; | ||
const { index, color } = action.payload; | ||
currentFiles[index].color = color; | ||
state.files = currentFiles; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { add, remove, changeColor } = filesSlice.actions; | ||
|
||
export const selectFiles = (state: AppState) => state.files.files; | ||
|
||
export default filesSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import { FunctionComponent, useState } from "react"; | ||
import { FunctionComponent } from "react"; | ||
import FilesSelectionContainer from "../components/FilesSelectionContainer/FilesSelectionContainer"; | ||
import { IFile } from "./_app"; | ||
|
||
const FilesSelectionPage: FunctionComponent = () => { | ||
const [files, setFiles] = useState<IFile[]>([]); | ||
return <FilesSelectionContainer files={files} setFiles={setFiles} />; | ||
return <FilesSelectionContainer />; | ||
}; | ||
|
||
export default FilesSelectionPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.