reseller sales and collections apis
This commit is contained in:
parent
5b304c8952
commit
40b0ef3ab2
|
|
@ -5,17 +5,20 @@ import LayoutModel from "../../../../../Layout/Dashboard/LayoutModel";
|
||||||
import ModelForm from "./ModelForm";
|
import ModelForm from "./ModelForm";
|
||||||
import { QueryStatusEnum } from "../../../../../enums/QueryStatus";
|
import { QueryStatusEnum } from "../../../../../enums/QueryStatus";
|
||||||
import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
|
import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
|
||||||
import { useUpdateReseller } from "../../../../../api/reseller";
|
import { useUpdateReseller, useUpdateResellerCollection } from "../../../../../api/reseller";
|
||||||
|
import { formatDate } from "../../../../../utils/formatDate";
|
||||||
|
|
||||||
const EditModel: React.FC = () => {
|
const EditModel: React.FC = () => {
|
||||||
const { mutate, status } = useUpdateReseller();
|
const { mutate, status } = useUpdateResellerCollection();
|
||||||
const { objectToEdit } = useObjectToEdit((state) => state);
|
const { objectToEdit } = useObjectToEdit((state) => state);
|
||||||
|
|
||||||
const handleSubmit = (values: any) => {
|
const handleSubmit = (values: any) => {
|
||||||
mutate({
|
mutate({
|
||||||
...values,
|
...values,
|
||||||
|
date:formatDate(values?.date),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<LayoutModel
|
<LayoutModel
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,23 @@
|
||||||
import ValidationField from "../../../../../Components/ValidationField/ValidationField";
|
|
||||||
import { Col, Row } from "reactstrap";
|
import { Col, Row } from "reactstrap";
|
||||||
|
import ValidationField from "../../../../../Components/ValidationField/ValidationField";
|
||||||
|
|
||||||
const FilterForm = () => {
|
const FilterForm = () => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<ValidationField placeholder="amount_value" label="amount_value" name="amount_value" />
|
<ValidationField
|
||||||
<ValidationField type="Date" placeholder="date_of_receipt" label="date_of_receipt" name="date_of_receipt" />
|
placeholder="activation_date"
|
||||||
|
label="activation_date"
|
||||||
|
name="activation_date"
|
||||||
|
type="Date"
|
||||||
|
/>
|
||||||
|
<ValidationField
|
||||||
|
placeholder="expiration_date"
|
||||||
|
label="expiration_date"
|
||||||
|
name="expiration_date"
|
||||||
|
type="Date"
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
19
src/Pages/Admin/Reseller/show/Model/FilterFormCollection.tsx
Normal file
19
src/Pages/Admin/Reseller/show/Model/FilterFormCollection.tsx
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { Col, Row } from "reactstrap";
|
||||||
|
import ValidationField from "../../../../../Components/ValidationField/ValidationField";
|
||||||
|
|
||||||
|
const FilterFormCollection = () => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
|
<ValidationField placeholder="description" label="description" name="description" />
|
||||||
|
<ValidationField placeholder="amount" label="amount" name="amount" />
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FilterFormCollection;
|
||||||
|
|
@ -5,9 +5,9 @@ const Form = () => {
|
||||||
return (
|
return (
|
||||||
<Row className="w-100">
|
<Row className="w-100">
|
||||||
<Col>
|
<Col>
|
||||||
<ValidationField placeholder="amount_value" label="amount_value" name="amount_value" />
|
|
||||||
<ValidationField type="Date" placeholder="date_of_receipt" label="date_of_receipt" name="date_of_receipt" />
|
|
||||||
<ValidationField placeholder="description" label="description" name="description" />
|
<ValidationField placeholder="description" label="description" name="description" />
|
||||||
|
<ValidationField placeholder="amount" label="amount" name="amount" />
|
||||||
|
<ValidationField type="Date" placeholder="date" label="date" name="date" />
|
||||||
|
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
|
import dayjs from "dayjs";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
export const getInitialValues = (objectToEdit: any): any => {
|
export const getInitialValues = (objectToEdit: any): any => {
|
||||||
|
console.log(objectToEdit?.date);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: objectToEdit?.id ?? null,
|
id: objectToEdit?.id ?? null,
|
||||||
amount_value: objectToEdit?.amount_value ?? null,
|
amount: objectToEdit?.amount ?? null,
|
||||||
description: objectToEdit?.description ?? null,
|
description: objectToEdit?.description ?? null,
|
||||||
date_of_receipt: objectToEdit?.date_of_receipt ?? null,
|
date: objectToEdit?.date ? dayjs(objectToEdit.date) : null,
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getValidationSchema = () => {
|
export const getValidationSchema = () => {
|
||||||
return Yup.object().shape({
|
return Yup.object().shape({
|
||||||
amount_value: Yup.string().required("validation.required"),
|
amount: Yup.string().required("validation.required"),
|
||||||
description: Yup.string().required("validation.required"),
|
description: Yup.string().required("validation.required"),
|
||||||
date_of_receipt: Yup.string().required("validation.required"),
|
date: Yup.string().required("validation.required"),
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { useParams } from "react-router-dom";
|
||||||
import { ParamsEnum } from "../../../../enums/params";
|
import { ParamsEnum } from "../../../../enums/params";
|
||||||
import AttachmentsCard from "../../../../Components/Cards/AttachmentsCard";
|
import AttachmentsCard from "../../../../Components/Cards/AttachmentsCard";
|
||||||
import { ModalEnum } from "../../../../enums/Model";
|
import { ModalEnum } from "../../../../enums/Model";
|
||||||
import { useDeleteReseller } from "../../../../api/reseller";
|
import { useDeleteReseller, useDeleteResellerCollection } from "../../../../api/reseller";
|
||||||
import { useObjectToEdit } from "../../../../zustand/ObjectToEditState";
|
import { useObjectToEdit } from "../../../../zustand/ObjectToEditState";
|
||||||
import useModalHandler from "../../../../utils/useModalHandler";
|
import useModalHandler from "../../../../utils/useModalHandler";
|
||||||
const DeleteModalForm = lazy(
|
const DeleteModalForm = lazy(
|
||||||
|
|
@ -21,12 +21,12 @@ const DeleteModalForm = lazy(
|
||||||
|
|
||||||
const TableHeader = () => {
|
const TableHeader = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const { re_seller_id } = useParams<ParamsEnum>()
|
const { reseller_id } = useParams<ParamsEnum>()
|
||||||
|
|
||||||
useSetPageTitle([
|
useSetPageTitle([
|
||||||
{ name: `${t(`page_header.home`)}`, path: "/" },
|
{ name: `${t(`page_header.home`)}`, path: "/" },
|
||||||
{ name: `${t(`page_header.reseller`)}`, path: "reseller" },
|
{ name: `${t(`page_header.reseller`)}`, path: "reseller" },
|
||||||
{ name: `${t(`page_header.reseller_details`)}`, path: `reseller/${re_seller_id}` },
|
{ name: `${t(`page_header.reseller_details`)}`, path: `reseller/${reseller_id}` },
|
||||||
]);
|
]);
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ const TableHeader = () => {
|
||||||
handel_open_model(ModalEnum?.RE_SELLER_COLLECTION_ADD);
|
handel_open_model(ModalEnum?.RE_SELLER_COLLECTION_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteMutation = useDeleteReseller();
|
const deleteMutation = useDeleteResellerCollection();
|
||||||
return (
|
return (
|
||||||
<div className="TableWithHeader single_student">
|
<div className="TableWithHeader single_student">
|
||||||
<Suspense fallback={<Spin />}>
|
<Suspense fallback={<Spin />}>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ import { lazy } from 'react';
|
||||||
import { FaMoneyBills } from "react-icons/fa6";
|
import { FaMoneyBills } from "react-icons/fa6";
|
||||||
import useSearchQuery from '../../../../api/utils/useSearchQuery';
|
import useSearchQuery from '../../../../api/utils/useSearchQuery';
|
||||||
import { useFilterState } from '../../../../Components/Utils/Filter/FilterState';
|
import { useFilterState } from '../../../../Components/Utils/Filter/FilterState';
|
||||||
import { useGetAllReseller } from '../../../../api/reseller';
|
import { useGetAllReseller, useGetAllResellerCollection, useGetAllResellerSales } from '../../../../api/reseller';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
import { ParamsEnum } from '../../../../enums/params';
|
||||||
|
import FilterFormCollection from './Model/FilterFormCollection';
|
||||||
|
|
||||||
const Table = lazy(() => import("./Table"));
|
const Table = lazy(() => import("./Table"));
|
||||||
|
|
||||||
|
|
@ -16,10 +19,20 @@ const ReSellerTabs = () => {
|
||||||
|
|
||||||
const [searchQuery] = useSearchQuery("name");
|
const [searchQuery] = useSearchQuery("name");
|
||||||
const { filterState } = useFilterState();
|
const { filterState } = useFilterState();
|
||||||
const response = useGetAllReseller({
|
const {reseller_id} = useParams<ParamsEnum>();
|
||||||
|
|
||||||
|
const response = useGetAllResellerSales({
|
||||||
name: searchQuery,
|
name: searchQuery,
|
||||||
pagination: true,
|
pagination: true,
|
||||||
...filterState,
|
...filterState,
|
||||||
|
reseller_id:reseller_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const responseCollection = useGetAllResellerCollection({
|
||||||
|
name: searchQuery,
|
||||||
|
pagination: true,
|
||||||
|
...filterState,
|
||||||
|
reseller_id:reseller_id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const items: TabsProps['items'] = [
|
const items: TabsProps['items'] = [
|
||||||
|
|
@ -43,10 +56,10 @@ const ReSellerTabs = () => {
|
||||||
children:
|
children:
|
||||||
<>
|
<>
|
||||||
<FilterLayout
|
<FilterLayout
|
||||||
sub_children={<FilterForm />}
|
sub_children={<FilterFormCollection />}
|
||||||
filterTitle="practical.collections"
|
filterTitle="practical.collections"
|
||||||
/>
|
/>
|
||||||
<Table response={response}/>
|
<Table response={responseCollection}/>
|
||||||
</>,
|
</>,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -8,32 +8,40 @@ export const useColumns = () => {
|
||||||
const columns: TableColumnsType<ReSeller> = [
|
const columns: TableColumnsType<ReSeller> = [
|
||||||
{
|
{
|
||||||
title: t("columns.student_full_name"),
|
title: t("columns.student_full_name"),
|
||||||
dataIndex: "student_full_name",
|
|
||||||
key: "student_full_name",
|
key: "student_full_name",
|
||||||
align: "center",
|
align: "center",
|
||||||
|
render: (row) => {
|
||||||
|
console.log(row);
|
||||||
|
|
||||||
|
return row?.student?.first_name +" "+ row?.student?.last_name;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.grade"),
|
title: t("columns.grade"),
|
||||||
dataIndex: "grade",
|
render: (row) => {
|
||||||
key: "grade",
|
return row?.package?.name;
|
||||||
align: "center",
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t("columns.package"),
|
|
||||||
dataIndex: "package",
|
|
||||||
key: "package",
|
key: "package",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.amount_paid"),
|
title: t("columns.paid_price"),
|
||||||
dataIndex: "amount_paid",
|
render: (row) => {
|
||||||
key: "amount_paid",
|
return row?.package?.price;
|
||||||
|
},
|
||||||
|
key: "price",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.sale_date"),
|
title: t("columns.activation_date"),
|
||||||
dataIndex: "sale_date",
|
dataIndex: "activation_date",
|
||||||
key: "sale_date",
|
key: "activation_date",
|
||||||
|
align: "center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("columns.expiration_date"),
|
||||||
|
dataIndex: "expiration_date",
|
||||||
|
key: "expiration_date",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -29,18 +29,6 @@ export const useColumnsCollection = () => {
|
||||||
key: "ID",
|
key: "ID",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t("columns.amount"),
|
|
||||||
dataIndex: "amount",
|
|
||||||
key: "amount",
|
|
||||||
align: "center",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: t("columns.date_of_receipt"),
|
|
||||||
dataIndex: "date_of_receipt",
|
|
||||||
key: "date_of_receipt",
|
|
||||||
align: "center",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: t("columns.description"),
|
title: t("columns.description"),
|
||||||
dataIndex: "description",
|
dataIndex: "description",
|
||||||
|
|
@ -48,15 +36,15 @@ export const useColumnsCollection = () => {
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.residual"),
|
title: t("columns.amount"),
|
||||||
dataIndex: "residual",
|
dataIndex: "amount",
|
||||||
key: "residual",
|
key: "amount",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.procedure"),
|
title: t("columns.date"),
|
||||||
dataIndex: "procedure",
|
dataIndex: "date",
|
||||||
key: "procedure",
|
key: "date",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
export const BaseURL = "https://nerd-back.point-dev.net/api/";
|
export const BaseURL = "https://nerd-back.point-dev.net/api/";
|
||||||
// export const BaseURL = "http://192.168.1.109:8000/api/";
|
// export const BaseURL = "http://192.168.1.106:8000/api/";
|
||||||
|
|
||||||
export const HEADER_KEY = "X-Custom-Query-Key";
|
export const HEADER_KEY = "X-Custom-Query-Key";
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,18 @@ const API = {
|
||||||
ADD: "/reseller",
|
ADD: "/reseller",
|
||||||
DELETE: "/reseller",
|
DELETE: "/reseller",
|
||||||
UPDATE: "/reseller",
|
UPDATE: "/reseller",
|
||||||
|
|
||||||
|
GET_COLLECTION: "/financialCollection",
|
||||||
|
Update_COLLECTION: "/financialCollection",
|
||||||
|
DELETE_COLLECTION : "/financialCollection",
|
||||||
|
|
||||||
|
GET_SAlES: "/reseller/getStudentPackage",
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const KEY = "reseller";
|
const KEY = "reseller";
|
||||||
|
const KEY_SALE = "reseller_sale";
|
||||||
|
const KEY_COLLECTION = "reseller_collection";
|
||||||
|
|
||||||
export const useGetAllReseller = (params?: any, options?: any) =>
|
export const useGetAllReseller = (params?: any, options?: any) =>
|
||||||
useGetQuery(KEY, API.GET, params, options);
|
useGetQuery(KEY, API.GET, params, options);
|
||||||
|
|
@ -19,3 +28,16 @@ export const useUpdateReseller = () =>
|
||||||
useUpdateMutation(KEY, API.GET);
|
useUpdateMutation(KEY, API.GET);
|
||||||
export const useDeleteReseller = () =>
|
export const useDeleteReseller = () =>
|
||||||
useDeleteMutation(KEY, API.DELETE);
|
useDeleteMutation(KEY, API.DELETE);
|
||||||
|
|
||||||
|
|
||||||
|
export const useGetAllResellerCollection = (params?: any, options?: any) =>
|
||||||
|
useGetQuery(KEY_COLLECTION, API.GET_COLLECTION, params, options);
|
||||||
|
export const useUpdateResellerCollection = () =>
|
||||||
|
useUpdateMutation(KEY_COLLECTION, API.Update_COLLECTION);
|
||||||
|
export const useDeleteResellerCollection = () =>
|
||||||
|
useDeleteMutation(KEY_COLLECTION, API.DELETE_COLLECTION);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const useGetAllResellerSales = (params?: any, options?: any) =>
|
||||||
|
useGetQuery(KEY_SALE, API.GET_SAlES, params, options);
|
||||||
|
|
@ -11,11 +11,12 @@ export enum ParamsEnum {
|
||||||
LESSON_ID = "lesson_id",
|
LESSON_ID = "lesson_id",
|
||||||
QUESTION_ID = "question_id",
|
QUESTION_ID = "question_id",
|
||||||
CHILDREN_QUESTION_ID = "children_question_id",
|
CHILDREN_QUESTION_ID = "children_question_id",
|
||||||
RE_SELLER_ID = "re_seller_id",
|
RE_SELLER_ID = "reseller_id",
|
||||||
ROLE_ID = "role_id",
|
ROLE_ID = "role_id",
|
||||||
CITY_ID = "city_id",
|
CITY_ID = "city_id",
|
||||||
Collection_ID = "collection_id",
|
Collection_ID = "collection_id",
|
||||||
Manager_ID = "manager_id",
|
Manager_ID = "manager_id",
|
||||||
|
// RESELLER_ID = "reseller_id",
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user