-
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.
* changed sizing of overall page containers to be more consistant * made a page for 'expo sjef' to view all pictures that is considered good for posting on instagram * done with expo page, grid of all good images with possibility to select and download pictures * fixed jzip and file-saver import * changed the api requests to get allPictures * made the page more responsive * fixed problem with key identifer * mini fix * mini fix2 * fixed problem * fixed code smells * fixed code smells * fixed code smells * made sonar ignore line with math.random * removed duplicate folder * to remove duplicate code, i made a image context for the lightbox, so we can open it from everywhere a picture is * mooo mooo code smell fix * mooo mooo code smell fix * created a text showing up if no images --------- Co-authored-by: endre2112 <[email protected]>
- Loading branch information
Showing
13 changed files
with
630 additions
and
203 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import React, { FC, useState, useEffect, useContext } from "react"; | ||
import MotiveImage from "./MotiveImage"; | ||
import "react-image-lightbox/style.css"; | ||
import { MotiveDto, PhotoDto } from "../../../generated"; | ||
import { MotiveApi } from "../../utils/api/MotiveApi"; | ||
import { PhotoApi } from "../../utils/api/PhotoApi"; | ||
import { createImgUrl } from "../../utils/createImgUrl/createImgUrl"; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Grid, | ||
Typography, | ||
} from "@mui/material"; | ||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; | ||
import { ImageContext } from "../../contexts/ImageContext"; | ||
|
||
interface Props { | ||
id: string; | ||
index: number; | ||
} | ||
|
||
const ShowGoodMotive: FC<Props> = ({ id, index }: Props) => { | ||
const [photoResponse, setPhotoResponse] = useState<PhotoDto[]>([]); | ||
const [motiveResponse, setMotiveResponse] = useState<MotiveDto>( | ||
{} as MotiveDto, | ||
); | ||
|
||
const { setPhotos, setPhotoIndex, setIsOpen } = useContext(ImageContext); | ||
|
||
const bgcolors = ["#da7777", "#f3ee78", "#9c77da", "#BADA77", "#7793da"]; | ||
|
||
const updateIndex = (index: number) => { | ||
setPhotos(photoResponse); | ||
setPhotoIndex(index); | ||
setIsOpen(true); | ||
}; | ||
|
||
const imageItems = photoResponse.map((image: PhotoDto, index: number) => { | ||
const key = `is-good-picture-${index}`; | ||
return ( | ||
<Grid key={key} item> | ||
<MotiveImage | ||
id={image.photoId.id} | ||
image={createImgUrl(image)} | ||
imageListProp={photoResponse} | ||
index={index} | ||
updateIndex={() => updateIndex(index)} | ||
title={image.motive.title} | ||
/> | ||
</Grid> | ||
); | ||
}); | ||
|
||
useEffect(() => { | ||
if (id) { | ||
MotiveApi.getById(id) | ||
.then((res) => setMotiveResponse(res)) | ||
.catch((e) => console.log(e)); | ||
PhotoApi.getAll() | ||
.then((res) => setPhotoResponse(res)) | ||
.catch((e) => console.log(e)); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{photoResponse.length != 0 && ( | ||
<Accordion> | ||
<AccordionSummary | ||
expandIcon={<ExpandMoreIcon />} | ||
aria-controls="panel1a-content" | ||
id="panel1a-header" | ||
sx={{ boxShadow: 1, bgcolor: bgcolors[index % bgcolors.length] }} | ||
> | ||
<Typography> | ||
{motiveResponse.title} | {motiveResponse.dateCreated} | ||
</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Grid container>{imageItems}</Grid> | ||
</AccordionDetails> | ||
</Accordion> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ShowGoodMotive; |
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,17 @@ | ||
import { createContext, Dispatch, SetStateAction } from "react"; | ||
import { PhotoDto } from "../../generated"; | ||
|
||
|
||
|
||
interface IImageContext { | ||
isOpen: boolean; | ||
photoIndex: number; | ||
setIsOpen: Dispatch<SetStateAction<boolean>>; | ||
setPhotoIndex: Dispatch<SetStateAction<number>>; | ||
photos: PhotoDto[], | ||
setPhotos: Dispatch<SetStateAction<Array<PhotoDto>>> | ||
} | ||
|
||
const defaultState = {} as IImageContext; | ||
|
||
export const ImageContext = createContext<IImageContext>(defaultState); |
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 |
---|---|---|
|
@@ -4,7 +4,3 @@ html { | |
margin: 0 !important; | ||
} | ||
|
||
.container { | ||
width: 90vw; | ||
margin: auto; | ||
} |
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.