show in slider
This commit is contained in:
+2
-1
@@ -187,7 +187,8 @@
|
|||||||
"danak_sujescet": "پیشنهاد داناک",
|
"danak_sujescet": "پیشنهاد داناک",
|
||||||
"plans": "پلن ها",
|
"plans": "پلن ها",
|
||||||
"add_plan": "افزودن پلن",
|
"add_plan": "افزودن پلن",
|
||||||
"active_plan": "پلن فعال"
|
"active_plan": "پلن فعال",
|
||||||
|
"slider": "نمایش در اسلایدر"
|
||||||
},
|
},
|
||||||
"plan": {
|
"plan": {
|
||||||
"plans_list": "لیست پلن های ",
|
"plans_list": "لیست پلن های ",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import moment from 'moment-jalaali'
|
|||||||
import Pagination from '../../components/Pagination'
|
import Pagination from '../../components/Pagination'
|
||||||
import ToggleStatusService from './components/ToggleStatusService'
|
import ToggleStatusService from './components/ToggleStatusService'
|
||||||
import CheckBoxComponent from '../../components/CheckBoxComponent'
|
import CheckBoxComponent from '../../components/CheckBoxComponent'
|
||||||
|
import ToggleSliderService from './components/ToggleSliderService'
|
||||||
|
|
||||||
const ListService: FC = () => {
|
const ListService: FC = () => {
|
||||||
|
|
||||||
@@ -109,6 +110,7 @@ const ListService: FC = () => {
|
|||||||
<Td text={t('service.publish_date')} />
|
<Td text={t('service.publish_date')} />
|
||||||
<Td text={t('service.plans')} />
|
<Td text={t('service.plans')} />
|
||||||
<Td text={t('ticket.status')} />
|
<Td text={t('ticket.status')} />
|
||||||
|
<Td text={t('service.slider')} />
|
||||||
<Td text={t('ticket.detail')} />
|
<Td text={t('ticket.detail')} />
|
||||||
<Td text={''} />
|
<Td text={''} />
|
||||||
</tr>
|
</tr>
|
||||||
@@ -153,6 +155,12 @@ const ListService: FC = () => {
|
|||||||
status={item.isActive}
|
status={item.isActive}
|
||||||
/>
|
/>
|
||||||
</Td>
|
</Td>
|
||||||
|
<Td text={''}>
|
||||||
|
<ToggleSliderService
|
||||||
|
id={item.id}
|
||||||
|
status={item.showInSlider}
|
||||||
|
/>
|
||||||
|
</Td>
|
||||||
<Td text={''}>
|
<Td text={''}>
|
||||||
<Link to={Pages.services.update + item.id}>
|
<Link to={Pages.services.update + item.id}>
|
||||||
<Eye size={20} color='#8C90A3' />
|
<Eye size={20} color='#8C90A3' />
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import { FC, useState } from 'react'
|
||||||
|
import { useToggleSliderService } from '../hooks/useServiceData'
|
||||||
|
import SwitchComponent from '../../../components/Switch'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
id: string,
|
||||||
|
status: boolean,
|
||||||
|
}
|
||||||
|
|
||||||
|
const ToggleSliderService: FC<Props> = (props: Props) => {
|
||||||
|
|
||||||
|
const [isActive, setIsActive] = useState<boolean>(props.status)
|
||||||
|
const toggleStatus = useToggleSliderService()
|
||||||
|
|
||||||
|
const handleChange = (value: boolean) => {
|
||||||
|
setIsActive(value)
|
||||||
|
toggleStatus.mutate(props.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SwitchComponent
|
||||||
|
active={isActive}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ToggleSliderService
|
||||||
@@ -99,6 +99,12 @@ export const useToggleStatusService = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useToggleSliderService = () => {
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (id: string) => api.toggleSliderService(id),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const useCreatePlan = () => {
|
export const useCreatePlan = () => {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (variables: CreatePlanType) => api.createPlan(variables),
|
mutationFn: (variables: CreatePlanType) => api.createPlan(variables),
|
||||||
|
|||||||
@@ -161,3 +161,8 @@ export const deleteCategory = async (id: string) => {
|
|||||||
const { data } = await axios.delete(`/danak-services/categories/${id}`);
|
const { data } = await axios.delete(`/danak-services/categories/${id}`);
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const toggleSliderService = async (id: string) => {
|
||||||
|
const { data } = await axios.post(`/danak-services/toggle-slider/${id}`);
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ export type ServiceItemType = {
|
|||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
icon: string;
|
icon: string;
|
||||||
subscriptionCount: number;
|
subscriptionCount: number;
|
||||||
|
showInSlider: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type CreateItemPlanType = {
|
export type CreateItemPlanType = {
|
||||||
|
|||||||
Reference in New Issue
Block a user