anything-llm/frontend/src/components/Sidebar/IndexCount.jsx
timothycarambat 27c58541bd inital commit
2023-06-03 19:28:07 -07:00

35 lines
1.0 KiB
JavaScript

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>
);
}