edit card size

This commit is contained in:
yotakii
2026-02-10 12:27:17 +03:00
parent 085eaf5fa2
commit caad2875b4

View File

@@ -20,7 +20,7 @@ import {
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { Helmet } from 'react-helmet-async'; import { Helmet } from 'react-helmet-async';
import api from '../utils/api'; // ✅ بدل staticData import api from '../utils/api';
const API_BASE = process.env.REACT_APP_API_URL || 'http://localhost:5080'; const API_BASE = process.env.REACT_APP_API_URL || 'http://localhost:5080';
const toMediaUrl = (url) => { const toMediaUrl = (url) => {
@@ -30,14 +30,13 @@ const toMediaUrl = (url) => {
return url; return url;
} }
if (url.startsWith('/uploads/')) return `${API_BASE}${url}`; if (url.startsWith('/uploads/')) return `${API_BASE}${url}`;
return url; // /images/... stays on client return url;
}; };
const unwrapContent = (res) => { const unwrapContent = (res) => {
return res?.data?.data?.content || res?.data?.data || res?.data || null; return res?.data?.data?.content || res?.data?.data || res?.data || null;
}; };
// ✅ remove HTML tags مثل <p>..</p>
const stripHtml = (html = '') => String(html).replace(/<[^>]*>/g, '').trim(); const stripHtml = (html = '') => String(html).replace(/<[^>]*>/g, '').trim();
const About = () => { const About = () => {
@@ -47,7 +46,6 @@ const About = () => {
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const currentLanguage = i18n.language; const currentLanguage = i18n.language;
// ✅ Fetch about page content from API بدل static data
useEffect(() => { useEffect(() => {
let mounted = true; let mounted = true;
@@ -138,7 +136,6 @@ const About = () => {
// Use translations for non-English languages, API content for English // Use translations for non-English languages, API content for English
const useTranslations = currentLanguage !== 'en'; const useTranslations = currentLanguage !== 'en';
// ✅ stripHtml only for content coming from dashboard (English)
const heroTitle = useTranslations ? t('about.heroTitle') : stripHtml(content?.hero?.title || t('about.heroTitle')); const heroTitle = useTranslations ? t('about.heroTitle') : stripHtml(content?.hero?.title || t('about.heroTitle'));
const heroSubtitle = useTranslations ? t('about.heroSubtitle') : stripHtml(content?.hero?.subtitle || t('about.heroSubtitle')); const heroSubtitle = useTranslations ? t('about.heroSubtitle') : stripHtml(content?.hero?.subtitle || t('about.heroSubtitle'));
const heroDescription = useTranslations ? '' : stripHtml(content?.hero?.description || ''); const heroDescription = useTranslations ? '' : stripHtml(content?.hero?.description || '');
@@ -167,7 +164,6 @@ const About = () => {
...valuesSectionStatic, ...valuesSectionStatic,
title: stripHtml(valuesSectionStatic.title || ''), title: stripHtml(valuesSectionStatic.title || ''),
content: stripHtml(valuesSectionStatic.content || ''), content: stripHtml(valuesSectionStatic.content || ''),
// items (إذا موجودة) نتركها كما هي بدون تغيير
}; };
return ( return (
@@ -319,54 +315,58 @@ const About = () => {
</Typography> </Typography>
)} )}
<Grid container spacing={4}> <Grid container spacing={4}>
{(valuesSection.items && valuesSection.items.length > 0 ? valuesSection.items : values).map((value, index) => ( {(valuesSection.items && valuesSection.items.length > 0 ? valuesSection.items : values).map((value, index) => (
<Grid item xs={12} sm={6} md={3} key={index}> <Grid item xs={12} sm={6} md={3} key={index} sx={{ display: 'flex' }}>
<motion.div <motion.div
initial={{ opacity: 0, y: 20 }} initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }} whileInView={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, delay: index * 0.1 }} transition={{ duration: 0.6, delay: index * 0.1 }}
viewport={{ once: true }} viewport={{ once: true }}
style={{ height: '100%', width: '100%', display: 'flex' }}
>
<Card
sx={{
height: '100%',
flex: 1,
display: 'flex',
flexDirection: 'column',
textAlign: 'center',
p: 3,
'&:hover': {
transform: 'translateY(-8px)',
boxShadow: 6,
},
transition: 'all 0.3s ease',
}}
>
{value.icon && (
<Box
sx={{
display: 'flex',
justifyContent: 'center',
mb: 3,
color: 'primary.main',
}}
> >
<Card {value.icon}
sx={{ </Box>
height: '100%', )}
textAlign: 'center', <Typography
p: 3, variant="h6"
'&:hover': { component="h3"
transform: 'translateY(-8px)', sx={{ mb: 2, fontWeight: 600 }}
boxShadow: 6, >
}, {value.title}
transition: 'all 0.3s ease', </Typography>
}} <Typography variant="body2" color="text.secondary" sx={{ lineHeight: 1.6 }}>
> {value.description}
{value.icon && ( </Typography>
<Box </Card>
sx={{ </motion.div>
display: 'flex', </Grid>
justifyContent: 'center', ))}
mb: 3, </Grid>
color: 'primary.main',
}}
>
{value.icon}
</Box>
)}
<Typography
variant="h6"
component="h3"
sx={{ mb: 2, fontWeight: 600 }}
>
{value.title}
</Typography>
<Typography variant="body2" color="text.secondary" sx={{ lineHeight: 1.6 }}>
{value.description}
</Typography>
</Card>
</motion.div>
</Grid>
))}
</Grid>
</motion.div> </motion.div>
</Container> </Container>
</Box> </Box>