Skip to content

Commit 18076b8

Browse files
authored
Revert "🍀 Fix Update Broadcast Modal Description Population and Refactor form…" (#1068)
This reverts commit 223ed8a.
1 parent 223ed8a commit 18076b8

File tree

4 files changed

+136
-519
lines changed

4 files changed

+136
-519
lines changed

‎frontend/src/pages/Admin/Admin.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const Admin = (props) => {
258258
) : tab === 15 ? (
259259
<ResetPassword />
260260
) : tab === 16 ? (
261-
<ManageBroadcasts theme={props.theme}/>
261+
<ManageBroadcasts />
262262
) : tab === 18 ? (
263263
<QandA setQId={setQId} setTab={setTab} tab={tab} />
264264
) : tab === 19 ? (

‎frontend/src/pages/Admin/Components/Broadcast/ManageBroadcasts/ManageBroadcasts.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Loader from "../../../../../components/util/Loader";
1010
import { Button4 } from "../../../../../components/util/Button";
1111
import { customBoardcast } from "../../../../../service/Broadcast.jsx";
1212

13-
export function ManageBroadcasts(props) {
13+
export function ManageBroadcasts() {
1414
const [array, setArray] = useState([]);
1515
const [index, setIndex] = useState(0);
1616
const [visible, setVisible] = useState(false);
@@ -86,15 +86,13 @@ export function ManageBroadcasts(props) {
8686
setArray(result);
8787
setLoaded(true);
8888
}
89-
const { theme } = props;
9089
return (
9190
<div>
9291
<Edit
9392
visible={visible}
9493
setVisible={setVisible}
9594
handleChange={handleChange}
9695
data={array[index]}
97-
theme={theme}
9896
/>
9997
<div id={style["hero"]}>
10098
<div className={style["motive"]}>
Lines changed: 70 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,83 @@
1-
import React, { useState } from "react";
1+
import React, { useEffect, useState } from "react";
22
import style from "./edit.module.scss";
3-
import { Button2 } from "../../../../../components/util/Button/index";
4-
import SunEditor from "suneditor-react";
5-
import "suneditor/dist/css/suneditor.min.css";
6-
import { SimpleToast } from "../../../../../components/util/Toast";
7-
import { UpdateBoardCast } from "../../../../../service/Broadcast.jsx";
3+
import { TextField } from "@material-ui/core";
4+
import CloseIcon from "@material-ui/icons/Close";
85

96
export function Edit(props) {
10-
const [toast, setToast] = useState({
11-
toastStatus: false,
12-
toastType: "",
13-
toastMessage: "",
14-
});
7+
const [a, seta] = useState();
8+
function scrolls() {
9+
let b = window.scrollY;
10+
seta(b);
11+
}
12+
useEffect(() => {
13+
window.addEventListener("scroll", scrolls);
14+
}, []);
1515

16-
const handleCloseToast = (event, reason) => {
17-
if (reason === "clickaway") {
18-
return;
19-
}
20-
setToast({ ...toast, toastStatus: false });
21-
props.setVisible(false);
22-
};
23-
24-
const handleInputChange = (e) => {
25-
const { name, value } = e.target;
26-
props.handleChange({ target: { name, value } });
27-
};
28-
29-
const handleContentChange = (content) => {
30-
props.handleChange({ target: { name: 'content', value: content } });
31-
};
32-
33-
const handleSubmit = async (e) => {
34-
e.preventDefault();
35-
const { data } = props;
36-
const newData = {
37-
id: data._id,
38-
content:data.content,
39-
link: data.link,
40-
expiresOn: data.expiresOn,
41-
imageUrl: data.imageUrl,
42-
tags: data.tags,
43-
isApproved: data.isApproved,
44-
title: data.title,
45-
};
46-
47-
try {
48-
await UpdateBoardCast(newData,setToast, toast);
49-
setToast({
50-
toastStatus: true,
51-
toastType: "success",
52-
toastMessage: "Broadcast updated successfully!",
53-
});
54-
} catch (error) {
55-
console.error("Error updating broadcast:", error);
56-
setToast({
57-
toastStatus: true,
58-
toastType: "error",
59-
toastMessage: "Failed to update broadcast. Please try again.",
60-
});
61-
}
62-
};
63-
64-
const { visible, data} = props;
6516
let dark = props.theme;
66-
67-
return visible ? (
68-
<div className={style["popup"]}>
69-
<div className={
70-
dark
71-
? `${style["card"]} ${style["card-dark"]} `
72-
: `${style["card"]} ${style["card-light"]}`
73-
}>
74-
<form className={style["editor"]} onSubmit={handleSubmit}>
75-
<div className={style["motive"]}>
76-
<h1 className={
77-
dark
78-
? `${style["header-text"]} ${style["header-text-dark"]} `
79-
: `${style["header-text"]} ${style["header-text-light"]}`
80-
}>Edit Broadcast</h1>
81-
<div className={
82-
dark
83-
? `${style.dash} ${style["dash-dark"]}`
84-
: `${style.dash} ${style["dash-light"]}`
85-
} />
86-
</div>
87-
<div>
88-
<div className={
89-
dark
90-
? `${style["input"]} ${style["input-dark"]} `
91-
: `${style["input"]} ${style["input-light"]}`
92-
}>
93-
<input
94-
type="text"
95-
name="title"
96-
// className={style["form-control-input"]}
97-
placeholder="Title"
98-
value={data.title}
99-
onChange={handleInputChange}
100-
/>
101-
<i className="fas fa-pencil-alt" />
102-
</div>
103-
</div>
104-
<div>
105-
<div className={
106-
dark
107-
? `${style["input"]} ${style["input-dark"]} `
108-
: `${style["input"]} ${style["input-light"]}`
109-
}>
110-
<SunEditor
111-
name="content"
112-
placeholder="Description"
113-
setContents={data.content}
114-
onChange={handleContentChange}
115-
height="100px"
116-
className={style["edit"]}
117-
onSetContents={(content) =>
118-
handleInputChange({ target: { name: "content", value: content } })
119-
}
120-
/>
121-
</div>
122-
</div>
123-
<div>
124-
<div className={
125-
dark
126-
? `${style["input"]} ${style["input-dark"]} `
127-
: `${style["input"]} ${style["input-light"]}`
128-
}>
129-
<input
130-
type="text"
131-
name="link"
132-
placeholder="Resource Link"
133-
value={data.link}
134-
onChange={handleInputChange}
135-
/>
136-
<i className="fas fa-link" />
137-
</div>
17+
return props.visible ? (
18+
<div className={style["popup"]} style={{ top: a }}>
19+
<div className={dark ? style["div-dark"] : style["div"]}>
20+
<h1 className={style["heading"]}>
21+
Edit modal
22+
<CloseIcon
23+
style={{ float: "right", cursor: "pointer" }}
24+
onClick={() => props.setVisible(false)}
25+
/>
26+
</h1>
27+
<form>
28+
<div className={style["form"]}>
29+
<h5>Title:</h5>
30+
<TextField
31+
type="text"
32+
name="title"
33+
placeholder="Title"
34+
multiline
35+
value={props.data.title}
36+
className={style["input"]}
37+
InputProps={{
38+
className: `${dark ? style["input-dark"] : ""}`,
39+
}}
40+
onChange={props.handleChange}
41+
/>
13842
</div>
139-
<div className={style["submit-btn"]}>
140-
<Button2
141-
className={style["submit-btn-text"]}
142-
label="Update"
143-
type="submit"
43+
<div className={style.form}>
44+
<h5>Description:</h5>
45+
<TextField
46+
type="text"
47+
name="desc"
48+
multiline
49+
placeholder="Description"
50+
value={props.data.desc}
51+
className={style["input"]}
52+
InputProps={{
53+
className: `${dark ? style["input-dark"] : ""}`,
54+
}}
55+
onChange={props.handleChange}
14456
/>
145-
<Button2
146-
className={style["submit-btn-text"]}
147-
label="Cancel"
148-
type="button"
149-
onClick={() => props.setVisible(false)}
57+
</div>
58+
<div className={style.form}>
59+
<h5>Link:</h5>
60+
<TextField
61+
type="text"
62+
name="link"
63+
placeholder="Link"
64+
className={style["input"]}
65+
InputProps={{
66+
className: `${dark ? style["input-dark"] : ""}`,
67+
}}
68+
onChange={props.handleChange}
69+
value={props.data.link}
70+
multiline
15071
/>
15172
</div>
73+
<button
74+
className={style["btns1"]}
75+
onClick={() => props.setVisible(false)}
76+
>
77+
Edit
78+
</button>
15279
</form>
15380
</div>
154-
{toast.toastStatus && (
155-
<div className={style["toast-overlay"]}>
156-
<SimpleToast
157-
open={toast.toastStatus}
158-
message={toast.toastMessage}
159-
handleCloseToast={handleCloseToast}
160-
severity={toast.toastType}
161-
/>
162-
</div>
163-
)}
16481
</div>
16582
) : null;
166-
}
83+
}

0 commit comments

Comments
 (0)