slug
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
VITE_TOKEN_NAME = 'dsc_token'
|
||||
VITE_REFRESH_TOKEN_NAME = 'dsc_refresh_token'
|
||||
VITE_BASE_URL = 'https://api.danakcorp.com'
|
||||
# VITE_BASE_URL = 'http://192.168.1.119:4001'
|
||||
# VITE_BASE_URL = 'https://api.danakcorp.com'
|
||||
VITE_BASE_URL = 'http://192.168.99.235:3500'
|
||||
+3
-3
@@ -526,9 +526,9 @@
|
||||
"actions": "عملیات"
|
||||
},
|
||||
"restaurant": {
|
||||
"manage": "مدیریت رستوران",
|
||||
"restaurant_info": "اطلاعات رستوران",
|
||||
"enter_restaurant_info": "لطفا اطلاعات رستوران خود را وارد کنید",
|
||||
"manage": "ساخت منوی رستوران",
|
||||
"restaurant_info": "اسلاگ رستوران",
|
||||
"enter_restaurant_info": "در این بخش نام کاربری رستوران خود که از طریق آن به منو دسترسی دارید را وارد نمایید.",
|
||||
"name": "نام رستوران",
|
||||
"enter_name": "نام رستوران را وارد کنید",
|
||||
"slug": "اسلاگ",
|
||||
|
||||
@@ -7,8 +7,8 @@ import { DmenuCreateRestaurantType } from './types/ServiecTypes'
|
||||
import * as Yup from 'yup'
|
||||
import { toast } from '../../components/Toast'
|
||||
import { ErrorType } from '../../helpers/types'
|
||||
import Input from '../../components/Input'
|
||||
import Button from '../../components/Button'
|
||||
import Error from '../../components/Error'
|
||||
import { TickCircle } from 'iconsax-react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
|
||||
@@ -42,29 +42,18 @@ export const ManageRestaurant: FC = () => {
|
||||
|
||||
const formik = useFormik<DmenuCreateRestaurantType>({
|
||||
initialValues: {
|
||||
name: '',
|
||||
slug: '',
|
||||
establishedYear: 0,
|
||||
phone: '',
|
||||
userSubscriptionId: subscriptionId || ''
|
||||
},
|
||||
enableReinitialize: true,
|
||||
validationSchema: Yup.object({
|
||||
name: Yup.string().required(t('errors.required')),
|
||||
slug: Yup.string().required(t('errors.required')),
|
||||
establishedYear: Yup.number()
|
||||
slug: Yup.string()
|
||||
.required(t('errors.required'))
|
||||
.min(1300, 'سال باید حداقل ۱۳۰۰ باشد')
|
||||
.max(1500, 'سال باید حداکثر ۱۵۰۰ باشد'),
|
||||
phone: Yup.string().required(t('errors.required')),
|
||||
.matches(/^[a-zA-Z0-9-]+$/, 'اسلاگ باید فقط شامل حروف انگلیسی، اعداد و خط تیره باشد'),
|
||||
userSubscriptionId: Yup.string().required(t('errors.required'))
|
||||
}),
|
||||
onSubmit: (values) => {
|
||||
const submitValues = {
|
||||
...values,
|
||||
establishedYear: Number(values.establishedYear)
|
||||
}
|
||||
createDmenuRestaurant.mutate(submitValues, {
|
||||
createDmenuRestaurant.mutate(values, {
|
||||
onSuccess: () => {
|
||||
toast(t('success') || 'با موفقیت انجام شد', 'success')
|
||||
formik.resetForm()
|
||||
@@ -84,7 +73,7 @@ export const ManageRestaurant: FC = () => {
|
||||
</Helmet>
|
||||
<div className='mt-4'>
|
||||
<div className='text-lg font-semibold mb-2'>
|
||||
{t('restaurant.manage') || 'مدیریت رستوران'}
|
||||
{t('restaurant.manage')}
|
||||
</div>
|
||||
|
||||
<div className='bg-white rounded-3xl xl:p-6 p-4 mt-8 text-sm'>
|
||||
@@ -98,40 +87,32 @@ export const ManageRestaurant: FC = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex flex-col gap-6'>
|
||||
<div className='flex xl:flex-row flex-col xl:gap-6 gap-3'>
|
||||
<Input
|
||||
label={t('restaurant.name') || 'نام رستوران'}
|
||||
{...formik.getFieldProps('name')}
|
||||
error_text={formik.touched.name && formik.errors.name ? formik.errors.name : ''}
|
||||
placeholder={t('restaurant.enter_name') || 'نام رستوران را وارد کنید'}
|
||||
/>
|
||||
|
||||
<Input
|
||||
label={t('restaurant.slug') || 'اسلاگ'}
|
||||
{...formik.getFieldProps('slug')}
|
||||
error_text={formik.touched.slug && formik.errors.slug ? formik.errors.slug : ''}
|
||||
<div className='flex lg:max-w-[500px] mx-auto flex-col gap-6'>
|
||||
<div className='w-full'>
|
||||
<label className='text-sm font-medium mb-2 block'>
|
||||
{t('restaurant.slug') || 'اسلاگ'}
|
||||
</label>
|
||||
<div className='w-full relative mt-1'>
|
||||
<div className='flex items-center border border-border rounded-xl overflow-hidden bg-white hover:border-gray-400 transition-colors focus-within:border-primary focus-within:ring-2 focus-within:ring-primary/20' dir='ltr'>
|
||||
<div className='px-4 py-2.5 bg-gray-50 text-xs text-gray-600 border-r border-border whitespace-nowrap font-medium'>
|
||||
dmenu.danakcorp.com/
|
||||
</div>
|
||||
<input
|
||||
type='text'
|
||||
value={formik.values.slug}
|
||||
onChange={(e) => {
|
||||
formik.setFieldValue('slug', e.target.value)
|
||||
}}
|
||||
onBlur={formik.handleBlur}
|
||||
placeholder={t('restaurant.enter_slug') || 'اسلاگ را وارد کنید'}
|
||||
className='flex-1 h-10 text-black block px-4 text-xs border-0 focus:outline-none focus:ring-0 bg-transparent'
|
||||
dir='ltr'
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex xl:flex-row flex-col xl:gap-6 gap-3'>
|
||||
<Input
|
||||
label={t('restaurant.established_year') || 'سال تأسیس'}
|
||||
{...formik.getFieldProps('establishedYear')}
|
||||
error_text={formik.touched.establishedYear && formik.errors.establishedYear ? formik.errors.establishedYear : ''}
|
||||
placeholder={t('restaurant.enter_year') || 'سال تأسیس را وارد کنید'}
|
||||
type='number'
|
||||
min={1300}
|
||||
max={1500}
|
||||
/>
|
||||
|
||||
<Input
|
||||
label={t('auth.phonen_number') || 'شماره تماس'}
|
||||
{...formik.getFieldProps('phone')}
|
||||
error_text={formik.touched.phone && formik.errors.phone ? formik.errors.phone : ''}
|
||||
placeholder={t('auth.enter_phone_number') || 'شماره تماس را وارد کنید'}
|
||||
/>
|
||||
{formik.touched.slug && formik.errors.slug && (
|
||||
<Error errorText={formik.errors.slug} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='mt-4 flex justify-end'>
|
||||
|
||||
@@ -279,10 +279,7 @@ export type ExtentSubscriptionResponseType = {
|
||||
};
|
||||
|
||||
export type DmenuCreateRestaurantType = {
|
||||
name: string;
|
||||
slug: string;
|
||||
establishedYear: number;
|
||||
phone: string;
|
||||
userSubscriptionId: string;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user