Skip to content

Commit

Permalink
api refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Farmaha committed Feb 1, 2024
1 parent 3c8d075 commit d014844
Show file tree
Hide file tree
Showing 28 changed files with 160 additions and 28 deletions.
10 changes: 7 additions & 3 deletions src/Api/ApiRequest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import data from './photoBase.json';
import photos from "./photos.json";
import members from "./members.json";

export const photosApi = () => {
return photos;
};

export const apiRequest = () => {
return data
export const membersApi = () => {
return members;
};
42 changes: 21 additions & 21 deletions src/Api/photoBase.json β†’ src/Api/members.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,127 +2,127 @@
{
"id": "1",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/1.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/1.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "2",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/2.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/2.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "3",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/3.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/3.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "4",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/4.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/4.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "5",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/5.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/5.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "6",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/6.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/6.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "7",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/7.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/7.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "8",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/8.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/8.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "9",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/9.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/9.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "10",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/10.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/10.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "11",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/11.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/11.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "12",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/12.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/12.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "13",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/13.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/13.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "14",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/14.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/14.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "15",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/15.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/15.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "16",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/16.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/16.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "17",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/17.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/17.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "18",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/18.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/18.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "19",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/19.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/19.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "20",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/20.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/20.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "21",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/photos/21.jpg",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/21.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
}
]
128 changes: 128 additions & 0 deletions src/Api/photos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
[
{
"id": "1",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/1.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "2",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/2.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "3",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/3.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "4",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/4.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "5",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/5.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "6",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/6.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "7",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/7.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "8",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/8.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "9",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/9.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "10",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/10.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "11",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/11.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "12",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/12.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "13",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/13.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "14",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/14.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "15",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/15.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "16",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/16.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "17",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/17.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "18",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/18.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "19",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/19.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "20",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/20.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
},
{
"id": "21",
"date": "unknown",
"path": "https://raw.githubusercontent.com/M-Farmaha/100-club/main/src/ImageGallery/photos/21.jpg",
"description": "Π’ΡƒΡ‚ ΠΌΠΎΠΆΠ΅ Π±ΡƒΡ‚ΠΈ опис"
}
]
4 changes: 2 additions & 2 deletions src/components/ImageGallery/ImageGallery.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { apiRequest } from "../../Api/ApiRequest";
import { photosApi } from "../../Api/ApiRequest";
import { ImageGalleryItem } from "./ImageGalleryItem";

import { ImageGalleryList, Section, SectionWrap } from "./ImageGallery-styled";
Expand All @@ -8,7 +8,7 @@ export const ImageGallery = () => {
const [galleryArray, setGalleryArray] = useState([]);

useEffect(() => {
const response = apiRequest();
const response = photosApi();
setGalleryArray(response);
}, []);

Expand Down
4 changes: 2 additions & 2 deletions src/components/ImageGallery/ImageGalleryModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import sprite from "../../sprite.svg";
import { Loader } from "../Loaders/Loaders";
import { Modal } from "../Modal/Modal";
import { Portal } from "../../Routes/Portal/Portal";
import { apiRequest } from "../../Api/ApiRequest";
import { photosApi } from "../../Api/ApiRequest";

export const ImageGalleryModal = () => {
const { id } = useParams();
Expand All @@ -36,7 +36,7 @@ export const ImageGalleryModal = () => {
setScrollPosition(rect.y - window.innerHeight / 2 + 100);
}

const response = apiRequest();
const response = photosApi();
const current = response.find((el) => String(el.id) === String(id));
setGalleryArray(response);
setCurrentImg(current);
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Empty file.
Empty file.

0 comments on commit d014844

Please sign in to comment.