This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
VITE_BASE_URL = 'https://api.fajrtabloshop.com'
|
||||
# VITE_BASE_URL = 'http://192.168.99.235:4000'
|
||||
|
||||
# VITE_BASE_URL = 'https://api.shinan.ir'
|
||||
VITE_TOKEN_NAME = 'sh_admin_token'
|
||||
VITE_REFRESH_TOKEN_NAME = 'sh_admin_refresh_token'
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type FC } from 'react'
|
||||
import PageTitle from '../../components/PageTitle'
|
||||
import { useGetProductVariants } from './hooks/useProductData'
|
||||
import { useDeleteProductVariant, useGetProductVariants } from './hooks/useProductData'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import PageLoading from '@/components/PageLoading'
|
||||
import type { ProductVariantDetailType } from './types/Types'
|
||||
@@ -8,11 +8,13 @@ import Td from '@/components/Td'
|
||||
import StatusWithText from '@/components/StatusWithText'
|
||||
import CreateVariant from './components/CreateVariant'
|
||||
import UpdateVariant from './components/UpdateVariant'
|
||||
import TrashWithConfrim from '@/components/TrashWithConfrim'
|
||||
|
||||
const ProductVariant: FC = () => {
|
||||
|
||||
const { id } = useParams()
|
||||
const { data, isLoading, refetch } = useGetProductVariants(id!)
|
||||
const { mutate: deleteVariant } = useDeleteProductVariant()
|
||||
|
||||
const getVariantColumnHeader = () => {
|
||||
return 'تنوع'
|
||||
@@ -76,7 +78,18 @@ const ProductVariant: FC = () => {
|
||||
</span>
|
||||
</Td>
|
||||
<Td text="">
|
||||
<UpdateVariant variant={variant} onUpdate={refetch} />
|
||||
<div className='flex gap-2 items-center'>
|
||||
<UpdateVariant variant={variant} onUpdate={refetch} />
|
||||
<TrashWithConfrim
|
||||
onDelete={() => {
|
||||
deleteVariant(variant._id, {
|
||||
onSuccess: () => {
|
||||
refetch()
|
||||
}
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Td>
|
||||
</tr>
|
||||
)
|
||||
|
||||
@@ -141,4 +141,10 @@ export const useDraftProduct = () => {
|
||||
return useMutation({
|
||||
mutationFn: api.draftProduct,
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteProductVariant = () => {
|
||||
return useMutation({
|
||||
mutationFn: api.deleteProductVariant,
|
||||
});
|
||||
};
|
||||
@@ -132,4 +132,9 @@ export const answerProductQuestion = async (params: {id: string, answer: string}
|
||||
export const draftProduct = async (id: string) => {
|
||||
const { data } = await axios.post(`/admin/products/${id}/draft`);
|
||||
return data;
|
||||
};
|
||||
|
||||
export const deleteProductVariant = async (variantId: string) => {
|
||||
const { data } = await axios.delete(`/admin/products/variants/${variantId}`);
|
||||
return data;
|
||||
};
|
||||
Reference in New Issue
Block a user