added state updating after removing an event

This commit is contained in:
mmacierzanka committed 2021-10-07 20:58:31 +02:00
1 parent d256925d25
commit 44dcac4c61
2 files changed
+8 -5

No files matched your search

@@ -33,12 +33,10 @@ export const EventPreviewEdit = (props) => {
</div>
<div className="d-flex justify-content-between align-items-center ">
<span className={styles.time}>
<BIcon icon="calendar" />
{`${getDate(props.data.time)} ${getTime(props.data.time)}` ?? ""}
<BIcon icon="calendar" /> {`${getDate(props.data.time)} ${getTime(props.data.time)}` ?? ""}
</span>
<span className={styles.location}>
<BIcon icon="geo-alt-fill" />
{props.data.address?.split(", ").splice(0, 2).join(", ")}
<BIcon icon="geo-alt-fill" /> {props.data.address?.split(", ").splice(0, 2).join(", ")}
</span>
</div>
<div className="d-flex justify-content-between align-items-center ">
+6 -1
View File
@@ -24,8 +24,13 @@ export class APIClient extends EventEmitter {
}
async deleteEvent(item) {
const rq = await axios.post(`${this.#dbUrl}/api/deleteEvent`,item);
const rq = await axios.post(`${this.#dbUrl}/api/deleteEvent`, item);
if (rq.status !== 200) throw new Error(`Request failed with status code ${rq.status}: ${rq.statusText}`);
this.#events.splice(
this.#events.findIndex((e) => e._id === item.id),
1
);
this.emit("EVENT_CREATE", this.#events, rq.data);
return rq.data;
}