chrone: sperate client and server to different repos.

This commit is contained in:
a.bouhuolia
2021-09-21 17:13:53 +02:00
parent e011b2a82b
commit 18df5530c7
10015 changed files with 17686 additions and 97524 deletions

View File

@@ -0,0 +1,57 @@
import React, { createContext } from 'react';
import { DialogContent } from 'components';
import {
useItemCategory,
useEditItemCategory,
useCreateItemCategory,
} from 'hooks/query';
const ItemCategoryContext = createContext();
/**
* Accounts chart data provider.
*/
function ItemCategoryProvider({ itemCategoryId, dialogName, ...props }) {
const { data: itemCategory, isFetching: isItemCategoryLoading } = useItemCategory(
itemCategoryId,
{
enabled: !!itemCategoryId,
},
);
// Create and edit item category mutations.
const { mutateAsync: createItemCategoryMutate } = useCreateItemCategory();
const { mutateAsync: editItemCategoryMutate } = useEditItemCategory();
// Detarmines whether the new mode form.
const isNewMode = !itemCategoryId;
const isEditMode = !isNewMode;
// Provider state.
const provider = {
itemCategoryId,
dialogName,
itemCategory,
isItemCategoryLoading,
createItemCategoryMutate,
editItemCategoryMutate,
isNewMode,
isEditMode
};
return (
<DialogContent
isLoading={isItemCategoryLoading}
name={'item-category-form'}
>
<ItemCategoryContext.Provider value={provider} {...props} />
</DialogContent>
);
}
const useItemCategoryContext = () =>
React.useContext(ItemCategoryContext);
export { ItemCategoryProvider, useItemCategoryContext };