Revert to version ae99983
This commit is contained in:
parent
5d72cee2f9
commit
bf9fcdfc11
File diff suppressed because one or more lines are too long
@ -6,21 +6,10 @@ const fetch = require('node-fetch');
|
|||||||
const KEY = pexelsKey;
|
const KEY = pexelsKey;
|
||||||
|
|
||||||
router.get('/image', async (req, res) => {
|
router.get('/image', async (req, res) => {
|
||||||
const headers = {
|
// Return static Wix image instead of Pexels
|
||||||
Authorization: `${KEY}`,
|
res.status(200).json({
|
||||||
};
|
src: 'https://static.wixstatic.com/media/42b9b7_87daee7014234d78a8a0766bd8d906bd~mv2.jpeg/v1/crop/x_0,y_186,w_768,h_652/fill/w_768,h_652,al_c,q_85,enc_avif,quality_auto/WhatsApp%20Image%202023-11-07%20at%2019_31_00.jpeg'
|
||||||
const query = pexelsQuery || 'nature';
|
});
|
||||||
const orientation = 'portrait';
|
|
||||||
const perPage = 1;
|
|
||||||
const url = `https://api.pexels.com/v1/search?query=${query}&orientation=${orientation}&per_page=${perPage}&page=1`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch(url, { headers });
|
|
||||||
const data = await response.json();
|
|
||||||
res.status(200).json(data.photos[0]);
|
|
||||||
} catch (error) {
|
|
||||||
res.status(200).json({ error: 'Failed to fetch image' });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/video', async (req, res) => {
|
router.get('/video', async (req, res) => {
|
||||||
@ -41,66 +30,21 @@ router.get('/video', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/multiple-images', async (req, res) => {
|
// Return the user-specified static images in random order for all galleries
|
||||||
const headers = {
|
router.get('/multiple-images', (req, res) => {
|
||||||
Authorization: `${KEY}`,
|
const images = [
|
||||||
};
|
{ src: 'https://static.wixstatic.com/media/42b9b7_87daee7014234d78a8a0766bd8d906bd~mv2.jpeg/v1/crop/x_0,y_186,w_768,h_652/fill/w_768,h_652,al_c,q_85,enc_avif,quality_auto/WhatsApp%20Image%202023-11-07%20at%2019_31_00.jpeg', photographer: '', photographer_url: '' },
|
||||||
|
{ src: 'https://static.wixstatic.com/media/42b9b7_3e6e0cf2e71f4fca8c12705c35df1d61~mv2.jpg/v1/crop/x_59,y_0,w_905,h_768/fill/w_850,h_721,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/D29C232E-F61F-46B2-AF8C-1E29C87270C8_L0_001%20(1).jpg', photographer: '', photographer_url: '' },
|
||||||
|
{ src: 'https://static.wixstatic.com/media/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png/v1/fill/w_529,h_678,al_c,lg_1,q_85,enc_avif,quality_auto/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png', photographer: '', photographer_url: '' }
|
||||||
|
];
|
||||||
|
|
||||||
const queries = req.query.queries
|
// Shuffle the images array
|
||||||
? req.query.queries.split(',')
|
for (let i = images.length - 1; i > 0; i--) {
|
||||||
: ['home', 'apple', 'pizza', 'mountains', 'cat'];
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
const orientation = 'square';
|
[images[i], images[j]] = [images[j], images[i]];
|
||||||
const perPage = 1;
|
|
||||||
|
|
||||||
const fallbackImage = {
|
|
||||||
src: 'https://images.pexels.com/photos/8199252/pexels-photo-8199252.jpeg',
|
|
||||||
photographer: 'Yan Krukau',
|
|
||||||
photographer_url: 'https://www.pexels.com/@yankrukov',
|
|
||||||
};
|
|
||||||
const fetchFallbackImage = async () => {
|
|
||||||
try {
|
|
||||||
const response = await fetch('https://picsum.photos/600');
|
|
||||||
return {
|
|
||||||
src: response.url,
|
|
||||||
photographer: 'Random Picsum',
|
|
||||||
photographer_url: 'https://picsum.photos/',
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
return fallbackImage;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
const fetchImage = async (query) => {
|
|
||||||
const url = `https://api.pexels.com/v1/search?query=${query}&orientation=${orientation}&per_page=${perPage}&page=1`;
|
|
||||||
const response = await fetch(url, { headers });
|
|
||||||
const data = await response.json();
|
|
||||||
return data.photos[0] || null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const imagePromises = queries.map((query) => fetchImage(query));
|
res.json(images);
|
||||||
const imagesResults = await Promise.allSettled(imagePromises);
|
|
||||||
|
|
||||||
const formattedImages = await Promise.all(
|
|
||||||
imagesResults.map(async (result) => {
|
|
||||||
if (result.status === 'fulfilled' && result.value) {
|
|
||||||
const image = result.value;
|
|
||||||
return {
|
|
||||||
src: image.src?.original || fallbackImage.src,
|
|
||||||
photographer: image.photographer || fallbackImage.photographer,
|
|
||||||
photographer_url:
|
|
||||||
image.photographer_url || fallbackImage.photographer_url,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
const fallback = await fetchFallbackImage();
|
|
||||||
return {
|
|
||||||
src: fallback.src || '',
|
|
||||||
photographer: fallback.photographer || 'Unknown',
|
|
||||||
photographer_url: fallback.photographer_url || '',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
res.json(formattedImages);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
@ -11,7 +11,7 @@ const HeroImageBg = ({
|
|||||||
<div
|
<div
|
||||||
className='relative w-full h-screen flex items-center justify-center text-center mb-24 bg-cover bg-center'
|
className='relative w-full h-screen flex items-center justify-center text-center mb-24 bg-cover bg-center'
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${imageHero[0]?.src})`,
|
backgroundImage: `url('https://static.wixstatic.com/media/42b9b7_04d3e636f03349f28be843bce8350e9f~mv2.png/v1/fill/w_1236,h_896,al_c,q_90,enc_avif,quality_auto/42b9b7_04d3e636f03349f28be843bce8350e9f~mv2.png')`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className='absolute inset-0 bg-black opacity-50'></div>
|
<div className='absolute inset-0 bg-black opacity-50'></div>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import axios from 'axios';
|
|||||||
|
|
||||||
export async function getPexelsImage() {
|
export async function getPexelsImage() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/pexels/image`);
|
const response = await axios.get(`/api/pexels/image`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching image:', error);
|
console.error('Error fetching image:', error);
|
||||||
@ -12,7 +12,7 @@ export async function getPexelsImage() {
|
|||||||
|
|
||||||
export async function getPexelsVideo() {
|
export async function getPexelsVideo() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/pexels/video`);
|
const response = await axios.get(`/api/pexels/video`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching video:', error);
|
console.error('Error fetching video:', error);
|
||||||
@ -33,6 +33,8 @@ export async function getMultiplePexelsImages(
|
|||||||
}
|
}
|
||||||
localStorageLock = true;
|
localStorageLock = true;
|
||||||
|
|
||||||
|
// Force-clear old Pexels cache to load new Wix images
|
||||||
|
localStorage.removeItem('pexelsImagesCache');
|
||||||
const cachedImages =
|
const cachedImages =
|
||||||
JSON.parse(localStorage.getItem('pexelsImagesCache')) || {};
|
JSON.parse(localStorage.getItem('pexelsImagesCache')) || {};
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ export async function getMultiplePexelsImages(
|
|||||||
const queryString = missingQueries.join(',');
|
const queryString = missingQueries.join(',');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`/pexels/multiple-images`, {
|
const response = await axios.get(`/api/pexels/multiple-images`, {
|
||||||
params: { queries: queryString },
|
params: { queries: queryString },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import FeaturesSection from '../components/WebPageComponents/FeaturesComponent';
|
|||||||
|
|
||||||
import GalleryPortfolioSection from '../components/WebPageComponents/GalleryPortfolioComponent';
|
import GalleryPortfolioSection from '../components/WebPageComponents/GalleryPortfolioComponent';
|
||||||
|
|
||||||
import { getMultiplePexelsImages } from '../helpers/pexels';
|
|
||||||
|
|
||||||
import AboutUsSection from '../components/WebPageComponents/AboutUsComponent';
|
import AboutUsSection from '../components/WebPageComponents/AboutUsComponent';
|
||||||
|
|
||||||
@ -79,32 +78,13 @@ export default function WebSite() {
|
|||||||
icon: 'mdiChartLine',
|
icon: 'mdiChartLine',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// Use static Wix images for the gallery
|
||||||
|
const images = [
|
||||||
|
{ src: 'https://static.wixstatic.com/media/42b9b7_87daee7014234d78a8a0766bd8d906bd~mv2.jpeg/v1/crop/x_0,y_186,w_768,h_652/fill/w_768,h_652,al_c,q_85,enc_avif,quality_auto/WhatsApp%20Image%202023-11-07%20at%2019_31_00.jpeg' },
|
||||||
|
{ src: 'https://static.wixstatic.com/media/42b9b7_3e6e0cf2e71f4fca8c12705c35df1d61~mv2.jpg/v1/crop/x_59,y_0,w_905,h_768/fill/w_850,h_721,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/D29C232E-F61F-46B2-AF8C-1E29C87270C8_L0_001%20(1).jpg' },
|
||||||
|
{ src: 'https://static.wixstatic.com/media/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png/v1/fill/w_529,h_678,al_c,lg_1,q_85,enc_avif,quality_auto/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png' }
|
||||||
|
];
|
||||||
|
|
||||||
const [images, setImages] = useState([]);
|
|
||||||
const pexelsQueriesWebSite = [
|
|
||||||
'Team building the robot',
|
|
||||||
'Robotics competition excitement',
|
|
||||||
'Innovative robot design process',
|
|
||||||
'Team brainstorming session',
|
|
||||||
'Celebrating competition success',
|
|
||||||
];
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchImages = async () => {
|
|
||||||
try {
|
|
||||||
const images = await getMultiplePexelsImages(pexelsQueriesWebSite);
|
|
||||||
const formattedImages = (images || []).map((image) => ({
|
|
||||||
src: image?.src || undefined,
|
|
||||||
photographer: image?.photographer || undefined,
|
|
||||||
photographer_url: image?.photographer_url || undefined,
|
|
||||||
}));
|
|
||||||
setImages(formattedImages);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching images:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchImages();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col min-h-screen'>
|
<div className='flex flex-col min-h-screen'>
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import FeaturesSection from '../../components/WebPageComponents/FeaturesComponen
|
|||||||
|
|
||||||
import GalleryPortfolioSection from '../../components/WebPageComponents/GalleryPortfolioComponent';
|
import GalleryPortfolioSection from '../../components/WebPageComponents/GalleryPortfolioComponent';
|
||||||
|
|
||||||
import { getMultiplePexelsImages } from '../../helpers/pexels';
|
|
||||||
|
|
||||||
import AboutUsSection from '../../components/WebPageComponents/AboutUsComponent';
|
import AboutUsSection from '../../components/WebPageComponents/AboutUsComponent';
|
||||||
|
|
||||||
@ -59,31 +58,11 @@ export default function WebSite() {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const [images, setImages] = useState([]);
|
const images = [
|
||||||
const pexelsQueriesWebSite = [
|
{ src: 'https://static.wixstatic.com/media/42b9b7_87daee7014234d78a8a0766bd8d906bd~mv2.jpeg/v1/crop/x_0,y_186,w_768,h_652/fill/w_768,h_652,al_c,q_85,enc_avif,quality_auto/WhatsApp%20Image%202023-11-07%20at%2019_31_00.jpeg' },
|
||||||
'Team building the robot',
|
{ src: 'https://static.wixstatic.com/media/42b9b7_3e6e0cf2e71f4fca8c12705c35df1d61~mv2.jpg/v1/crop/x_59,y_0,w_905,h_768/fill/w_850,h_721,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/D29C232E-F61F-46B2-AF8C-1E29C87270C8_L0_001%20(1).jpg' },
|
||||||
'Robotics competition excitement',
|
{ src: 'https://static.wixstatic.com/media/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png/v1/fill/w_529,h_678,al_c,lg_1,q_85,enc_avif,quality_auto/42b9b7_b26e4585851c4e60a32d892baff6ca4e~mv2.png' }
|
||||||
'Innovative robot design process',
|
|
||||||
'Team brainstorming session',
|
|
||||||
'Celebrating competition success',
|
|
||||||
];
|
];
|
||||||
useEffect(() => {
|
|
||||||
const fetchImages = async () => {
|
|
||||||
try {
|
|
||||||
const images = await getMultiplePexelsImages(pexelsQueriesWebSite);
|
|
||||||
const formattedImages = (images || []).map((image) => ({
|
|
||||||
src: image?.src || undefined,
|
|
||||||
photographer: image?.photographer || undefined,
|
|
||||||
photographer_url: image?.photographer_url || undefined,
|
|
||||||
}));
|
|
||||||
setImages(formattedImages);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching images:', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
fetchImages();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='flex flex-col min-h-screen'>
|
<div className='flex flex-col min-h-screen'>
|
||||||
|
|||||||
@ -74,7 +74,7 @@ export const create = createAsyncThunk(
|
|||||||
'scouting/createScouting',
|
'scouting/createScouting',
|
||||||
async (data: any, { rejectWithValue }) => {
|
async (data: any, { rejectWithValue }) => {
|
||||||
try {
|
try {
|
||||||
const result = await axios.post('scouting', { data });
|
const result = await axios.post('/api/scouting', { data }, { withCredentials: true });
|
||||||
return result.data;
|
return result.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!error.response) {
|
if (!error.response) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user