2023-08-18 20:46:32 +02:00
|
|
|
import React from "react";
|
2023-06-08 12:06:43 +02:00
|
|
|
import { useAccountComment } from "@plebbit/plebbit-react-hooks";
|
2023-06-01 17:24:44 +02:00
|
|
|
import useStateString from "../hooks/useStateString";
|
2023-06-01 10:43:17 +02:00
|
|
|
|
2023-06-08 22:23:58 +02:00
|
|
|
const StateLabel = ({ commentIndex, className }) => {
|
|
|
|
|
const comment = useAccountComment({commentIndex: commentIndex});
|
2023-06-01 17:24:44 +02:00
|
|
|
const stateString = useStateString(comment);
|
2023-06-01 10:43:17 +02:00
|
|
|
|
2023-08-21 17:35:40 +02:00
|
|
|
if (comment.updatedAt !== undefined || comment.index === undefined) {
|
2023-08-18 20:46:32 +02:00
|
|
|
return null;
|
|
|
|
|
}
|
2023-06-08 22:23:58 +02:00
|
|
|
|
2023-08-21 17:35:40 +02:00
|
|
|
if (comment.state === "failed" || comment.state === "succeeded") {
|
2023-08-18 20:46:32 +02:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!stateString) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-06-08 22:23:58 +02:00
|
|
|
|
2023-06-01 10:43:17 +02:00
|
|
|
return (
|
2023-08-18 20:46:32 +02:00
|
|
|
<span className="ttl">
|
|
|
|
|
<br />
|
|
|
|
|
(
|
|
|
|
|
<span className={className}>
|
|
|
|
|
{stateString}
|
2023-06-08 22:23:58 +02:00
|
|
|
</span>
|
2023-08-18 20:46:32 +02:00
|
|
|
)
|
|
|
|
|
</span>
|
2023-06-08 12:06:43 +02:00
|
|
|
);
|
2023-06-01 10:43:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default StateLabel;
|