Skip to content

Commit

Permalink
Merge pull request #37 from AleksandraKrasteva/dev
Browse files Browse the repository at this point in the history
client fixes
  • Loading branch information
AleksandraKrasteva authored Jun 23, 2024
2 parents 356f80d + 733014a commit 8fa3477
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 19 deletions.
4 changes: 2 additions & 2 deletions client/src/api/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else if(process.env.NEXT_PUBLIC_ENVIRONMENT == 'development'){
baseURL= 'http://localhost:80';
}
else if(process.env.NEXT_PUBLIC_ENVIRONMENT == 'prod'){
baseURL= 'http://localhost:8080';
baseURL= 'http://4.182.131.77';
}
console.log(baseURL);

Expand Down Expand Up @@ -179,7 +179,7 @@ export const deleteJourneysForUser = (username:string, token: string) => {
Authorization: 'Bearer ' + token,
};

return axios.delete(`http://skipass.api/delete-journeys-user/${username}`, {headers}).then((res) => {
return axios.delete(`${baseURL}/delete-journeys-user/${username}`, {headers}).then((res) => {
return res;
});
};
4 changes: 1 addition & 3 deletions client/src/components/atoms/PostsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const PostsView = (props:Props) => {
setExpandedId(postId);
if(journeyId !== 0){
const res = await viewJourney(journeyId);
console.log(res);
if (res.data){
setJourney(res.data);
}
Expand Down Expand Up @@ -70,7 +69,6 @@ const PostsView = (props:Props) => {
props.setTrigger(!props.trigger);
})
.catch((e)=>{
console.log(e);
if(e.response.status === 401){
// @ts-ignore
loginWithRedirect();
Expand All @@ -80,7 +78,7 @@ const PostsView = (props:Props) => {
const reaction = selected[0].reactions?.filter((x)=>x.creator === user?.nickname && x.postId === postId );
await deleteReaction(reaction[0].id, token).then(()=>{
props.setTrigger(!props.trigger);
}).catch((e)=>{console.log(e);});
}).catch(()=>{});
}

};
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/atoms/UserPostsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const UserPostsView = (props:Props) => {
await deletePost(data, token).then(()=>{
props.setTrigger(!props.trigger);
}).catch((e)=>{
console.log(e);
if(e.response.status === 401){
// @ts-ignore
loginWithRedirect();
Expand Down Expand Up @@ -119,7 +118,6 @@ const UserPostsView = (props:Props) => {
props.setTrigger(!props.trigger);
setEditing(false);
}).catch((e)=>{
console.log(e);
if(e.response.status === 401){
// @ts-ignore

Expand Down
5 changes: 3 additions & 2 deletions client/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const HomePage = () => {
return (
<>
<Navigation/>
{isAuthenticated && <Box sx={{mt:10}}>
{isAuthenticated ? <Box sx={{mt:10}}>
<Typography
sx={{
ml: 4,
Expand All @@ -55,7 +55,8 @@ const HomePage = () => {
}}
> Welcome {user!.nickname}!
</Typography>
</Box>}
</Box>
:<Box sx={{mt:10}}></Box>}
{posts.length == 0 ?
<Typography
sx={{
Expand Down
46 changes: 36 additions & 10 deletions client/src/pages/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const style = {
transform: 'translate(-50%, -50%)',
width: 400,
bgcolor: 'background.paper',
border: '2px solid #000',
border: 1,
borderColor: 'pink',
borderRadius: '16px',
boxShadow: 24,
p: 4,
};
Expand Down Expand Up @@ -151,11 +153,19 @@ const Profile = () => {
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<Typography sx={{color: 'red'}}id="modal-modal-title" variant="h6" component="h2">
<Typography
sx={{
ml:2,
fontFamily: 'monospace',
fontSize: 18,
fontWeight: 700,
letterSpacing: '.1rem',
color: 'teal',
}}>
Are you sure that you want to delete all of your journeys?. This action can not be undone.
</Typography>
<Button onClick={()=>{deleteJourneys();}}>Delete</Button>
<Button onClick={()=>setDelJourneys(false)}>Cancel</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>{deleteJourneys();}}>Delete</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>setDelJourneys(false)}>Cancel</Button>
</Box>
</Modal>
<Modal
Expand All @@ -165,11 +175,19 @@ const Profile = () => {
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<Typography sx={{color:'red'}}id="modal-modal-title" variant="h6" component="h2">
<Typography
sx={{
ml:2,
fontFamily: 'monospace',
fontSize: 18,
fontWeight: 700,
letterSpacing: '.1rem',
color: 'teal',
}}>
Are you sure that you want to delete all of your likes? This action can not be undone.
</Typography>
<Button onClick={()=>{deleteLikes();}}>Delete</Button>
<Button onClick={()=>setDelLikes(false)}>Cancel</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>{deleteLikes();}}>Delete</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>setDelLikes(false)}>Cancel</Button>
</Box>
</Modal>
<Modal
Expand All @@ -179,11 +197,19 @@ const Profile = () => {
aria-describedby="modal-modal-description"
>
<Box sx={style}>
<Typography sx={{color: 'red'}} id="modal-modal-title" variant="h6" component="h2">
<Typography
sx={{
ml:2,
fontFamily: 'monospace',
fontSize: 18,
fontWeight: 700,
letterSpacing: '.1rem',
color: 'teal',
}}>
Are you sure that you want to delete all of your posts? This action can not be undone.
</Typography>
<Button onClick={()=>{deletePosts();}}>Delete</Button>
<Button onClick={()=>setDelPosts(false)}>Cancel</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>{deletePosts();}}>Delete</Button>
<Button sx={{fontFamily: 'monospace', bgcolor:'pink', color: 'black', mt:2, ml:4}} onClick={()=>setDelPosts(false)}>Cancel</Button>
</Box>
</Modal>

Expand Down

0 comments on commit 8fa3477

Please sign in to comment.