payment method
This commit is contained in:
@@ -35,7 +35,6 @@ const CreatePaymentMethod: FC = () => {
|
|||||||
|
|
||||||
const formik = useFormik<CreateRestaurantPaymentMethodType>({
|
const formik = useFormik<CreateRestaurantPaymentMethodType>({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
title: '',
|
|
||||||
method: '',
|
method: '',
|
||||||
gateway: '',
|
gateway: '',
|
||||||
description: '',
|
description: '',
|
||||||
@@ -44,7 +43,6 @@ const CreatePaymentMethod: FC = () => {
|
|||||||
merchantId: '',
|
merchantId: '',
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object().shape({
|
validationSchema: Yup.object().shape({
|
||||||
title: Yup.string().required('عنوان الزامی است'),
|
|
||||||
method: Yup.string().required('روش پرداخت الزامی است'),
|
method: Yup.string().required('روش پرداخت الزامی است'),
|
||||||
gateway: Yup.string().when('method', {
|
gateway: Yup.string().when('method', {
|
||||||
is: PaymentMethodEnum.Online,
|
is: PaymentMethodEnum.Online,
|
||||||
@@ -62,7 +60,6 @@ const CreatePaymentMethod: FC = () => {
|
|||||||
}),
|
}),
|
||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
const submitValues: CreateRestaurantPaymentMethodType = {
|
const submitValues: CreateRestaurantPaymentMethodType = {
|
||||||
title: values.title,
|
|
||||||
method: values.method,
|
method: values.method,
|
||||||
description: values.description,
|
description: values.description,
|
||||||
enabled: values.enabled,
|
enabled: values.enabled,
|
||||||
@@ -120,15 +117,6 @@ const CreatePaymentMethod: FC = () => {
|
|||||||
error_text={formik.touched.method && formik.errors.method ? formik.errors.method : ''}
|
error_text={formik.touched.method && formik.errors.method ? formik.errors.method : ''}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='mt-6'>
|
|
||||||
<Input
|
|
||||||
label='عنوان'
|
|
||||||
name='title'
|
|
||||||
value={formik.values.title}
|
|
||||||
onChange={formik.handleChange}
|
|
||||||
error_text={formik.touched.title && formik.errors.title ? formik.errors.title : ''}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{formik.values.method === PaymentMethodEnum.Online && (
|
{formik.values.method === PaymentMethodEnum.Online && (
|
||||||
<>
|
<>
|
||||||
<div className='mt-6'>
|
<div className='mt-6'>
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ const UpdatePaymentMethod: FC = () => {
|
|||||||
if (paymentMethodData?.data) {
|
if (paymentMethodData?.data) {
|
||||||
const data = paymentMethodData.data as CreateRestaurantPaymentMethodType & { id: string }
|
const data = paymentMethodData.data as CreateRestaurantPaymentMethodType & { id: string }
|
||||||
return {
|
return {
|
||||||
title: data.title || '',
|
|
||||||
method: data.method || '',
|
method: data.method || '',
|
||||||
gateway: data.gateway || '',
|
gateway: data.gateway || '',
|
||||||
description: data.description || '',
|
description: data.description || '',
|
||||||
@@ -49,7 +48,6 @@ const UpdatePaymentMethod: FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
title: '',
|
|
||||||
method: '',
|
method: '',
|
||||||
gateway: '',
|
gateway: '',
|
||||||
description: '',
|
description: '',
|
||||||
@@ -63,7 +61,6 @@ const UpdatePaymentMethod: FC = () => {
|
|||||||
initialValues,
|
initialValues,
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
validationSchema: Yup.object().shape({
|
validationSchema: Yup.object().shape({
|
||||||
title: Yup.string().required('عنوان الزامی است'),
|
|
||||||
method: Yup.string().required('روش پرداخت الزامی است'),
|
method: Yup.string().required('روش پرداخت الزامی است'),
|
||||||
gateway: Yup.string().when('method', {
|
gateway: Yup.string().when('method', {
|
||||||
is: PaymentMethodEnum.Online,
|
is: PaymentMethodEnum.Online,
|
||||||
@@ -83,7 +80,6 @@ const UpdatePaymentMethod: FC = () => {
|
|||||||
if (!id) return
|
if (!id) return
|
||||||
|
|
||||||
const submitValues: CreateRestaurantPaymentMethodType = {
|
const submitValues: CreateRestaurantPaymentMethodType = {
|
||||||
title: values.title,
|
|
||||||
method: values.method,
|
method: values.method,
|
||||||
description: values.description,
|
description: values.description,
|
||||||
enabled: values.enabled,
|
enabled: values.enabled,
|
||||||
@@ -160,15 +156,6 @@ const UpdatePaymentMethod: FC = () => {
|
|||||||
error_text={formik.touched.method && formik.errors.method ? formik.errors.method : ''}
|
error_text={formik.touched.method && formik.errors.method ? formik.errors.method : ''}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='mt-6'>
|
|
||||||
<Input
|
|
||||||
label='عنوان'
|
|
||||||
name='title'
|
|
||||||
value={formik.values.title}
|
|
||||||
onChange={formik.handleChange}
|
|
||||||
error_text={formik.touched.title && formik.errors.title ? formik.errors.title : ''}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{formik.values.method === PaymentMethodEnum.Online && (
|
{formik.values.method === PaymentMethodEnum.Online && (
|
||||||
<>
|
<>
|
||||||
<div className='mt-6'>
|
<div className='mt-6'>
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ interface GetPaymentMethodTableColumnsParams {
|
|||||||
|
|
||||||
export const getPaymentMethodTableColumns = ({ onDelete, isDeleting }: GetPaymentMethodTableColumnsParams = {}): ColumnType<RestaurantPaymentMethod>[] => {
|
export const getPaymentMethodTableColumns = ({ onDelete, isDeleting }: GetPaymentMethodTableColumnsParams = {}): ColumnType<RestaurantPaymentMethod>[] => {
|
||||||
return [
|
return [
|
||||||
{
|
|
||||||
key: 'title',
|
|
||||||
title: 'عنوان',
|
|
||||||
render: (item: RestaurantPaymentMethod) => {
|
|
||||||
return item.title || '-'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'method',
|
key: 'method',
|
||||||
title: 'روش',
|
title: 'روش',
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ export type RestaurantPaymentMethod = {
|
|||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
deletedAt: string | null;
|
deletedAt: string | null;
|
||||||
restaurant: Restaurant;
|
restaurant: Restaurant;
|
||||||
title: string;
|
|
||||||
method: string;
|
method: string;
|
||||||
gateway: string;
|
gateway: string;
|
||||||
description: string;
|
description: string;
|
||||||
@@ -75,7 +74,6 @@ export type RestaurantPaymentMethodResponse = IResponse<
|
|||||||
>;
|
>;
|
||||||
|
|
||||||
export type CreateRestaurantPaymentMethodType = {
|
export type CreateRestaurantPaymentMethodType = {
|
||||||
title: string;
|
|
||||||
method: string;
|
method: string;
|
||||||
gateway?: string;
|
gateway?: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user