-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
34 changed files
with
925 additions
and
78 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from typing import Any | ||
|
||
from rest_framework.exceptions import APIException | ||
|
||
|
||
class CustomAPIException(APIException): | ||
def __init__(self, detail: Any, code: str) -> None: | ||
self.code = code | ||
super().__init__({**detail, "code": code}) |
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
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
60 changes: 60 additions & 0 deletions
60
frontend/src/components/buttons/LevelAddToMyPlaylistButton/index.tsx
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,60 @@ | ||
import { useContext } from "react"; | ||
import { useState } from "react"; | ||
import { useQueryClient } from "react-query"; | ||
import { Button } from "src/components/common/Button"; | ||
import { IconBookmark } from "src/components/icons"; | ||
import { PlaylistItemModal } from "src/components/modals/PlaylistItemModal"; | ||
import { UserContext } from "src/contexts/UserContext"; | ||
import type { LevelNested } from "src/services/LevelService"; | ||
import { PlaylistService } from "src/services/PlaylistService"; | ||
import { resetQueries } from "src/utils/misc"; | ||
|
||
interface LevelAddToMyPlaylistButtonProps { | ||
level: LevelNested; | ||
} | ||
|
||
const LevelAddToMyPlaylistButton = ({ | ||
level, | ||
}: LevelAddToMyPlaylistButtonProps) => { | ||
const { user } = useContext(UserContext); | ||
const queryClient = useQueryClient(); | ||
const [isChanged, setIsChanged] = useState(false); | ||
const [isModalActive, setIsModalActive] = useState(false); | ||
|
||
const handleButtonClick = () => { | ||
setIsModalActive(true); | ||
}; | ||
|
||
const handleSubmit = () => { | ||
setIsChanged(true); | ||
}; | ||
|
||
const handleIsModalActiveChange = (value: boolean) => { | ||
setIsModalActive(value); | ||
if (isChanged) { | ||
resetQueries(queryClient, ["playlists"]); | ||
} | ||
}; | ||
|
||
if (!user) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<> | ||
<PlaylistItemModal | ||
isActive={isModalActive} | ||
onIsActiveChange={handleIsModalActiveChange} | ||
user={user} | ||
level={level} | ||
onSubmit={handleSubmit} | ||
/> | ||
|
||
<Button icon={<IconBookmark />} onClick={handleButtonClick}> | ||
Add to my playlist | ||
</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export { LevelAddToMyPlaylistButton }; |
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
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.