rofactored edit and create pages
This commit is contained in:
1 parent
2f13d424e1
commit
4adc153503
79 files changed
+1663
-2333
No files matched your search
@@ -1,16 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardBalanceForm } from '@/features/cardBalance/components/cardBalanceForm'
|
||||
|
||||
export default function CardBalanceCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">
|
||||
{t('Create card balance', 'Kart galyndysy dörediň')}
|
||||
</h1>
|
||||
|
||||
<CardBalanceForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <CardBalanceForm mode="create" />
|
||||
}
|
||||
@@ -1,47 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardBalanceForm } from '@/features/cardBalance/components/cardBalanceForm'
|
||||
import { useCardBalance } from '@/features/cardBalance/hooks/useCardBalance'
|
||||
|
||||
|
||||
export default function CardBalanceEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading } = useCardBalance(numericId)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="space-y-4 max-w-3xl">
|
||||
<Skeleton className="h-8 w-48" />
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-10 w-full" />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t('Not found', 'Tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">
|
||||
{t('Edit card balance', 'Kart galyndysyny düzetmek')}:{' '}
|
||||
<span className="text-primary font-mono">{data.id}</span>
|
||||
</h1>
|
||||
|
||||
<CardBalanceForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
cardBalanceId={numericId}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return <CardBalanceForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,23 +1,5 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { CardPinForm } from '@/features/cardPins/components/cardPinForm'
|
||||
import { useCreateCardPin } from '@/features/cardPins/hooks/useCardPins'
|
||||
import type { CardPinCreatePayload } from '@/features/cardPins/api/cardPinApi'
|
||||
|
||||
export default function CardPinCreatePage() {
|
||||
const navigate = useNavigate()
|
||||
const { mutate: createPin, isPending } = useCreateCardPin()
|
||||
|
||||
const handleSubmit = (payload: CardPinCreatePayload) => {
|
||||
createPin(payload, {
|
||||
onSuccess: (data) => navigate(`/card-pins/${data.id}`),
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<CardPinForm
|
||||
mode="create"
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={isPending}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return <CardPinForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,17 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardPinForm } from '@/features/cardPins/components/cardPinForm'
|
||||
import { useCardPin, useUpdateCardPin } from '@/features/cardPins/hooks/useCardPins'
|
||||
import type { CardPinUpdatePayload } from '@/features/cardPins/api/cardPinApi'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { useCardPin } from '@/features/cardPins/hooks/useCardPins'
|
||||
|
||||
export default function CardPinEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { data, isLoading, isError } = useCardPin(id ?? '')
|
||||
|
||||
const { data, isLoading, isError } = useCardPin(id!)
|
||||
const { mutate: updatePin, isPending } = useUpdateCardPin(id!)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Maglumat tapylmady')} />
|
||||
|
||||
const handleSubmit = (payload: CardPinUpdatePayload) => {
|
||||
updatePin(payload, {
|
||||
onSuccess: () => navigate(`/card-pins/${id}`),
|
||||
})
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-8 text-primary" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<CardPinForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={isPending}
|
||||
/>
|
||||
)
|
||||
}
|
||||
return <CardPinForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardRequisiteForm } from '@/features/cardRequisites/components/cardRequisiteForm'
|
||||
|
||||
export default function CardRequisiteCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Create card requisite order', 'Kart rekwiziti üçin sargyt dörediň dörediň')}
|
||||
</h1>
|
||||
<CardRequisiteForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <CardRequisiteForm mode="create" />
|
||||
}
|
||||
@@ -1,41 +1,17 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardRequisiteForm } from '@/features/cardRequisites/components/cardRequisiteForm'
|
||||
import { useCardRequisite } from '@/features/cardRequisites/hooks/useCardRequisites'
|
||||
|
||||
export default function CardRequisiteEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
|
||||
const { t } = useTranslation()
|
||||
const { data, isLoading } = useCardRequisite(id ?? '')
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t('Not found', 'Tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Edit card requisite', 'Kart rekwizitini üýtget')}
|
||||
</h1>
|
||||
<CardRequisiteForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
cardRequisiteId={data.id}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
return <CardRequisiteForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardTransactionForm } from '@/features/cardTransactions/components/cardTransactionForm'
|
||||
|
||||
export default function CardTransactionCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('Create card transaction', 'Kart herekedi dörediň')}
|
||||
</h1>
|
||||
<CardTransactionForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <CardTransactionForm mode="create" />
|
||||
}
|
||||
@@ -1,42 +1,18 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { CardTransactionForm } from "@/features/cardTransactions/components/cardTransactionForm";
|
||||
import { useCardTransaction } from "@/features/cardTransactions/hooks/useCardTransactions";
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardTransactionForm } from '@/features/cardTransactions/components/cardTransactionForm'
|
||||
import { useCardTransaction } from '@/features/cardTransactions/hooks/useCardTransactions'
|
||||
|
||||
export default function CardTransactionEditPage() {
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const numericId = Number(id);
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading } = useCardTransaction(numericId)
|
||||
|
||||
const { data, isLoading } = useCardTransaction(numericId);
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-7 text-primary" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="text-center py-24 text-muted-foreground">
|
||||
{t("Not found", "Tapylmady")}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("Edit card transaction", "Kart herekedini üýtget")}
|
||||
</h1>
|
||||
<CardTransactionForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
cardTransactionId={numericId}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
return <CardTransactionForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,24 +1,5 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardOrderForm } from '@/features/orderNewCard/components/orderNewCardForm'
|
||||
|
||||
|
||||
export default function CardOrderCreatePage() {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">
|
||||
{t('cardOrder.createTitle', 'Kart sargyt dörediň')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<CardOrderForm
|
||||
mode="create"
|
||||
onSuccess={() => navigate('/order-new-card')}
|
||||
onCancel={() => navigate('/order-new-card')}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <CardOrderForm mode="create" />
|
||||
}
|
||||
@@ -1,51 +1,17 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
import { CardOrderForm } from '@/features/orderNewCard/components/orderNewCardForm'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardOrderForm } from '@/features/orderNewCard/components/orderNewCardForm'
|
||||
import { useCardOrderById } from '@/features/orderNewCard/hooks/useOrderNewCard'
|
||||
|
||||
|
||||
export default function CardOrderEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const { data: order, isLoading } = useCardOrderById(id ?? '')
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="space-y-4 max-w-3xl">
|
||||
<Skeleton className="h-8 w-48" />
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<Skeleton key={i} className="h-10 w-full" />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!order) {
|
||||
return (
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{t('common.notFound', 'Tapylmady')}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-xl font-semibold text-foreground tracking-tight">
|
||||
{t('cardOrder.editTitle', 'Düzetmek')}:{' '}
|
||||
<span className="text-primary font-mono">{order.id}</span>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<CardOrderForm
|
||||
mode="edit"
|
||||
initialData={order}
|
||||
cardOrderId={id}
|
||||
onSuccess={() => navigate(`/order-new-card/${id}`)}
|
||||
onCancel={() => navigate(`/order-new-card/${id}`)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!order) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return <CardOrderForm mode="edit" initialData={order} />
|
||||
}
|
||||
@@ -1,23 +1,5 @@
|
||||
// pages/CurrencyRateCreatePage.tsx
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CurrencyRateForm } from '@/features/currencyRates/components/currencyRatesForm'
|
||||
|
||||
// ─── CurrencyRateCreatePage ───────────────────────────────────────────────────
|
||||
|
||||
export default function CurrencyRateCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('currencyRates.actions.create', 'Walýuta kursy dörediň')}
|
||||
</h1>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
<CurrencyRateForm mode="create" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <CurrencyRateForm mode="create" />
|
||||
}
|
||||
@@ -1,57 +1,18 @@
|
||||
// pages/CurrencyRateEditPage.tsx
|
||||
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CurrencyRateForm } from '@/features/currencyRates/components/currencyRatesForm'
|
||||
import { useGetCurrencyRateById } from '@/features/currencyRates/hooks/useCurrencyRates'
|
||||
|
||||
// ─── CurrencyRateEditPage ─────────────────────────────────────────────────────
|
||||
|
||||
export default function CurrencyRateEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data: rate, isLoading } = useGetCurrencyRateById(numericId)
|
||||
|
||||
// ─── Loading skeleton ──────────────────────────────────────────────────────
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!rate) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="h-6 w-64 bg-muted rounded animate-pulse" />
|
||||
<div className="h-48 bg-muted rounded-xl animate-pulse" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!rate) {
|
||||
return (
|
||||
<div>
|
||||
<p className="text-muted-foreground">
|
||||
{t('currencyRates.notFound', 'Walýuta kursy tapylmady')}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
|
||||
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('currencyRates.detail.editTitle', 'Walýuta kursyny üýtgetmek')}: {rate.id}
|
||||
</h1>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
<CurrencyRateForm
|
||||
mode="edit"
|
||||
initialData={rate}
|
||||
rateId={numericId}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <CurrencyRateForm mode="edit" initialData={rate} />
|
||||
}
|
||||
@@ -1,24 +1,5 @@
|
||||
// pages/VisaMasterSettingCreatePage.tsx
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { VisaMasterSettingForm } from '@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm'
|
||||
|
||||
// ─── VisaMasterSettingCreatePage ──────────────────────────────────────────────
|
||||
|
||||
export default function VisaMasterSettingCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('visaMasterSettings.actions.create', 'Visa/Master, Sber sazlamalar dörediň')}
|
||||
</h1>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
<VisaMasterSettingForm mode="create" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <VisaMasterSettingForm mode="create" />
|
||||
}
|
||||
@@ -1,57 +1,18 @@
|
||||
// pages/VisaMasterSettingEditPage.tsx
|
||||
|
||||
import {useParams } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { VisaMasterSettingForm } from '@/features/visaMasterSberSettings/components/visaMasterSberSettingsForm'
|
||||
import { useGetVisaMasterSettingById } from '@/features/visaMasterSberSettings/hooks/useVisaMasterSettings'
|
||||
|
||||
// ─── VisaMasterSettingEditPage ────────────────────────────────────────────────
|
||||
|
||||
export default function VisaMasterSettingEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data: setting, isLoading } = useGetVisaMasterSettingById(numericId)
|
||||
|
||||
// ─── Loading skeleton ──────────────────────────────────────────────────────
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!setting) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="p-6 space-y-4">
|
||||
<div className="h-6 w-72 bg-muted rounded animate-pulse" />
|
||||
<div className="h-56 bg-muted rounded-xl animate-pulse" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!setting) {
|
||||
return (
|
||||
<div className="p-6">
|
||||
<p className="text-muted-foreground">
|
||||
{t('visaMasterSettings.notFound', 'Sazlama tapylmady')}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
// ─── Render ───────────────────────────────────────────────────────────────
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('visaMasterSettings.detail.editTitle', 'Sazlamany üýtgetmek')}: {setting.id}
|
||||
</h1>
|
||||
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
<VisaMasterSettingForm
|
||||
mode="edit"
|
||||
initialData={setting}
|
||||
settingId={numericId}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <VisaMasterSettingForm mode="edit" initialData={setting} />
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
|
||||
import { SberPaymentForm } from '@/features/sberPayments/components/sberPaymentsForm'
|
||||
|
||||
export default function SberPaymentCreatePage() {
|
||||
return (
|
||||
<div>
|
||||
<SberPaymentForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <SberPaymentForm mode="create" />
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { SberPaymentForm } from '@/features/sberPayments/components/sberPaymentsForm'
|
||||
import { useSberPaymentOrder } from '@/features/sberPayments/hooks/useSberPayments'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
|
||||
export default function SberPaymentEditPage() {
|
||||
const params = useParams()
|
||||
const id = params.id as string
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Spinner className="w-8 h-8" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-foreground mb-6">
|
||||
{t('sberPayments.formTitle.edit', 'Sber töleg redaktirläň')}: {id}
|
||||
</h1>
|
||||
<SberPaymentForm mode="edit" initialData={order} orderId={id} />
|
||||
</div>
|
||||
)
|
||||
const { data: order, isLoading } = useSberPaymentOrder(id ?? '')
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!order) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return <SberPaymentForm mode="edit" initialData={order} />
|
||||
}
|
||||
@@ -1,23 +1,5 @@
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { IntlPaymentForm } from '@/features/visaMasterPayments/components/intlPaymentForm'
|
||||
import { useCreateIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||
import type { IntlPaymentCreatePayload } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
|
||||
export default function IntlPaymentCreatePage() {
|
||||
const navigate = useNavigate()
|
||||
const { mutate: createPayment, isPending } = useCreateIntlPayment()
|
||||
|
||||
const handleSubmit = (payload: IntlPaymentCreatePayload) => {
|
||||
createPayment(payload, {
|
||||
onSuccess: (data) => navigate(`/intl-payments/visa-master/${data.id}`),
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<IntlPaymentForm
|
||||
mode="create"
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={isPending}
|
||||
/>
|
||||
)
|
||||
return <IntlPaymentForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,17 @@
|
||||
import { useParams, useNavigate } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { IntlPaymentForm } from '@/features/visaMasterPayments/components/intlPaymentForm'
|
||||
import { useIntlPayment, useUpdateIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||
import type { IntlPaymentUpdatePayload } from '@/features/visaMasterPayments/api/visaMasterPaymentsApi'
|
||||
import { Spinner } from '@/components/ui/spinner'
|
||||
import { useIntlPayment } from '@/features/visaMasterPayments/hooks/useVisaMasterPayments'
|
||||
|
||||
export default function IntlPaymentEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation()
|
||||
const { data, isLoading, isError } = useIntlPayment(id ?? '')
|
||||
|
||||
const { data, isLoading, isError } = useIntlPayment(id!)
|
||||
const { mutate: updatePayment, isPending } = useUpdateIntlPayment(id!)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Maglumat tapylmady')} />
|
||||
|
||||
const handleSubmit = (payload: IntlPaymentUpdatePayload) => {
|
||||
updatePayment(payload, {
|
||||
onSuccess: () => navigate(`/intl-payments/visa-master/${id}`),
|
||||
})
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24">
|
||||
<Spinner className="size-8 text-primary" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-24 text-muted-foreground">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<IntlPaymentForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={isPending}
|
||||
/>
|
||||
)
|
||||
return <IntlPaymentForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,29 +1,17 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { PageSpinner } from "@/components/pageSpinner";
|
||||
import { PageError } from "@/components/pageError";
|
||||
import { LoanOrderForm } from "@/features/loanOrders/components/loanOrderForm";
|
||||
import { useLoanOrderById } from "@/features/loanOrders/hooks/useLoanOrders";
|
||||
|
||||
export default function LoanOrderEditPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { t } = useTranslation();
|
||||
const { data, isLoading, isError } = useLoanOrderById(id ?? "");
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Loader2 className="animate-spin text-muted-foreground" size={32} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (isLoading) return <PageSpinner />;
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Maglumat ýüklenilmedi')} />;
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<p className="text-sm text-destructive">
|
||||
Maglumat ýüklenilmedi. Sahypany täzeleläň.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return <LoanOrderForm mode="edit" initialData={data} loanOrderId={id} />;
|
||||
return <LoanOrderForm mode="edit" initialData={data} />;
|
||||
}
|
||||
@@ -1,31 +1,17 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { PageSpinner } from "@/components/pageSpinner";
|
||||
import { PageError } from "@/components/pageError";
|
||||
import { LoanOrderMobileForm } from "@/features/loanOrderMobiles/components/loanOrderMobileForm";
|
||||
import { useLoanOrderMobileById } from "@/features/loanOrderMobiles/hooks/useLoanOrderMobiles";
|
||||
|
||||
export default function LoanOrderMobilesEditPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { t } = useTranslation();
|
||||
const { data, isLoading, isError } = useLoanOrderMobileById(id ?? "");
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Loader2 className="animate-spin text-muted-foreground" size={32} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (isLoading) return <PageSpinner />;
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Maglumat ýüklenilmedi')} />;
|
||||
|
||||
if (isError || !data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<p className="text-sm text-destructive">
|
||||
Maglumat ýüklenilmedi. Sahypany täzeleläň.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<LoanOrderMobileForm mode="edit" initialData={data} loanOrderId={id} />
|
||||
);
|
||||
return <LoanOrderMobileForm mode="edit" initialData={data} />;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState, useMemo, useCallback } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Eye, Pencil, Trash2, TableProperties } from "lucide-react";
|
||||
import type { ColumnDef, VisibilityState } from "@tanstack/react-table";
|
||||
@@ -41,6 +42,7 @@ function EmptyState({ onCreate }: { onCreate: () => void }) {
|
||||
|
||||
export default function LoanPaidOffLettersPage() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
const [deleteId, setDeleteId] = useState<number | null>(null);
|
||||
|
||||
@@ -81,8 +83,8 @@ export default function LoanPaidOffLettersPage() {
|
||||
}, [deleteId, deleteMutation]);
|
||||
|
||||
const handleCreate = useCallback(() => {
|
||||
// navigate to create page or open modal
|
||||
}, []);
|
||||
navigate("/loan-paid-off-letters/create");
|
||||
}, [navigate]);
|
||||
|
||||
// ── Columns ────────────────────────────────────────────────────────────────
|
||||
const columns = useMemo<ColumnDef<LoanPaidOffLetter>[]>(
|
||||
@@ -128,12 +130,14 @@ export default function LoanPaidOffLettersPage() {
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-1.5 justify-end">
|
||||
<button
|
||||
onClick={() => navigate(`/loan-paid-off-letters/${row.original.id}`)}
|
||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.view", "Görmek")}
|
||||
>
|
||||
<Eye size={15} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-paid-off-letters/${row.original.id}/edit`)}
|
||||
className="p-1.5 cursor-pointer rounded hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Üýtgetmek")}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { LoanPaidOffLetterForm } from '@/features/loanPaidOffLetters/components/LoanPaidOffLetterForm'
|
||||
|
||||
export default function LoanPaidOffLettersCreatePage() {
|
||||
return <LoanPaidOffLetterForm mode="create" />
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { LoanPaidOffLetterForm } from '@/features/loanPaidOffLetters/components/LoanPaidOffLetterForm'
|
||||
import { useLoanPaidOffLetterById } from '@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters'
|
||||
|
||||
export default function LoanPaidOffLettersEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
|
||||
const { data, isLoading } = useLoanPaidOffLetterById(id)
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return <LoanPaidOffLetterForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import { useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Trash2, Pencil } from "lucide-react";
|
||||
import {
|
||||
useLoanPaidOffLetterById,
|
||||
useDeleteLoanPaidOffLetter,
|
||||
} from "@/features/loanPaidOffLetters/hooks/useLoanPaidOffLetters";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { InfoRow, Section } from "@/components/viewPageComponents";
|
||||
import { ConfirmDialog } from "@/components/confirmDialog";
|
||||
|
||||
function LoanPaidOffLetterViewSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-7 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl p-4 flex flex-col gap-3">
|
||||
{[...Array(5)].map((_, j) => (
|
||||
<Skeleton key={j} className="h-4 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function LoanPaidOffLettersViewPage() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const deleteMutation = useDeleteLoanPaidOffLetter();
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
|
||||
const { data: record, isLoading } = useLoanPaidOffLetterById(id!);
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteMutation.mutate(Number(id!), {
|
||||
onSuccess: () => navigate("/loan-paid-off-letters"),
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) return <LoanPaidOffLetterViewSkeleton />;
|
||||
|
||||
if (!record) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground text-sm">
|
||||
{t("common.notFound", "Tapylmady")}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<div className="flex items-center justify-between mb-5">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t("loanPaidOffLetters.view.title", "Güwanama maglumaty")}:{" "}
|
||||
{record.id}
|
||||
</h1>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<button
|
||||
onClick={() => setShowDeleteDialog(true)}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
|
||||
title={t("common.delete", "Poz")}
|
||||
>
|
||||
<Trash2 size={16} />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => navigate(`/loan-paid-off-letters/${record.id}/edit`)}
|
||||
className="p-2 rounded-md cursor-pointer hover:bg-muted/60 text-muted-foreground hover:text-foreground transition-colors"
|
||||
title={t("common.edit", "Redaktirle")}
|
||||
>
|
||||
<Pencil size={16} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Section title={t("loanPaidOffLetters.sections.info", "Esasy maglumatlar")}>
|
||||
<InfoRow label={t("common.id", "ID")} value={String(record.id)} />
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.passportSeries", "Pasport seriýasy")}
|
||||
value={record.passportSeries}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.passportNumber", "Pasport belgisi")}
|
||||
value={record.passportNumber}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.loanAccount", "Karz hasaby")}
|
||||
value={record.loanAccount}
|
||||
/>
|
||||
<InfoRow
|
||||
label={t("loanPaidOffLetters.columns.issuedAt", "Berlen wagty")}
|
||||
value={record.issuedAt}
|
||||
/>
|
||||
</Section>
|
||||
|
||||
<ConfirmDialog
|
||||
open={showDeleteDialog}
|
||||
onOpenChange={setShowDeleteDialog}
|
||||
title={t("loanPaidOffLetters.deleteConfirm", "Bu ýazgy pozulsynmy?")}
|
||||
confirmLabel={t("common.delete", "Poz")}
|
||||
onConfirm={confirmDelete}
|
||||
isLoading={deleteMutation.isPending}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoanRemainingForm } from '@/features/loanRemaining/components/LoanRemainingForm'
|
||||
|
||||
export default function LoanRemainingCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('loanRemaining.create.title', 'Täze karz galyndysy')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<LoanRemainingForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <LoanRemainingForm mode="create" />
|
||||
}
|
||||
@@ -1,19 +1,9 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { LoanRemainingForm } from '@/features/loanRemaining/components/LoanRemainingForm'
|
||||
import { useLoanRemainingById } from '@/features/loanRemaining/hooks/useLoanRemaining'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
function LoanRemainingEditSkeleton() {
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<Skeleton className="h-8 w-64" />
|
||||
<div className="bg-card border border-border rounded-xl p-6 h-[250px]">
|
||||
<Skeleton className="h-full w-full" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function LoanRemainingEditPage() {
|
||||
const { t } = useTranslation()
|
||||
@@ -21,25 +11,8 @@ export default function LoanRemainingEditPage() {
|
||||
|
||||
const { data, isLoading } = useLoanRemainingById(id)
|
||||
|
||||
if (isLoading) return <LoanRemainingEditSkeleton />
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-64 text-muted-foreground">
|
||||
{t('common.notFound', 'Tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-xl font-semibold text-foreground">
|
||||
{t('loanRemaining.edit.title', 'Karz galyndysyny üýtget')}: {data.id}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<LoanRemainingForm mode="edit" initialData={data} loanRemainingId={id} />
|
||||
</div>
|
||||
)
|
||||
return <LoanRemainingForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,20 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardTypeForm } from '@/features/cardTypes/components/cardTypesForm'
|
||||
|
||||
export default function CardTypeCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div className="mb-6">
|
||||
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('cardTypes.create.title', 'Kart görnüşi döretmek')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<CardTypeForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <CardTypeForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardTypeForm } from '@/features/cardTypes/components/cardTypesForm'
|
||||
import { useCardTypeById } from '@/features/cardTypes/hooks/useCardTypes'
|
||||
|
||||
export default function CardTypeEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading, isError } = useCardTypeById(numericId)
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div className="mb-6">
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{isLoading
|
||||
? '...'
|
||||
: `${t('cardTypes.edit.title', 'Kart görnüşini üýtgetmek')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-3 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-8 w-full bg-muted rounded animate-pulse" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError || !data ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<CardTypeForm mode="edit" initialData={data} cardTypeId={numericId} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
return <CardTypeForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,21 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { CardReasonForm } from '@/features/cardReasons/components/reasonForm'
|
||||
|
||||
export function CardReasonCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div className="mb-6">
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('CardReasons.create.title', 'Kartyň çykarylmagynyň sebäbi dörediň')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<CardReasonForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
export default function CardReasonCreatePage() {
|
||||
return <CardReasonForm mode="create" />
|
||||
}
|
||||
|
||||
export default CardReasonCreatePage
|
||||
@@ -1,49 +1,18 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { CardReasonForm } from "@/features/cardReasons/components/reasonForm";
|
||||
import { useCardReasonById } from "@/features/cardReasons/hooks/useCardReasons";
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { CardReasonForm } from '@/features/cardReasons/components/reasonForm'
|
||||
import { useCardReasonById } from '@/features/cardReasons/hooks/useCardReasons'
|
||||
|
||||
// ─── CardReasonEditPage ────────────────────────────────────────────────────────
|
||||
export default function CardReasonEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading } = useCardReasonById(numericId)
|
||||
|
||||
export function CardReasonEditPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const { t } = useTranslation();
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading } = useCardReasonById(numericId);
|
||||
|
||||
return (
|
||||
<div className="p-6">
|
||||
<div className="mb-6">
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{isLoading
|
||||
? "..."
|
||||
: `${t("CardReasons.edit.title", "Kartyň çykarylmagynyň sebäbini üýtgetmek")}: ${data?.name.tk ?? ""}`}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 4 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-3 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-8 w-full bg-muted rounded animate-pulse" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<CardReasonForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
CardReasonId={numericId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
return <CardReasonForm mode="edit" initialData={data} />
|
||||
}
|
||||
|
||||
export default CardReasonEditPage
|
||||
@@ -1,20 +1,5 @@
|
||||
// pages/LoanTypeCreatePage.tsx
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { LoanTypeForm } from '@/features/loanTypes/components/loanTypesForm'
|
||||
|
||||
export default function LoanTypeCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{t('loanTypes.actions.create', 'Karz görnüşi dörediň')}
|
||||
</h1>
|
||||
|
||||
<LoanTypeForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <LoanTypeForm mode="create" />
|
||||
}
|
||||
@@ -1,47 +1,18 @@
|
||||
// pages/LoanTypeEditPage.tsx
|
||||
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { LoanTypeForm } from '@/features/loanTypes/components/loanTypesForm'
|
||||
import { useGetLoanTypeById } from '@/features/loanTypes/hooks/useLoanTypes'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function LoanTypeEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const loanTypeId = Number(id)
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading, isError } = useGetLoanTypeById(numericId)
|
||||
|
||||
const { data, isLoading, isError } = useGetLoanTypeById(loanTypeId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{isLoading
|
||||
? t('common.loading', 'Ýüklenýär...')
|
||||
: `${t('loanTypes.editTitle', 'Karz görnüşi redaktirle')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center px-4 py-3">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-8 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<LoanTypeForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
loanTypeId={loanTypeId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <LoanTypeForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,16 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RequiredDocumentForm } from '@/features/requiredDocuments/components/requiredDocumentsForm'
|
||||
|
||||
export default function RequiredDocumentsCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{t('loanDocuments.createBtn', 'Karz gerekli resminamalary dörediň')}
|
||||
</h1>
|
||||
|
||||
<RequiredDocumentForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <RequiredDocumentForm mode="create" />
|
||||
}
|
||||
@@ -1,47 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { RequiredDocumentForm } from '@/features/requiredDocuments/components/requiredDocumentsForm'
|
||||
import { useGetRequiredDocumentById } from '@/features/requiredDocuments/hooks/useRequiredDocuments'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function RequiredDocumentsEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const documentId = Number(id)
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading, isError } = useGetRequiredDocumentById(numericId)
|
||||
|
||||
const { data, isLoading, isError } = useGetRequiredDocumentById(documentId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return (
|
||||
<div >
|
||||
<h1 className="text-xl font-semibold text-foreground mb-5">
|
||||
{isLoading
|
||||
? t('common.loading', 'Ýüklenýär...')
|
||||
: `${t('loanDocuments.editTitle', 'Karz gerekli resminamalary redaktirle')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 2 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-start px-4 py-4">
|
||||
<Skeleton className="h-4 w-24 mt-2" />
|
||||
<div>
|
||||
<Skeleton className="h-10 w-full mb-2" />
|
||||
<Skeleton className="h-32 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<RequiredDocumentForm
|
||||
mode="edit"
|
||||
initialData={data}
|
||||
requiredDocumentId={documentId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
return <RequiredDocumentForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,20 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { BranchForm } from '@/features/branches/components/branchesForm'
|
||||
|
||||
export default function BranchCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div >
|
||||
<div className="mb-6">
|
||||
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('branches.create.title', 'Şahamça döretmek')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<BranchForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <BranchForm mode="create" />
|
||||
}
|
||||
@@ -1,40 +1,18 @@
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { PageSpinner } from "@/components/pageSpinner";
|
||||
import { PageError } from "@/components/pageError";
|
||||
import { BranchForm } from "@/features/branches/components/branchesForm";
|
||||
import { useBranchById } from "@/features/branches/hooks/useBranches";
|
||||
import { Loader2 } from "lucide-react";
|
||||
|
||||
export default function BranchEditPage() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const numericId = Number(id);
|
||||
const { data, isLoading, isError } = useBranchById(numericId);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{isLoading
|
||||
? "..."
|
||||
: `${t("branches.edit.title", "Şahamçany üýtgetmek")}: ${data?.name.tk ?? ""}`}
|
||||
</h1>
|
||||
</div>
|
||||
if (isLoading) return <PageSpinner />;
|
||||
if (isError || !data) return <PageError message={t("common.error", "Maglumat ýüklenilmedi")} />;
|
||||
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<Loader2 className="animate-spin text-muted-foreground" size={32} />
|
||||
</div>
|
||||
) : isError || !data ? (
|
||||
<div className="flex items-center justify-center min-h-[400px]">
|
||||
<p className="text-sm text-destructive">
|
||||
{t("common.error", "Maglumat ýüklenilmedi. Sahypany täzeleläň.")}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<BranchForm mode="edit" initialData={data} branchId={numericId} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
return <BranchForm mode="edit" initialData={data} />;
|
||||
}
|
||||
@@ -1,20 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { DistrictForm } from '@/features/districts/components/districtsForm'
|
||||
|
||||
export default function DistrictCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div >
|
||||
<div className="mb-6">
|
||||
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('districts.create.title', 'Etrap döretmek')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<DistrictForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <DistrictForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { DistrictForm } from '@/features/districts/components/districtsForm'
|
||||
import { useDistrictById } from '@/features/districts/hooks/useDistricts'
|
||||
|
||||
export default function DistrictEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const { t } = useTranslation()
|
||||
|
||||
const numericId = Number(id)
|
||||
const { data, isLoading, isError } = useDistrictById(numericId)
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="mb-6">
|
||||
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !data) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{isLoading
|
||||
? '...'
|
||||
: `${t('districts.edit.title', 'Etrapy üýtgetmek')}: ${data?.name.tk ?? ''}`}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="grid grid-cols-[220px_1fr] items-center py-3 px-4 border-b border-border last:border-0"
|
||||
>
|
||||
<div className="h-4 w-24 bg-muted rounded animate-pulse" />
|
||||
<div className="h-8 w-full bg-muted rounded animate-pulse" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : isError || !data ? (
|
||||
<div className="flex items-center justify-center py-20 text-destructive text-sm">
|
||||
{t('common.error', 'Ýalňyşlyk ýüze çykdy')}
|
||||
</div>
|
||||
) : (
|
||||
<DistrictForm mode="edit" initialData={data} districtId={numericId} />
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
return <DistrictForm mode="edit" initialData={data} />
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { RoleForm } from '@/features/roles/components/roleForm'
|
||||
|
||||
export default function RoleCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground mb-6">
|
||||
{t('roles.actions.create', 'Rol dörediň')}
|
||||
</h1>
|
||||
<RoleForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <RoleForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { RoleForm } from '@/features/roles/components/roleForm'
|
||||
import { useRole } from '@/features/roles/hooks/useRoles'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function RoleEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const roleId = Number(id)
|
||||
|
||||
const { data: role, isLoading, isError } = useRole(roleId)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div>
|
||||
<Skeleton className="h-8 w-48 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center p-5">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-9 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !role) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isError || !role) {
|
||||
return (
|
||||
<p className="text-destructive text-sm">
|
||||
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground mb-6">
|
||||
{t('roles.editTitle', 'Rol üýtget')}: {role.name?.tk}
|
||||
</h1>
|
||||
<RoleForm mode="edit" initialData={role} roleId={roleId} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <RoleForm mode="edit" initialData={role} />
|
||||
}
|
||||
@@ -1,15 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PermissionForm } from '@/features/permissions/components/permissionsForm'
|
||||
|
||||
export default function PermissionCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground mb-6">
|
||||
{t('permissions.actions.create', 'Rugsat dörediň')}
|
||||
</h1>
|
||||
<PermissionForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <PermissionForm mode="create" />
|
||||
}
|
||||
@@ -1,46 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { PermissionForm } from '@/features/permissions/components/permissionsForm'
|
||||
import { usePermission } from '@/features/permissions/hooks/usePermissions'
|
||||
import { Skeleton } from '@/components/ui/skeleton'
|
||||
|
||||
export default function PermissionEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const permissionId = Number(id)
|
||||
const numericId = Number(id)
|
||||
const { data: permission, isLoading, isError } = usePermission(numericId)
|
||||
|
||||
const { data: permission, isLoading, isError } = usePermission(permissionId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !permission) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div>
|
||||
<Skeleton className="h-8 w-56 mb-6" />
|
||||
<div className="bg-card border border-border rounded-xl overflow-hidden divide-y divide-border">
|
||||
{Array.from({ length: 3 }).map((_, i) => (
|
||||
<div key={i} className="grid grid-cols-[220px_1fr] items-center p-5">
|
||||
<Skeleton className="h-4 w-24" />
|
||||
<Skeleton className="h-9 w-full" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isError || !permission) {
|
||||
return (
|
||||
<p className="text-destructive text-sm">
|
||||
{t('common.fetchError', 'Maglumat ýüklenmedi.')}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-foreground mb-6">
|
||||
{t('permissions.editTitle', 'Rugsaty üýtget')}: {permission.name?.tk}
|
||||
</h1>
|
||||
<PermissionForm mode="edit" initialData={permission} permissionId={permissionId} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <PermissionForm mode="edit" initialData={permission} />
|
||||
}
|
||||
@@ -1,21 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { UserForm } from '@/features/allUsers/components/allUsersForm'
|
||||
|
||||
// ─── UserCreatePage ───────────────────────────────────────────────────────────
|
||||
|
||||
export default function UserCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div >
|
||||
|
||||
{/* Title */}
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('users.actions.create', 'Ulanyjy dörediň')}
|
||||
</h1>
|
||||
|
||||
{/* Shared form — create mode */}
|
||||
<UserForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <UserForm mode="create" />
|
||||
}
|
||||
@@ -1,45 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { UserForm } from '@/features/allUsers/components/allUsersForm'
|
||||
import { useUser } from '@/features/allUsers/hooks/useAllUsers'
|
||||
|
||||
// ─── UserEditPage ─────────────────────────────────────────────────────────────
|
||||
|
||||
export default function UserEditPage() {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const userId = Number(id)
|
||||
const numericId = Number(id)
|
||||
const { data: user, isLoading, isError } = useUser(numericId)
|
||||
|
||||
const { data: user, isLoading, isError } = useUser(userId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (isError || !user) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[300px]">
|
||||
<Loader2 size={24} className="animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isError || !user) {
|
||||
return (
|
||||
<div className="p-6 text-center text-muted-foreground">
|
||||
{t('common.notFound', 'Maglumat tapylmady')}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-4 max-w-4xl">
|
||||
|
||||
|
||||
{/* Title */}
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
{t('users.editTitle', 'Ulanyjy giňişleýin')}: {user.name} ({user.username})
|
||||
</h1>
|
||||
|
||||
{/* Shared form — edit mode, passes fetched data */}
|
||||
<UserForm mode="edit" initialData={user} userId={userId} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <UserForm mode="edit" initialData={user} />
|
||||
}
|
||||
@@ -1,19 +1,5 @@
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ClientForm } from '@/features/clients/components/clientForm'
|
||||
|
||||
export default function ClientCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div >
|
||||
|
||||
|
||||
{/* Page heading */}
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('clients.createTitle', 'Müşderi dörediň')}
|
||||
</h1>
|
||||
|
||||
<ClientForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
return <ClientForm mode="create" />
|
||||
}
|
||||
@@ -1,37 +1,18 @@
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { ClientForm } from '@/features/clients/components/clientForm'
|
||||
import { useClient } from '@/features/clients/hooks/useClients'
|
||||
|
||||
export default function ClientEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const clientId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { data: client, isLoading } = useClient(numericId)
|
||||
|
||||
const { data: client, isLoading } = useClient(clientId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!client) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
|
||||
{/* Page heading */}
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('clients.editTitle', 'Müşderi üýtget')}: {client?.name ?? ''}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-3">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="h-14 bg-muted rounded-xl animate-pulse" />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<ClientForm
|
||||
mode="edit"
|
||||
initialData={client}
|
||||
clientId={clientId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
return <ClientForm mode="edit" initialData={client} />
|
||||
}
|
||||
@@ -1,19 +1,5 @@
|
||||
// ─── OperatorCreatePage.tsx ───────────────────────────────────────────────────
|
||||
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { OperatorForm } from '@/features/operators/components/operatorForms'
|
||||
|
||||
export default function OperatorCreatePage() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Page heading */}
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('operators.createTitle', 'Operator döredin')}
|
||||
</h1>
|
||||
|
||||
<OperatorForm mode="create" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <OperatorForm mode="create" />
|
||||
}
|
||||
@@ -1,37 +1,18 @@
|
||||
// ─── OperatorEditPage.tsx ─────────────────────────────────────────────────────
|
||||
|
||||
import { useParams, } from 'react-router-dom'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { PageSpinner } from '@/components/pageSpinner'
|
||||
import { PageError } from '@/components/pageError'
|
||||
import { OperatorForm } from '@/features/operators/components/operatorForms'
|
||||
import { useOperator } from '@/features/operators/hooks/useOperators'
|
||||
|
||||
export default function OperatorEditPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const operatorId = Number(id)
|
||||
const { t } = useTranslation()
|
||||
const numericId = Number(id)
|
||||
const { data: operator, isLoading } = useOperator(numericId)
|
||||
|
||||
const { data: operator, isLoading } = useOperator(operatorId)
|
||||
if (isLoading) return <PageSpinner />
|
||||
if (!operator) return <PageError message={t('common.notFound', 'Tapylmady')} />
|
||||
|
||||
return (
|
||||
<div >
|
||||
{/* Page heading */}
|
||||
<h1 className="text-2xl font-semibold text-foreground mb-6">
|
||||
{t('operators.editTitle', 'Operator üýtget')}: {operator?.name ?? ''}
|
||||
</h1>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="space-y-3">
|
||||
{Array.from({ length: 6 }).map((_, i) => (
|
||||
<div key={i} className="h-14 bg-muted rounded-xl animate-pulse" />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<OperatorForm
|
||||
mode="edit"
|
||||
initialData={operator}
|
||||
operatorId={operatorId}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return <OperatorForm mode="edit" initialData={operator} />
|
||||
}
|
||||
Reference in new issue
Block a user