Skip to content

Commit

Permalink
create form gets restored to no values
Browse files Browse the repository at this point in the history
  • Loading branch information
Krisssssssssssssssssssssss committed Oct 25, 2024
1 parent 132b2f3 commit 91c8abd
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -42,11 +43,9 @@ public MovieActorRelation addActor(String movieId, String actorId) {
}

public void removeActor(String movieId, String actorId) {
MovieActorRelation relation = movieActorRelationRepository
.findByMovieIdAndActorId(movieId, actorId)
.orElseThrow();

movieActorRelationRepository.delete(relation);
Optional<MovieActorRelation> relation = movieActorRelationRepository
.findByMovieIdAndActorId(movieId, actorId);
relation.ifPresent(movieActorRelationRepository::delete);
}

public void removeRelationsByMovieId(String movieId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -41,11 +42,9 @@ public MovieDirectorRelation addRelation(String movieId, String directorId) {
}

public void removeRelation(String movieId, String directorId) {
MovieDirectorRelation relation = movieDirectorRelationRepository
.findByMovieIdAndDirectorId(movieId, directorId)
.orElseThrow();

movieDirectorRelationRepository.delete(relation);
Optional<MovieDirectorRelation> relation = movieDirectorRelationRepository
.findByMovieIdAndDirectorId(movieId, directorId);
relation.ifPresent(movieDirectorRelationRepository::delete);
}

public void removeRelationsByMovieId(String movieId) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Component/App/Details/MovieControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function MovieControls(
if (actorInstance.id) {
const data = {
movieId: movieResponse.data.id,
actorId: actorInstance.id
personId: actorInstance.id
}
await axios.post<PersonType>(`/api/movie-actor`, data);
}
Expand All @@ -65,7 +65,7 @@ export default function MovieControls(
if (directorInstance.id) {
const data = {
movieId: movieResponse.data.id,
directorId: directorInstance.id
personId: directorInstance.id
}
await axios.post<PersonType>(`/api/movie-director`, data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function EditablePersonList({legend, staff, setStaff, autocomplet
person
]
);
setPerson({id: "", name: ""});
}

return (
Expand All @@ -32,7 +33,7 @@ export default function EditablePersonList({legend, staff, setStaff, autocomplet
<button onClick={addPerson}>Add</button>
{Array.isArray(staff) && staff.length > 0 ? (
staff.map((person) => (
<div>
<div key={person.id} className="person-list">
<Person key={person.id} person={person} />
<DeletePersonButton person={person} setStaff={setStaff} staff={staff} deleteUrl={deleteUrl} movieId={movieId}/>
</div>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/Component/App/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function Header(
function login() {
const host = window.location.host === 'localhost:5173' ? 'http://localhost:8080' : window.location.origin
window.open(host + '/oauth2/authorization/github', '_self')
navigate("/")
}

const loadUser = () => {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/Component/App/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default function Main(
isWatched: true,
movieId: ""
})
setActorsData([])
setDirectorsData([])
}, [isUpdated, userName]);

const [movieData, setMovieData] = useState<MovieType>({
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Component/App/Main/CreateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function CreateButton(
if (actorInstance.id) {
const data = {
movieId: movieResponse.data.id,
actorId: actorInstance.id
personId: actorInstance.id
}
await axios.post<PersonType>(`/api/movie-actor`, data);
}
Expand All @@ -60,7 +60,7 @@ export default function CreateButton(
if (directorInstance.id) {
const data = {
movieId: movieResponse.data.id,
directorId: directorInstance.id
personId: directorInstance.id
}
await axios.post<PersonType>(`/api/movie-director`, data);
}
Expand Down

0 comments on commit 91c8abd

Please sign in to comment.