Merge branch 'main' of http://192.168.1.163:3000/inmake/graff-mate-client
This commit is contained in:
@@ -5,10 +5,11 @@ import SpinIcon from "../components/icons/SpinIcon";
|
||||
import MultySelect from "../components/MultySelect";
|
||||
import SearchInput from "../components/SearchInput";
|
||||
import { useState } from "react";
|
||||
import { useDebounce } from "@uidotdev/usehooks";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { User } from "../types/User";
|
||||
import { Client } from "../types/Client";
|
||||
import { useDebounce } from "@uidotdev/usehooks";
|
||||
import pluralize from "../utils/pluralize";
|
||||
|
||||
function ClientsPage() {
|
||||
const [limit, setLimit] = useState(10);
|
||||
@@ -42,6 +43,7 @@ function ClientsPage() {
|
||||
searchParams: debouncedSearch ? { search: debouncedSearch } : {},
|
||||
})
|
||||
.json<number>(),
|
||||
|
||||
enabled: !!me,
|
||||
});
|
||||
|
||||
@@ -80,7 +82,7 @@ function ClientsPage() {
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="caption-m font-medium opacity-40">
|
||||
Найдено {count} клиентов
|
||||
Найдено {count ? pluralize(count, "клиент") : "0 клиентов"}
|
||||
</p>
|
||||
<button className="flex gap-[0.278vw] items-center" onClick={reset}>
|
||||
<div className="size-[1.111vw] text-[#7D7D7D]">
|
||||
@@ -116,13 +118,13 @@ function ClientsPage() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{!!count && clients?.length === 0 && (
|
||||
{!!clients?.length && clients?.length === 0 && (
|
||||
<Button
|
||||
size="large"
|
||||
variant="primary"
|
||||
className="w-full"
|
||||
onClick={() => setLimit((prev) => prev + 10)}
|
||||
disabled={!!count && limit >= count}
|
||||
disabled={!!clients?.length && limit >= clients.length}
|
||||
>
|
||||
Показать еще
|
||||
</Button>
|
||||
|
||||
@@ -14,6 +14,7 @@ import Button from "../components/Button";
|
||||
import SearchInput from "../components/SearchInput";
|
||||
import CloseIcon from "../components/icons/CloseIcon";
|
||||
import SpinIcon from "../components/icons/SpinIcon";
|
||||
import pluralize from "../utils/pluralize";
|
||||
|
||||
function SessionsPage() {
|
||||
const [limit, setLimit] = useState(10);
|
||||
@@ -119,7 +120,7 @@ function SessionsPage() {
|
||||
</div>
|
||||
<div className="flex justify-between items-center">
|
||||
<p className="caption-m font-medium opacity-40">
|
||||
Найдено {count} сеансов
|
||||
Найдено {count ? pluralize(count, "сеанс") : "0 сеансов"}
|
||||
</p>
|
||||
<button className="flex gap-[0.278vw] items-center" onClick={reset}>
|
||||
<div className="size-[1.111vw] text-[#7D7D7D]">
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
function pluralize(count: number, word: "клиент" | "сеанс"): string {
|
||||
const cases = [2, 0, 1, 1, 1, 2];
|
||||
const index =
|
||||
count % 100 > 4 && count % 100 < 20
|
||||
? 2
|
||||
: cases[count % 10 < 5 ? count % 10 : 5];
|
||||
|
||||
const specialWords: Record<string, string[]> = {
|
||||
клиент: ["клиент", "клиента", "клиентов"],
|
||||
сеанс: ["сеанс", "сеанса", "сеансов"],
|
||||
};
|
||||
|
||||
return `${count} ${specialWords[word][index]}`;
|
||||
}
|
||||
|
||||
export default pluralize;
|
||||
Reference in New Issue
Block a user