Skip to content

Commit c5a036f

Browse files
authored
Merge pull request #28 from Seol-JY/feature/new
[FEAT]: 광고 삽입
2 parents ac6b4c1 + 57c69ff commit c5a036f

File tree

3 files changed

+67
-61
lines changed

3 files changed

+67
-61
lines changed

client/src/App.js

+41-27
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useState, useEffect } from "react";
99
import { Provider } from "react-redux";
1010
import store from "./redux/store";
1111
import Draggable from "react-draggable";
12+
import InFeedAdvertise from "./components/advertises/InFeedAdvertise";
1213

1314
function App() {
1415
const [section, setSection] = useState("1");
@@ -24,36 +25,36 @@ function App() {
2425
const [counterValue, setCounterValue] = useState(0);
2526

2627
useEffect(() => {
27-
fetchCounterValue();
28+
// fetchCounterValue();
2829
egg();
2930
}, []);
3031

31-
const fetchCounterValue = async () => {
32-
try {
33-
const response = await fetch("/counter");
34-
if (!response.ok) {
35-
throw new Error("Failed to fetch counter value");
36-
}
37-
const data = await response.json();
38-
setCounterValue(data.value);
39-
} catch (error) {
40-
console.error("Failed to fetch counter value:", error);
41-
}
42-
};
43-
const increaseCounter = async () => {
44-
try {
45-
const response = await fetch(`/counter?amount=${1}`, {
46-
method: "POST",
47-
});
48-
if (!response.ok) {
49-
throw new Error("Failed to increase counter value");
50-
}
51-
setCounterValue((prevValue) => prevValue + 1);
52-
setButtonClicked(true);
53-
} catch (error) {
54-
console.error("Failed to increase counter value:", error);
55-
}
56-
};
32+
// const fetchCounterValue = async () => {
33+
// try {
34+
// const response = await fetch("/counter");
35+
// if (!response.ok) {
36+
// throw new Error("Failed to fetch counter value");
37+
// }
38+
// const data = await response.json();
39+
// setCounterValue(data.value);
40+
// } catch (error) {
41+
// console.error("Failed to fetch counter value:", error);
42+
// }
43+
// };
44+
// const increaseCounter = async () => {
45+
// try {
46+
// const response = await fetch(`/counter?amount=${1}`, {
47+
// method: "POST",
48+
// });
49+
// if (!response.ok) {
50+
// throw new Error("Failed to increase counter value");
51+
// }
52+
// setCounterValue((prevValue) => prevValue + 1);
53+
// setButtonClicked(true);
54+
// } catch (error) {
55+
// console.error("Failed to increase counter value:", error);
56+
// }
57+
// };
5758

5859
const handleResize = () => {
5960
setScale(Math.min(window.innerWidth / 1400, window.innerHeight / 900));
@@ -115,6 +116,19 @@ function App() {
115116
</button>
116117
)}
117118
</div> */}
119+
<div
120+
style={{
121+
margin: "0 10px 0 0",
122+
position: "absolute",
123+
right: "0",
124+
top: "calc(100vh/2 - 250px)",
125+
display: "flex",
126+
justifyContent: "space-around",
127+
alignItems: "center",
128+
}}
129+
>
130+
<InFeedAdvertise />
131+
</div>
118132
<div className="scale-wrapper" style={{ transform: `scale(${scale})` }}>
119133
<Draggable onDrag={(e, data) => trackPos(data)}>
120134
<div className="form no-drag">

client/src/components/LeaderBoard.jsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export default function LeaderBoard({ daynight }) {
6363
</ul>
6464
) : (
6565
<ul className="sidebarsection-rank">
66-
{items
67-
.map((s, i) => {
66+
{
67+
items.map((s, i) => {
6868
// if (i === 2) {
6969
// return (
7070
// <li key={s._id} ref={prev}>
@@ -84,17 +84,19 @@ export default function LeaderBoard({ daynight }) {
8484
</li>
8585
);
8686
})
87-
.reduce((acc, curr, i) => {
88-
if (i === 3) {
89-
acc.push(
90-
<li key="advertise">
91-
<InFeedAdvertise />
92-
</li>
93-
);
94-
}
95-
acc.push(curr);
96-
return acc;
97-
}, [])}
87+
// 인피드 광고가 3번째에 삽입되어야 하나, 최소 width를 만족하지 못해 제거
88+
// .reduce((acc, curr, i) => {
89+
// if (i === 3) {
90+
// acc.push(
91+
// <li key="advertise">
92+
// <InFeedAdvertise />
93+
// </li>
94+
// );
95+
// }
96+
// acc.push(curr);
97+
// return acc;
98+
// }, [])
99+
}
98100
{loading && (
99101
<li>
100102
<ul>

client/src/components/advertises/InFeedAdvertise.jsx

+11-21
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { useEffect } from "react";
22

3-
const InFeedAdvertise = ({
4-
className = "adsbygoogle",
5-
client = "ca-pub-8658385917169302",
6-
slot = "1562420452",
7-
format = "fluid",
8-
layoutKey = "-fp+68-11-df+sd",
9-
}) => {
3+
const InFeedAdvertise = () => {
104
useEffect(() => {
115
if (process.env.NODE_ENV === "production")
126
try {
@@ -24,10 +18,9 @@ const InFeedAdvertise = ({
2418
style={{
2519
background: "#8aff8a",
2620
color: "black",
27-
fontSize: "18px",
28-
fontWeight: "bold",
29-
textAlign: "center",
30-
padding: "16px",
21+
display: "inline-block",
22+
width: "140px",
23+
height: "500px",
3124
}}
3225
>
3326
광고 표시 영역
@@ -36,18 +29,15 @@ const InFeedAdvertise = ({
3629
//production인 경우 구글 광고 표시
3730
return (
3831
<ins
39-
className={className}
32+
className="adsbygoogle"
4033
style={{
41-
overflowX: "auto",
42-
overflowY: "hidden",
43-
display: "block",
44-
textAlign: "center",
34+
display: "inline-block",
35+
width: "140px",
36+
height: "500px",
4537
}}
46-
data-ad-client={client}
47-
data-ad-slot={slot}
48-
data-ad-format={format}
49-
data-ad-layout-key={layoutKey}
50-
/>
38+
data-ad-client="ca-pub-8658385917169302"
39+
data-ad-slot="5603304488"
40+
></ins>
5141
);
5242
};
5343

0 commit comments

Comments
 (0)