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

working on "TODO:" from "utils/constants/links.js" #9

Open
wants to merge 2 commits into
base: main
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
2 changes: 1 addition & 1 deletion actions/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getConfig = () => async dispatch => {
} catch (error) {
console.log('[getConfig] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getCredits.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const getCredits = movieId => async dispatch => {
} catch (error) {
console.log('[getCredits] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getGenreMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getGenreMovies = (genreId, page, sort) => async (
} catch (error) {
console.log('[getGenreMovies] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getGenres.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getGenres = () => async dispatch => {
} catch (error) {
console.log('[getGenres] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getMovie.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getMovie = id => async dispatch => {
} catch (error) {
console.log('[getMovie] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getPerson = id => async dispatch => {
} catch (error) {
console.log('[getPerson] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getPersonMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const getPersonMovies = (id, page, sort) => async dispatch => {
} catch (error) {
console.log('[getPersonMovies] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getRecommendedMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const getRecommendedMovies = (id, page) => async dispatch => {
} catch (error) {
console.log('[getRecommendedMovies] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getSearchMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getSearchMovies = (query, page) => async dispatch => {
} catch (error) {
console.log('[getSearchMovies] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion actions/getStaticCategoryMovies.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const getStaticCategoryMovies = (name, page) => async (dispatch, getState) => {
} catch (error) {
console.log('[getStaticCategoryMovies] error => ', error);
dispatch({type: TYPES.INSERT_ERROR, payload: error.response});
Router.push(LINKS.ERROR.HREF);
Router.push(LINKS.ERROR.PATHNAME);
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/Logo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Logo = () => (
<>
<Link
href={{
pathname: LINKS.HOME.HREF,
pathname: LINKS.HOME.PATHNAME,
query: {
[QUERY_PARAMS.CATEGORY]: STATIC_MOVIE_CATEGORIES[0].name,
[QUERY_PARAMS.PAGE]: 1
Expand Down
4 changes: 2 additions & 2 deletions components/Menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const renderStaticCategories = (staticCategories, selectedMenuItemName, closeMen
<MenuItemLink
key={staticCategory.id}
href={{
pathname: LINKS.HOME.HREF,
pathname: LINKS.HOME.PATHNAME,
query: {
[QUERY_PARAMS.CATEGORY]: staticCategory.name,
[QUERY_PARAMS.PAGE]: 1
Expand All @@ -34,7 +34,7 @@ const renderGenres = (genres, selectedMenuItemName, closeMenu = null) => {
<MenuItemLink
key={genre.id}
href={{
pathname: LINKS.GENRE.HREF,
pathname: LINKS.GENRE.PATHNAME,
query: {
[QUERY_PARAMS.ID]: genre.id,
[QUERY_PARAMS.NAME]: genre.name,
Expand Down
2 changes: 1 addition & 1 deletion components/MovieList/MovieListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const MovieListItem = ({
<PosterLink
className={POSTER_LINK_CLASS_NAME}
href={{
pathname: LINKS.MOVIE.HREF,
pathname: LINKS.MOVIE.PATHNAME,
query: {
[QUERY_PARAMS.ID]: movie.id,
[QUERY_PARAMS.PAGE]: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const PersonLink = ({
<>
<Link
href={{
pathname: LINKS.PERSON.HREF,
pathname: LINKS.PERSON.PATHNAME,
query: {
[QUERY_PARAMS.ID]: person.id,
[QUERY_PARAMS.PAGE]: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const GenreLink = ({
<>
<Link
href={{
pathname: LINKS.GENRE.HREF,
pathname: LINKS.GENRE.PATHNAME,
query: {
[QUERY_PARAMS.ID]: genre.id,
[QUERY_PARAMS.NAME]: genre.name,
Expand All @@ -39,15 +39,15 @@ const GenreLink = ({
font-weight: ${theme.typography.fontWeightBold};
text-transform: uppercase;
}

a:not(:last-child) {
margin-right: 2rem;
}

a:hover {
text-decoration: underline;
}

a:active {
transform: translateY(2px);
}
Expand Down
2 changes: 1 addition & 1 deletion components/MyTMDBLists/MyTMDBList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const MyTMDBList = ({
<PosterLink
className={POSTER_LINK_CLASS_NAME}
href={{
pathname: LINKS.LIST.HREF,
pathname: LINKS.LIST.PATHNAME,
query: {
[QUERY_PARAMS.ID]: myList.id,
[QUERY_PARAMS.PAGE]: 1
Expand Down
8 changes: 4 additions & 4 deletions containers/ListActions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ListActions = ({
{
title: 'Edit',
href: {
pathname: LINKS.ADD_OR_EDIT_LIST.HREF,
pathname: LINKS.ADD_OR_EDIT_LIST.PATHNAME,
query: {[QUERY_PARAMS.ID]: listId}
},
invisible: creatorAccountId !== accountId
Expand All @@ -46,7 +46,7 @@ const ListActions = ({
{
title: 'Add/Remove Items',
href: {
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.HREF,
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.PATHNAME,
query: {
[QUERY_PARAMS.LIST_ID]: listId,
[QUERY_PARAMS.PAGE]: 1
Expand All @@ -57,7 +57,7 @@ const ListActions = ({
{
title: 'Create New List',
href: {
pathname: LINKS.ADD_OR_EDIT_LIST.HREF
pathname: LINKS.ADD_OR_EDIT_LIST.PATHNAME
},
invisible: false
}
Expand Down Expand Up @@ -101,7 +101,7 @@ const ListActions = ({
</TextButton>
</a>
)}
</NavbarItem>
</NavbarItem>
))}
</Navbar>
</>
Expand Down
18 changes: 9 additions & 9 deletions containers/ListNavigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ const ListNavigation = ({ listId }) => {
{
title: 'Edit List',
href: {
pathname: LINKS.ADD_OR_EDIT_LIST.HREF,
pathname: LINKS.ADD_OR_EDIT_LIST.PATHNAME,
query: {[QUERY_PARAMS.ID]: listId}
},
disabled: false
},
{
title: 'View List',
href: {
pathname: LINKS.LIST.HREF,
pathname: LINKS.LIST.PATHNAME,
query: {
[QUERY_PARAMS.ID]: listId,
[QUERY_PARAMS.PAGE]: 1
Expand All @@ -32,7 +32,7 @@ const ListNavigation = ({ listId }) => {
{
title: 'Add/Remove Items',
href: {
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.HREF,
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.PATHNAME,
query: {
[QUERY_PARAMS.LIST_ID]: listId,
[QUERY_PARAMS.PAGE]: 1
Expand All @@ -43,15 +43,15 @@ const ListNavigation = ({ listId }) => {
{
title: 'Choose Image',
href: {
pathname: LINKS.CHOOSE_LIST_IMAGE.HREF,
pathname: LINKS.CHOOSE_LIST_IMAGE.PATHNAME,
query: {[QUERY_PARAMS.LIST_ID]: listId, [QUERY_PARAMS.PAGE]: 1}
},
disabled: false
},
{
title: 'Delete List',
href: {
pathname: LINKS.REMOVE_LIST.HREF,
pathname: LINKS.REMOVE_LIST.PATHNAME,
query: {[QUERY_PARAMS.ID]: listId}
},
disabled: false
Expand All @@ -62,21 +62,21 @@ const ListNavigation = ({ listId }) => {
{
title: 'Step1: List Details',
href: {
pathname: LINKS.ADD_OR_EDIT_LIST.HREF
pathname: LINKS.ADD_OR_EDIT_LIST.PATHNAME
},
disabled: false
},
{
title: 'Step2: Add Items',
href: {
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.HREF
pathname: LINKS.ADD_OR_REMOVE_ITEMS_AT_LIST.PATHNAME
},
disabled: true
},
{
title: 'Step3: Choose Image',
href: {
pathname: LINKS.CHOOSE_LIST_IMAGE.HREF
pathname: LINKS.CHOOSE_LIST_IMAGE.PATHNAME
},
disabled: true
}
Expand All @@ -95,7 +95,7 @@ const ListNavigation = ({ listId }) => {
href={listLink.href}>
<a>{listLink.title}</a>
</Link>
</NavbarItem>
</NavbarItem>
))}
</Navbar>
);
Expand Down
2 changes: 1 addition & 1 deletion containers/SearchBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SearchBar = ({
// setSearchTerm('');
setOpened(false);
Router.push({
pathname: LINKS.SEARCH.HREF,
pathname: LINKS.SEARCH.PATHNAME,
query: {
[QUERY_PARAMS.SEARCH_TERM]: searchTerm,
[QUERY_PARAMS.PAGE]: 1
Expand Down
4 changes: 2 additions & 2 deletions containers/TheUser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ const TheUser = ({
)}>
<DropdownMenuItem>
<Link href={{
pathname: LINKS.ADD_OR_EDIT_LIST.HREF
pathname: LINKS.ADD_OR_EDIT_LIST.PATHNAME
}}>
<a>Create New List</a>
</Link>
</DropdownMenuItem>
<DropdownMenuItem>
<Link href={{
pathname: LINKS.MY_LISTS.HREF,
pathname: LINKS.MY_LISTS.PATHNAME,
query: {
[QUERY_PARAMS.PAGE]: 1
}
Expand Down
4 changes: 2 additions & 2 deletions pages/genre/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Genre = () => {
const newPage = 1;
console.log('[Genre useEffect] query parameter update: newGenreId, newGenreName, newPage => ', newGenreId, newGenreName, newPage);
Router.replace({
pathname: LINKS.GENRE.HREF,
pathname: LINKS.GENRE.PATHNAME,
query: {
[QUERY_PARAMS.ID]: newGenreId,
[QUERY_PARAMS.NAME]: newGenreName,
Expand All @@ -63,7 +63,7 @@ const Genre = () => {
useEffect(() => {
(async () => {
if (!genreId || !genreName || !page || !sortByOptionValue) return;

scroll.scrollToTop({smooth: true});

await dispatch(setSelectedMenuItemName(genreName));
Expand Down
6 changes: 3 additions & 3 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Home = () => {

const categoryName = query[QUERY_PARAMS.CATEGORY];
const page = Number(query[QUERY_PARAMS.PAGE]);

useEffect(() => {
return () => {
dispatch(setSelectedMenuItemName());
Expand All @@ -54,7 +54,7 @@ const Home = () => {

useEffect(() => {
// MEMO: check if query parsing has finished
if (Router.router.asPath !== LINKS.HOME.HREF && checkEmptyObject(query)) return;
if (Router.router.asPath !== LINKS.HOME.PATHNAME && checkEmptyObject(query)) return;

const initialCategoryName = Router.query[QUERY_PARAMS.CATEGORY];
const initialPage = Router.query[QUERY_PARAMS.PAGE];
Expand Down Expand Up @@ -99,7 +99,7 @@ const Home = () => {
if (!categoryName || !page) return;

scroll.scrollToTop({smooth: true});

await dispatch(setSelectedMenuItemName(categoryName));
dispatch(getStaticCategoryMovies(categoryName, page));
})();
Expand Down
2 changes: 1 addition & 1 deletion pages/list/add-or-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const AddOrEdit = ({

useEffect(() => {
// MEMO: check if there is no query parameter (list ID) which means ADD case
if (Router.router.asPath === LINKS.ADD_OR_EDIT_LIST.HREF) {
if (Router.router.asPath === LINKS.ADD_OR_EDIT_LIST.PATHNAME) {
setEditStatus(STATUSES.RESOLVED);
}
}, []);
Expand Down
6 changes: 3 additions & 3 deletions pages/list/remove/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ const Remove = ({
const headers = {
'Authorization': `Bearer ${accessToken}`
};

setRemoveStatus(STATUSES.PENDING);

await tmdbAPI.delete(`/${TMDB_API_NEW_VERSION}/list/${listId}`, {headers});

setRemoveStatus(STATUSES.RESOLVED);

Router.push({
pathname: LINKS.MY_LISTS.HREF,
pathname: LINKS.MY_LISTS.PATHNAME,
query: {
[QUERY_PARAMS.PAGE]: 1
}
Expand All @@ -101,7 +101,7 @@ const Remove = ({
if (status === STATUSES.IDLE || status === STATUSES.PENDING) {
return <Loader />;
}

if (status === STATUSES.REJECTED) {
// TODO: should show proper error message based on error state
return (
Expand Down
Loading