🗒️ Added scaffold for the toast notification
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, { ReactElement } from "react";
|
import React, { ReactElement } from "react";
|
||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import { Navbar2 } from "./shared/Navbar2";
|
import { Navbar2 } from "./shared/Navbar2";
|
||||||
import {ToastContainer} from "react-toastify";
|
import { ToastContainer } from "react-toastify";
|
||||||
import "../assets/scss/App.scss";
|
import "../assets/scss/App.scss";
|
||||||
|
|
||||||
export const App = (): ReactElement => {
|
export const App = (): ReactElement => {
|
||||||
@@ -9,7 +9,7 @@ export const App = (): ReactElement => {
|
|||||||
<>
|
<>
|
||||||
<Navbar2 />
|
<Navbar2 />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
<ToastContainer />
|
<ToastContainer stacked hideProgressBar />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,8 +11,7 @@ import { useShallow } from "zustand/react/shallow";
|
|||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { AIRDCPP_SERVICE_BASE_URI } from "../../constants/endpoints";
|
import { AIRDCPP_SERVICE_BASE_URI } from "../../constants/endpoints";
|
||||||
import {toast} from "react-toastify";
|
|
||||||
import 'react-toastify/dist/ReactToastify.min.css';
|
|
||||||
|
|
||||||
interface IAcquisitionPanelProps {
|
interface IAcquisitionPanelProps {
|
||||||
query: any;
|
query: any;
|
||||||
@@ -78,7 +77,7 @@ export const AcquisitionPanel = (
|
|||||||
const { comicObjectId } = props;
|
const { comicObjectId } = props;
|
||||||
const issueName = props.query.issue.name || "";
|
const issueName = props.query.issue.name || "";
|
||||||
const sanitizedIssueName = issueName.replace(/[^a-zA-Z0-9 ]/g, " ");
|
const sanitizedIssueName = issueName.replace(/[^a-zA-Z0-9 ]/g, " ");
|
||||||
const notify = () => toast("Wow so easy !");
|
|
||||||
const [dcppQuery, setDcppQuery] = useState({});
|
const [dcppQuery, setDcppQuery] = useState({});
|
||||||
const [airDCPPSearchResults, setAirDCPPSearchResults] = useState<
|
const [airDCPPSearchResults, setAirDCPPSearchResults] = useState<
|
||||||
SearchResult[]
|
SearchResult[]
|
||||||
@@ -140,6 +139,7 @@ export const AcquisitionPanel = (
|
|||||||
});
|
});
|
||||||
|
|
||||||
socketIOInstance.on("searchResultUpdated", ({ updatedResult }: any) => {
|
socketIOInstance.on("searchResultUpdated", ({ updatedResult }: any) => {
|
||||||
|
console.log("endh");
|
||||||
// ...update properties of the existing result in the UI
|
// ...update properties of the existing result in the UI
|
||||||
const bundleToUpdateIndex = airDCPPSearchResults?.findIndex(
|
const bundleToUpdateIndex = airDCPPSearchResults?.findIndex(
|
||||||
(bundle) => bundle.result.id === updatedResult.result.id,
|
(bundle) => bundle.result.id === updatedResult.result.id,
|
||||||
@@ -208,7 +208,6 @@ export const AcquisitionPanel = (
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<button onClick={notify}>Notify !</button>
|
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
{!isEmpty(hubs?.data) ? (
|
{!isEmpty(hubs?.data) ? (
|
||||||
<Form
|
<Form
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import io from "socket.io-client";
|
|||||||
import { SOCKET_BASE_URI } from "../constants/endpoints";
|
import { SOCKET_BASE_URI } from "../constants/endpoints";
|
||||||
import { produce } from "immer";
|
import { produce } from "immer";
|
||||||
import { QueryClient } from "@tanstack/react-query";
|
import { QueryClient } from "@tanstack/react-query";
|
||||||
|
import { toast } from "react-toastify";
|
||||||
|
import "react-toastify/dist/ReactToastify.min.css";
|
||||||
|
|
||||||
/* Broadly, this file sets up:
|
/* Broadly, this file sets up:
|
||||||
* 1. The zustand-based global client state
|
* 1. The zustand-based global client state
|
||||||
@@ -83,6 +84,7 @@ if (!isNil(sessionId)) {
|
|||||||
"call",
|
"call",
|
||||||
"socket.resumeSession",
|
"socket.resumeSession",
|
||||||
{
|
{
|
||||||
|
namespace: "/",
|
||||||
sessionId,
|
sessionId,
|
||||||
},
|
},
|
||||||
(data) => console.log(data),
|
(data) => console.log(data),
|
||||||
@@ -131,7 +133,8 @@ socketIOInstance.on("LS_COVER_EXTRACTION_FAILED", (data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socketIOInstance.on("searchResultsAvailable", (data) => {
|
socketIOInstance.on("searchResultsAvailable", (data) => {
|
||||||
console.log(data);
|
const results = Object.keys(data?.results).length;
|
||||||
|
toast(`${results} results found for query: ${data.query}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 1b. Clear the localStorage sessionId upon receiving the
|
// 1b. Clear the localStorage sessionId upon receiving the
|
||||||
|
|||||||
Reference in New Issue
Block a user