Skip to content

Commit 0bc0e79

Browse files
committed
Bug Fixed: The respective image should appear in the Recent&Previous Broadcast Cards
1 parent 1b26e50 commit 0bc0e79

File tree

1 file changed

+43
-22
lines changed

1 file changed

+43
-22
lines changed

frontend/src/pages/Broadcast/Component/Carousel/Carousel.jsx

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function Carousel(props) {
1818
toastStatus: false,
1919
toastType: "",
2020
toastMessage: "",
21-
})
21+
});
2222
const [open, setOpen] = useState(false);
2323
const [dataa, setDataa] = useState([]);
2424
const [isLoaded, setLoaded] = useState(false);
@@ -62,23 +62,31 @@ export function Carousel(props) {
6262
const cardImageArrayLight = dataa.map((item, i) => {
6363
const style = {
6464
height: "13em",
65-
backgroundSize: "cover",
65+
backgroundSize: "23.9em",
66+
//backgroundSize: "cover", // Cover the entire area
67+
margin: "0 auto",
68+
backgroundPosition: "center",
69+
backgroundRepeat: "no-repeat",
6670
backgroundBlendMode: "screen",
67-
clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
68-
backgroundImage: `linear-gradient(45deg,rgba(255, 0, 90, 1) 0%,rgba(10, 24, 61, 1) 90%),url(${item.link})`,
71+
// clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
72+
backgroundImage: `linear-gradient(45deg,rgba(255, 0, 90, 1) 0%,rgba(10, 24, 61, 1) 90%),url(${item.imageUrl[0]})`,
6973
};
7074
return style;
7175
});
7276

7377
const cardImageArrayDark = dataa.map((item, i) => {
7478
const style = {
7579
height: "13em",
76-
backgroundSize: "cover",
80+
backgroundSize: "23.9em",
81+
//backgroundSize: "cover", // Cover the entire area
82+
margin: "0 auto",
83+
backgroundPosition: "center",
84+
backgroundRepeat: "no-repeat",
7785
backgroundBlendMode: "screen",
78-
clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
86+
// clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
7987
backgroundImage: `linear-gradient(45deg,
8088
#4e4376 0%,
81-
#2b5876 90%),url(${item.link})`,
89+
#2b5876 90%),url(${item.imageUrl[0]})`,
8290
};
8391
return style;
8492
});
@@ -88,12 +96,14 @@ export function Carousel(props) {
8896
}, []);
8997
const getData = async () => {
9098
setLoaded(false);
91-
const result = await boardcast(setToast,toast)
92-
const approvedBroadcasts = result.filter(broadcast => broadcast.isApproved);
99+
const result = await boardcast(setToast, toast);
100+
const approvedBroadcasts = result.filter(
101+
(broadcast) => broadcast.isApproved
102+
);
93103
setDataa(approvedBroadcasts);
94104
setLoaded(true);
95-
}
96-
const handleCloseToast = (event,reason) => {
105+
};
106+
const handleCloseToast = (event, reason) => {
97107
if (reason === "clickaway") {
98108
return;
99109
}
@@ -102,7 +112,7 @@ export function Carousel(props) {
102112

103113
const truncatedContent = (content, maxLength) => {
104114
if (content.length > maxLength) {
105-
return content.substring(0, maxLength) + '...';
115+
return content.substring(0, maxLength) + "...";
106116
}
107117
return content;
108118
};
@@ -146,27 +156,38 @@ export function Carousel(props) {
146156
: `${style["slide-card-light"]} ${style["slide-card"]}`
147157
}
148158
onClick={() =>
149-
handleOpen(item.content, item.title, item.imageUrl[0], item?.link)
159+
handleOpen(
160+
item.content,
161+
item.title,
162+
item.imageUrl[0],
163+
item?.link
164+
)
150165
}
151166
>
152167
<div
153168
style={dark ? cardImageArrayDark[i] : cardImageArrayLight[i]}
154169
></div>
155170

156171
<h3 className={style["card-head"]}>{item.title}</h3>
157-
<div className={style["card-text"]}
158-
dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(truncatedContent(item.content, 250)),}} />
172+
<div
173+
className={style["card-text"]}
174+
dangerouslySetInnerHTML={{
175+
__html: DOMPurify.sanitize(
176+
truncatedContent(item.content, 250)
177+
),
178+
}}
179+
/>
159180
</div>
160181
))}
161182
</OwlCarousel>
162183
{toast.toastStatus && (
163-
<SimpleToast
164-
open={toast.toastStatus}
165-
message={toast.toastMessage}
166-
handleCloseToast={handleCloseToast}
167-
severity={toast.toastType}
168-
/>
169-
)}
184+
<SimpleToast
185+
open={toast.toastStatus}
186+
message={toast.toastMessage}
187+
handleCloseToast={handleCloseToast}
188+
severity={toast.toastType}
189+
/>
190+
)}
170191
</div>
171192
</React.Fragment>
172193
);

0 commit comments

Comments
 (0)