anything-llm/frontend/src/components/Sidebar/IndexCount.jsx

35 lines
1.0 KiB
React
Raw Normal View History

2023-06-04 04:28:07 +02:00
import pluralize from "pluralize";
import React, { useEffect, useState } from "react";
import System from "../../models/system";
import { numberWithCommas } from "../../utils/numbers";
export default function IndexCount() {
const [indexes, setIndexes] = useState(null);
useEffect(() => {
async function indexCount() {
setIndexes(await System.totalIndexes());
}
indexCount();
}, []);
if (indexes === null || indexes === 0) {
return (
<div className="flex w-full items-center justify-end gap-x-2">
<div className="flex items-center gap-x-1 px-2 rounded-full">
<p className="text-slate-400 leading-tight text-sm"></p>
</div>
</div>
);
}
return (
<div className="flex w-full items-center justify-end gap-x-2">
<div className="flex items-center gap-x-1 px-2 rounded-full">
<p className="text-slate-400 leading-tight text-sm">
{numberWithCommas(indexes)} {pluralize("index", indexes)}
</p>
</div>
</div>
);
}