Skip to content

Commit

Permalink
updated edit broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamgaur99 committed Jun 24, 2024
1 parent c2237ec commit 7a8eb26
Show file tree
Hide file tree
Showing 4 changed files with 349 additions and 110 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/Admin/Admin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const Admin = (props) => {
) : tab === 15 ? (
<ResetPassword />
) : tab === 16 ? (
<ManageBroadcasts />
<ManageBroadcasts theme={props.theme}/>
) : tab === 18 ? (
<QandA setQId={setQId} setTab={setTab} tab={tab} />
) : tab === 19 ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Loader from "../../../../../components/util/Loader";
import { Button4 } from "../../../../../components/util/Button";
import { customBoardcast } from "../../../../../service/Broadcast.jsx";

export function ManageBroadcasts() {
export function ManageBroadcasts(props) {
const [array, setArray] = useState([]);
const [index, setIndex] = useState(0);
const [visible, setVisible] = useState(false);
Expand Down Expand Up @@ -86,13 +86,15 @@ export function ManageBroadcasts() {
setArray(result);
setLoaded(true);
}
const { theme } = props;
return (
<div>
<Edit
visible={visible}
setVisible={setVisible}
handleChange={handleChange}
data={array[index]}
theme={theme}
/>
<div id={style["hero"]}>
<div className={style["motive"]}>
Expand Down
58 changes: 48 additions & 10 deletions frontend/src/pages/Broadcast/Component/AllBroadcasts/Edit/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,56 @@ export function Edit(props) {
title: data.title,
};

await UpdateBoardCast(newData, setToast, toast);
try {
await UpdateBoardCast(newData,setToast, toast);
setToast({
toastStatus: true,
toastType: "success",
toastMessage: "Broadcast updated successfully!",
});
} catch (error) {
console.error("Error updating broadcast:", error);
setToast({
toastStatus: true,
toastType: "error",
toastMessage: "Failed to update broadcast. Please try again.",
});
}
};

const { visible, data } = props;
const { visible, data} = props;
let dark = props.theme;

return visible ? (
<div className={style["popup"]}>
<div className={style["card"]}>
<div className={
dark
? `${style["card"]} ${style["card-dark"]} `
: `${style["card"]} ${style["card-light"]}`
}>
<form className={style["editor"]} onSubmit={handleSubmit}>
<div className={style["motive"]}>
<h1 className={style["heading"]}>Edit Broadcast</h1>
<div className={style["dash"]} />
<h1 className={
dark
? `${style["header-text"]} ${style["header-text-dark"]} `
: `${style["header-text"]} ${style["header-text-light"]}`
}>Edit Broadcast</h1>
<div className={
dark
? `${style.dash} ${style["dash-dark"]}`
: `${style.dash} ${style["dash-light"]}`
} />
</div>
<div>
<div className={style["form-control"]}>
<div className={
dark
? `${style["input"]} ${style["input-dark"]} `
: `${style["input"]} ${style["input-light"]}`
}>
<input
type="text"
name="title"
className={style["form-control-input"]}
// className={style["form-control-input"]}
placeholder="Title"
value={data.title}
onChange={handleInputChange}
Expand All @@ -71,7 +102,11 @@ export function Edit(props) {
</div>
</div>
<div>
<div className={style["form-control"]}>
<div className={
dark
? `${style["input"]} ${style["input-dark"]} `
: `${style["input"]} ${style["input-light"]}`
}>
<SunEditor
name="content"
placeholder="Description"
Expand All @@ -86,11 +121,14 @@ export function Edit(props) {
</div>
</div>
<div>
<div className={style["form-control"]}>
<div className={
dark
? `${style["input"]} ${style["input-dark"]} `
: `${style["input"]} ${style["input-light"]}`
}>
<input
type="text"
name="link"
className={style["form-control-input"]}
placeholder="Resource Link"
value={data.link}
onChange={handleInputChange}
Expand Down
Loading

0 comments on commit 7a8eb26

Please sign in to comment.