refactored some code

This commit is contained in:
Jelaletdin12 committed 2026-06-04 11:42:19 +05:00
1 parent caae941346
commit b83f350c6b
33 files changed
+1031 -1402

No files matched your search

+8 -25
View File
@@ -2,12 +2,13 @@ import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
import { CheckCircle2, XCircle } from "lucide-react";
import { DeleteDialog } from "@/components/deleteDialog";
import { DataTable } from "@/components/dataTable";
import { DataTableToolbar } from "@/components/dataTableToolbar";
import { TableSearchInput } from "@/components/tableSearch";
import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useBranches, useDeleteBranch } from "@/features/branches/hooks/useBranches";
import type { Branch } from "@/features/branches/api/branchesApi";
@@ -118,29 +119,11 @@ export function BranchesListPage() {
id: "actions",
header: "",
cell: ({ row }) => (
<div className="flex items-center gap-2 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
onClick={() => navigate(`/settings/location/branches/${row.original.id}`)}
title={t("common.view", "Görmek")}
>
<Eye size={14} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
onClick={() => navigate(`/settings/location/branches/${row.original.id}/edit`)}
title={t("common.edit", "Üýtgetmek")}
>
<Pencil size={14} />
</button>
<button
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
onClick={() => setDeleteId(row.original.id)}
title={t("common.delete", "Öçürmek")}
>
<Trash2 size={14} />
</button>
</div>
<TableActions
onView={() => navigate(`/settings/location/branches/${row.original.id}`)}
onEdit={() => navigate(`/settings/location/branches/${row.original.id}/edit`)}
onDelete={() => setDeleteId(row.original.id)}
/>
),
enableSorting: false,
enableHiding: false,
@@ -164,7 +147,7 @@ export function BranchesListPage() {
<h1 className="text-2xl font-bold text-foreground">{t("branches.title", "Şahamçalar")}</h1>
</div>
</div>
<div className="flex flex-wrap items-center gap-3 justify-between">
<div className="flex items-center gap-3 justify-between">
<TableSearchInput
value={search}
onChange={(v) => {
@@ -2,12 +2,13 @@ import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
import { Eye, Pencil, Trash2, CheckCircle2, XCircle } from "lucide-react";
import { CheckCircle2, XCircle } from "lucide-react";
import { DeleteDialog } from "@/components/deleteDialog";
import { DataTable } from "@/components/dataTable";
import { DataTableToolbar } from "@/components/dataTableToolbar";
import { TableSearchInput } from "@/components/tableSearch";
import { CreateButton } from "@/components/createButton";
import { TableActions } from "@/components/tableActions";
import type { FilterField, ActiveFilter } from "@/components/dataTableToolbar";
import { useDistricts, useDeleteDistrict } from "@/features/districts/hooks/useDistricts";
import type { District } from "@/features/districts/api/districtsApi";
@@ -86,29 +87,11 @@ export function DistrictsListPage() {
id: "actions",
header: "",
cell: ({ row }) => (
<div className="flex items-center gap-2 justify-end">
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
onClick={() => navigate(`/settings/location/districts/${row.original.id}`)}
title={t("common.view", "Görmek")}
>
<Eye size={14} />
</button>
<button
className="p-1.5 rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
onClick={() => navigate(`/settings/location/districts/${row.original.id}/edit`)}
title={t("common.edit", "Üýtgetmek")}
>
<Pencil size={14} />
</button>
<button
className="p-1.5 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors"
onClick={() => setDeleteId(row.original.id)}
title={t("common.delete", "Öçürmek")}
>
<Trash2 size={14} />
</button>
</div>
<TableActions
onView={() => navigate(`/settings/location/districts/${row.original.id}`)}
onEdit={() => navigate(`/settings/location/districts/${row.original.id}/edit`)}
onDelete={() => setDeleteId(row.original.id)}
/>
),
enableSorting: false,
enableHiding: false,
@@ -132,7 +115,7 @@ export function DistrictsListPage() {
<h1 className="text-2xl font-bold text-foreground">{t("districts.title", "Etraplar")}</h1>
</div>
</div>
<div className="flex flex-wrap items-center gap-3 justify-between">
<div className="flex items-center gap-3 justify-between">
<TableSearchInput
value={search}
onChange={(v) => {