refactor: rename product to party-event across frontend modules and types
This commit is contained in:
@@ -25,11 +25,11 @@ export async function GET(req: NextRequest) {
|
|||||||
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
const debug = { 'req.headers': flattenNextjsRequest(req) };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const events = await listEvents();
|
const partyEvents = await listEvents();
|
||||||
|
|
||||||
createAppLog(L_INFO, 'party-event list ok', {});
|
createAppLog(L_INFO, 'party-event list ok', {});
|
||||||
|
|
||||||
return response({ events }, STATUS.OK);
|
return response({ partyEvents }, STATUS.OK);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
createAppLog(L_ERROR, 'party-event list error', debug);
|
createAppLog(L_ERROR, 'party-event list error', debug);
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
import axiosInstance, { endpoints, fetcher } from 'src/lib/axios';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import type { SWRConfiguration } from 'swr';
|
import type { SWRConfiguration } from 'swr';
|
||||||
import useSWR, { mutate } from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
|
|
||||||
@@ -16,24 +16,28 @@ const swrOptions: SWRConfiguration = {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type ProductsData = {
|
type PartyEventsData = {
|
||||||
products: IProductItem[];
|
partyEvents: IPartyEventItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useGetProducts() {
|
export function useGetPartyEvents() {
|
||||||
const url = endpoints.product.list;
|
const url = endpoints.partyEvent.list;
|
||||||
|
|
||||||
const { data, isLoading, error, isValidating } = useSWR<ProductsData>(url, fetcher, swrOptions);
|
const { data, isLoading, error, isValidating } = useSWR<PartyEventsData>(
|
||||||
|
url,
|
||||||
|
fetcher,
|
||||||
|
swrOptions
|
||||||
|
);
|
||||||
|
|
||||||
const memoizedValue = useMemo(
|
const memoizedValue = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
products: data?.products || [],
|
partyEvents: data?.partyEvents || [],
|
||||||
productsLoading: isLoading,
|
partyEventsLoading: isLoading,
|
||||||
productsError: error,
|
partyEventsError: error,
|
||||||
productsValidating: isValidating,
|
partyEventsValidating: isValidating,
|
||||||
productsEmpty: !isLoading && !isValidating && !data?.products.length,
|
partyEventsEmpty: !isLoading && !isValidating && !data?.partyEvents.length,
|
||||||
}),
|
}),
|
||||||
[data?.products, error, isLoading, isValidating]
|
[data?.partyEvents, error, isLoading, isValidating]
|
||||||
);
|
);
|
||||||
|
|
||||||
return memoizedValue;
|
return memoizedValue;
|
||||||
@@ -42,7 +46,7 @@ export function useGetProducts() {
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type ProductData = {
|
type ProductData = {
|
||||||
product: IProductItem;
|
product: IPartyEventItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useGetPartyEvent(productId: string) {
|
export function useGetPartyEvent(productId: string) {
|
||||||
@@ -67,7 +71,7 @@ export function useGetPartyEvent(productId: string) {
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type SearchResultsData = {
|
type SearchResultsData = {
|
||||||
results: IProductItem[];
|
results: IPartyEventItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function useSearchProducts(query: string) {
|
export function useSearchProducts(query: string) {
|
||||||
@@ -94,7 +98,7 @@ export function useSearchProducts(query: string) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export async function createProduct(productData: IProductItem) {
|
export async function createProduct(productData: IPartyEventItem) {
|
||||||
/**
|
/**
|
||||||
* Work on server
|
* Work on server
|
||||||
*/
|
*/
|
||||||
@@ -109,7 +113,7 @@ export async function createProduct(productData: IProductItem) {
|
|||||||
mutate(
|
mutate(
|
||||||
endpoints.product.list,
|
endpoints.product.list,
|
||||||
(currentData: any) => {
|
(currentData: any) => {
|
||||||
const currentProducts: IProductItem[] = currentData?.products;
|
const currentProducts: IPartyEventItem[] = currentData?.products;
|
||||||
|
|
||||||
const products = [...currentProducts, { ...productData, id }];
|
const products = [...currentProducts, { ...productData, id }];
|
||||||
|
|
||||||
@@ -121,7 +125,7 @@ export async function createProduct(productData: IProductItem) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export async function updateProduct(productData: Partial<IProductItem>) {
|
export async function updateProduct(productData: Partial<IPartyEventItem>) {
|
||||||
/**
|
/**
|
||||||
* Work on server
|
* Work on server
|
||||||
*/
|
*/
|
||||||
@@ -135,7 +139,7 @@ export async function updateProduct(productData: Partial<IProductItem>) {
|
|||||||
mutate(
|
mutate(
|
||||||
endpoints.product.list,
|
endpoints.product.list,
|
||||||
(currentData: any) => {
|
(currentData: any) => {
|
||||||
const currentProducts: IProductItem[] = currentData?.products;
|
const currentProducts: IPartyEventItem[] = currentData?.products;
|
||||||
|
|
||||||
const products = currentProducts.map((product) =>
|
const products = currentProducts.map((product) =>
|
||||||
product.id === productData.id ? { ...product, ...productData } : product
|
product.id === productData.id ? { ...product, ...productData } : product
|
||||||
@@ -149,7 +153,7 @@ export async function updateProduct(productData: Partial<IProductItem>) {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export async function deleteProduct(productId: string) {
|
export async function deletePartyEvent(productId: string) {
|
||||||
/**
|
/**
|
||||||
* Work on server
|
* Work on server
|
||||||
*/
|
*/
|
||||||
@@ -164,7 +168,7 @@ export async function deleteProduct(productId: string) {
|
|||||||
endpoints.product.list,
|
endpoints.product.list,
|
||||||
(currentData: any) => {
|
(currentData: any) => {
|
||||||
console.log({ currentData });
|
console.log({ currentData });
|
||||||
const currentProducts: IProductItem[] = currentData?.products;
|
const currentProducts: IPartyEventItem[] = currentData?.products;
|
||||||
|
|
||||||
const products = currentProducts.filter((product) => product.id !== productId);
|
const products = currentProducts.filter((product) => product.id !== productId);
|
||||||
|
|
||||||
|
@@ -84,4 +84,12 @@ export const endpoints = {
|
|||||||
changeStatus: (invoiceId: string) => `/api/invoice/changeStatus?invoiceId=${invoiceId}`,
|
changeStatus: (invoiceId: string) => `/api/invoice/changeStatus?invoiceId=${invoiceId}`,
|
||||||
search: '/api/invoice/search',
|
search: '/api/invoice/search',
|
||||||
},
|
},
|
||||||
|
partyEvent: {
|
||||||
|
list: '/api/party-event/list',
|
||||||
|
details: '/api/party-event/details',
|
||||||
|
search: '/api/party-event/search',
|
||||||
|
create: '/api/party-event/create',
|
||||||
|
update: '/api/party-event/update',
|
||||||
|
delete: '/api/party-event/delete',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@@ -9,12 +9,12 @@ import {
|
|||||||
} from 'src/components/carousel';
|
} from 'src/components/carousel';
|
||||||
import { Image } from 'src/components/image';
|
import { Image } from 'src/components/image';
|
||||||
import { Lightbox, useLightBox } from 'src/components/lightbox';
|
import { Lightbox, useLightBox } from 'src/components/lightbox';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
images?: IProductItem['images'];
|
images?: IPartyEventItem['images'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ProductDetailsCarousel({ images }: Props) {
|
export function ProductDetailsCarousel({ images }: Props) {
|
||||||
|
@@ -17,13 +17,13 @@ import { NumberInput } from 'src/components/number-input';
|
|||||||
import { useRouter } from 'src/routes/hooks';
|
import { useRouter } from 'src/routes/hooks';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { CheckoutContextValue } from 'src/types/checkout';
|
import type { CheckoutContextValue } from 'src/types/checkout';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { fCurrency, fShortenNumber } from 'src/utils/format-number';
|
import { fCurrency, fShortenNumber } from 'src/utils/format-number';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
product: IProductItem;
|
product: IPartyEventItem;
|
||||||
disableActions?: boolean;
|
disableActions?: boolean;
|
||||||
items?: CheckoutContextValue['state']['items'];
|
items?: CheckoutContextValue['state']['items'];
|
||||||
onAddToCart?: CheckoutContextValue['onAddToCart'];
|
onAddToCart?: CheckoutContextValue['onAddToCart'];
|
||||||
|
@@ -9,14 +9,14 @@ import { Iconify } from 'src/components/iconify';
|
|||||||
import { Image } from 'src/components/image';
|
import { Image } from 'src/components/image';
|
||||||
import { Label } from 'src/components/label';
|
import { Label } from 'src/components/label';
|
||||||
import { RouterLink } from 'src/routes/components';
|
import { RouterLink } from 'src/routes/components';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { fCurrency } from 'src/utils/format-number';
|
import { fCurrency } from 'src/utils/format-number';
|
||||||
import { useCheckoutContext } from '../checkout/context';
|
import { useCheckoutContext } from '../checkout/context';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
product: IProductItem;
|
product: IPartyEventItem;
|
||||||
detailsHref: string;
|
detailsHref: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import type { BoxProps } from '@mui/material/Box';
|
|||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Pagination, { paginationClasses } from '@mui/material/Pagination';
|
import Pagination, { paginationClasses } from '@mui/material/Pagination';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { ProductItem } from './party-event-item';
|
import { ProductItem } from './party-event-item';
|
||||||
import { ProductItemSkeleton } from './party-event-skeleton';
|
import { ProductItemSkeleton } from './party-event-skeleton';
|
||||||
|
|
||||||
@@ -10,10 +10,10 @@ import { ProductItemSkeleton } from './party-event-skeleton';
|
|||||||
|
|
||||||
type Props = BoxProps & {
|
type Props = BoxProps & {
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
products: IProductItem[];
|
products: IPartyEventItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ProductList({ products, loading, sx, ...other }: Props) {
|
export function PartyEventList({ products, loading, sx, ...other }: Props) {
|
||||||
const renderLoading = () => <ProductItemSkeleton />;
|
const renderLoading = () => <ProductItemSkeleton />;
|
||||||
|
|
||||||
const renderList = () =>
|
const renderList = () =>
|
||||||
|
@@ -27,7 +27,7 @@ import { Iconify } from 'src/components/iconify';
|
|||||||
import { toast } from 'src/components/snackbar';
|
import { toast } from 'src/components/snackbar';
|
||||||
import { useRouter } from 'src/routes/hooks';
|
import { useRouter } from 'src/routes/hooks';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { fileToBase64 } from 'src/utils/file-to-base64';
|
import { fileToBase64 } from 'src/utils/file-to-base64';
|
||||||
import { z as zod } from 'zod';
|
import { z as zod } from 'zod';
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ export const NewProductSchema = zod.object({
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
currentProduct?: IProductItem;
|
currentProduct?: IPartyEventItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ProductNewEditForm({ currentProduct }: Props) {
|
export function ProductNewEditForm({ currentProduct }: Props) {
|
||||||
@@ -202,7 +202,7 @@ export function ProductNewEditForm({ currentProduct }: Props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const sanitizedValues: IProductItem = values as unknown as IProductItem;
|
const sanitizedValues: IPartyEventItem = values as unknown as IPartyEventItem;
|
||||||
|
|
||||||
if (currentProduct) {
|
if (currentProduct) {
|
||||||
// perform save
|
// perform save
|
||||||
|
@@ -15,7 +15,7 @@ import { Iconify } from 'src/components/iconify';
|
|||||||
import { SearchNotFound } from 'src/components/search-not-found';
|
import { SearchNotFound } from 'src/components/search-not-found';
|
||||||
import { RouterLink } from 'src/routes/components';
|
import { RouterLink } from 'src/routes/components';
|
||||||
import { useRouter } from 'src/routes/hooks';
|
import { useRouter } from 'src/routes/hooks';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ export function ProductSearch({ redirectPath, sx }: Props) {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [selectedItem, setSelectedItem] = useState<IProductItem | null>(null);
|
const [selectedItem, setSelectedItem] = useState<IPartyEventItem | null>(null);
|
||||||
|
|
||||||
const debouncedQuery = useDebounce(searchQuery);
|
const debouncedQuery = useDebounce(searchQuery);
|
||||||
const { searchResults: options, searchLoading: loading } = useSearchProducts(debouncedQuery);
|
const { searchResults: options, searchLoading: loading } = useSearchProducts(debouncedQuery);
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(item: IProductItem | null) => {
|
(item: IPartyEventItem | null) => {
|
||||||
setSelectedItem(item);
|
setSelectedItem(item);
|
||||||
if (item) {
|
if (item) {
|
||||||
router.push(redirectPath(item.id));
|
router.push(redirectPath(item.id));
|
||||||
@@ -45,7 +45,7 @@ export function ProductSearch({ redirectPath, sx }: Props) {
|
|||||||
|
|
||||||
const filterOptions = createFilterOptions({
|
const filterOptions = createFilterOptions({
|
||||||
matchFrom: 'any',
|
matchFrom: 'any',
|
||||||
stringify: (option: IProductItem) => `${option.name} ${option.sku}`,
|
stringify: (option: IPartyEventItem) => `${option.name} ${option.sku}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const paperStyles: SxProps<Theme> = {
|
const paperStyles: SxProps<Theme> = {
|
||||||
|
@@ -25,7 +25,7 @@ type Props = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ProductTableToolbar({ filters, options }: Props) {
|
export function PartyEventTableToolbar({ filters, options }: Props) {
|
||||||
const menuActions = usePopover();
|
const menuActions = usePopover();
|
||||||
|
|
||||||
const { state: currentFilters, setState: updateFilters } = filters;
|
const { state: currentFilters, setState: updateFilters } = filters;
|
||||||
|
@@ -17,7 +17,7 @@ import { Iconify } from 'src/components/iconify';
|
|||||||
import { DashboardContent } from 'src/layouts/dashboard';
|
import { DashboardContent } from 'src/layouts/dashboard';
|
||||||
import { RouterLink } from 'src/routes/components';
|
import { RouterLink } from 'src/routes/components';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { ProductDetailsCarousel } from '../party-event-details-carousel';
|
import { ProductDetailsCarousel } from '../party-event-details-carousel';
|
||||||
import { ProductDetailsDescription } from '../party-event-details-description';
|
import { ProductDetailsDescription } from '../party-event-details-description';
|
||||||
import { ProductDetailsReview } from '../party-event-details-review';
|
import { ProductDetailsReview } from '../party-event-details-review';
|
||||||
@@ -48,7 +48,7 @@ const SUMMARY = [
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
product?: IProductItem;
|
product?: IPartyEventItem;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
error?: any;
|
error?: any;
|
||||||
};
|
};
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
||||||
import { DashboardContent } from 'src/layouts/dashboard';
|
import { DashboardContent } from 'src/layouts/dashboard';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { ProductNewEditForm } from '../party-event-new-edit-form';
|
import { ProductNewEditForm } from '../party-event-new-edit-form';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
product?: IProductItem;
|
product?: IPartyEventItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function PartyEventEditView({ product }: Props) {
|
export function PartyEventEditView({ product }: Props) {
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
// src/sections/product/view/product-list-view.tsx
|
// src/sections/party-event/view/party-event-list-view.tsx
|
||||||
|
//
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
@@ -28,7 +29,7 @@ import { useBoolean, useSetState } from 'minimal-shared/hooks';
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
// import { PRODUCT_STOCK_OPTIONS } from 'src/_mock';
|
// import { PRODUCT_STOCK_OPTIONS } from 'src/_mock';
|
||||||
import { deleteProduct, useGetProducts } from 'src/actions/party-event';
|
import { deletePartyEvent, useGetPartyEvents } from 'src/actions/party-event';
|
||||||
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
import { CustomBreadcrumbs } from 'src/components/custom-breadcrumbs';
|
||||||
import { ConfirmDialog } from 'src/components/custom-dialog';
|
import { ConfirmDialog } from 'src/components/custom-dialog';
|
||||||
import { EmptyContent } from 'src/components/empty-content';
|
import { EmptyContent } from 'src/components/empty-content';
|
||||||
@@ -38,7 +39,7 @@ import { DashboardContent } from 'src/layouts/dashboard';
|
|||||||
import { endpoints } from 'src/lib/axios';
|
import { endpoints } from 'src/lib/axios';
|
||||||
import { RouterLink } from 'src/routes/components';
|
import { RouterLink } from 'src/routes/components';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem, IProductTableFilters } from 'src/types/party-event';
|
import type { IPartyEventItem, IProductTableFilters } from 'src/types/party-event';
|
||||||
import { mutate } from 'swr';
|
import { mutate } from 'swr';
|
||||||
import { ProductTableFiltersResult } from '../party-event-table-filters-result';
|
import { ProductTableFiltersResult } from '../party-event-table-filters-result';
|
||||||
import {
|
import {
|
||||||
@@ -48,7 +49,7 @@ import {
|
|||||||
RenderCellPublish,
|
RenderCellPublish,
|
||||||
RenderCellStock,
|
RenderCellStock,
|
||||||
} from '../party-event-table-row';
|
} from '../party-event-table-row';
|
||||||
import { ProductTableToolbar } from '../party-event-table-toolbar';
|
import { PartyEventTableToolbar } from '../party-event-table-toolbar';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -79,9 +80,9 @@ export function PartyEventListView() {
|
|||||||
const confirmDeleteSingleItemDialog = useBoolean();
|
const confirmDeleteSingleItemDialog = useBoolean();
|
||||||
const [idToDelete, setIdToDelete] = useState<string | null>(null);
|
const [idToDelete, setIdToDelete] = useState<string | null>(null);
|
||||||
|
|
||||||
const { products, productsLoading } = useGetProducts();
|
const { partyEvents, partyEventsLoading } = useGetPartyEvents();
|
||||||
|
|
||||||
const [tableData, setTableData] = useState<IProductItem[]>(products);
|
const [tableData, setTableData] = useState<IPartyEventItem[]>(partyEvents);
|
||||||
const [selectedRowIds, setSelectedRowIds] = useState<GridRowSelectionModel>([]);
|
const [selectedRowIds, setSelectedRowIds] = useState<GridRowSelectionModel>([]);
|
||||||
const [filterButtonEl, setFilterButtonEl] = useState<HTMLButtonElement | null>(null);
|
const [filterButtonEl, setFilterButtonEl] = useState<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
@@ -92,10 +93,10 @@ export function PartyEventListView() {
|
|||||||
useState<GridColumnVisibilityModel>(HIDE_COLUMNS);
|
useState<GridColumnVisibilityModel>(HIDE_COLUMNS);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (products.length) {
|
if (partyEvents.length) {
|
||||||
setTableData(products);
|
setTableData(partyEvents);
|
||||||
}
|
}
|
||||||
}, [products]);
|
}, [partyEvents]);
|
||||||
|
|
||||||
const canReset = currentFilters.publish.length > 0 || currentFilters.stock.length > 0;
|
const canReset = currentFilters.publish.length > 0 || currentFilters.stock.length > 0;
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ export function PartyEventListView() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (idToDelete) {
|
if (idToDelete) {
|
||||||
await deleteProduct(idToDelete);
|
await deletePartyEvent(idToDelete);
|
||||||
toast.success('Delete success!');
|
toast.success('Delete success!');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -125,10 +126,10 @@ export function PartyEventListView() {
|
|||||||
const handleDeleteRow = useCallback(
|
const handleDeleteRow = useCallback(
|
||||||
async (id: string) => {
|
async (id: string) => {
|
||||||
try {
|
try {
|
||||||
await deleteProduct(id);
|
await deletePartyEvent(id);
|
||||||
|
|
||||||
// invalidate cache to reload list
|
// invalidate cache to reload list
|
||||||
await mutate(endpoints.product.list);
|
await mutate(endpoints.partyEvent.list);
|
||||||
|
|
||||||
toast.success('Delete success!');
|
toast.success('Delete success!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -167,12 +168,15 @@ export function PartyEventListView() {
|
|||||||
{ field: 'category', headerName: t('Category'), filterable: false },
|
{ field: 'category', headerName: t('Category'), filterable: false },
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
headerName: t('Product'),
|
headerName: t('Party Event'),
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minWidth: 360,
|
minWidth: 360,
|
||||||
hideable: false,
|
hideable: false,
|
||||||
renderCell: (params) => (
|
renderCell: (params) => (
|
||||||
<RenderCellProduct params={params} href={paths.dashboard.product.details(params.row.id)} />
|
<RenderCellProduct
|
||||||
|
params={params}
|
||||||
|
href={paths.dashboard.partyEvent.details(params.row.id)}
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -220,13 +224,13 @@ export function PartyEventListView() {
|
|||||||
showInMenu
|
showInMenu
|
||||||
icon={<Iconify icon="solar:eye-bold" />}
|
icon={<Iconify icon="solar:eye-bold" />}
|
||||||
label="View"
|
label="View"
|
||||||
href={paths.dashboard.product.details(params.row.id)}
|
href={paths.dashboard.partyEvent.details(params.row.id)}
|
||||||
/>,
|
/>,
|
||||||
<GridActionsLinkItem
|
<GridActionsLinkItem
|
||||||
showInMenu
|
showInMenu
|
||||||
icon={<Iconify icon="solar:pen-bold" />}
|
icon={<Iconify icon="solar:pen-bold" />}
|
||||||
label="Edit"
|
label="Edit"
|
||||||
href={paths.dashboard.product.edit(params.row.id)}
|
href={paths.dashboard.partyEvent.edit(params.row.id)}
|
||||||
/>,
|
/>,
|
||||||
<GridActionsCellItem
|
<GridActionsCellItem
|
||||||
showInMenu
|
showInMenu
|
||||||
@@ -251,7 +255,7 @@ export function PartyEventListView() {
|
|||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={confirmDeleteMultiItemsDialog.value}
|
open={confirmDeleteMultiItemsDialog.value}
|
||||||
onClose={confirmDeleteMultiItemsDialog.onFalse}
|
onClose={confirmDeleteMultiItemsDialog.onFalse}
|
||||||
title="Delete multiple products"
|
title="Delete multiple party events"
|
||||||
content={
|
content={
|
||||||
<>
|
<>
|
||||||
Are you sure want to delete <strong> {selectedRowIds.length} </strong> items?
|
Are you sure want to delete <strong> {selectedRowIds.length} </strong> items?
|
||||||
@@ -277,7 +281,7 @@ export function PartyEventListView() {
|
|||||||
<ConfirmDialog
|
<ConfirmDialog
|
||||||
open={confirmDeleteSingleItemDialog.value}
|
open={confirmDeleteSingleItemDialog.value}
|
||||||
onClose={confirmDeleteSingleItemDialog.onFalse}
|
onClose={confirmDeleteSingleItemDialog.onFalse}
|
||||||
title="Delete product"
|
title="Delete party event"
|
||||||
content={<>Are you sure want to delete item?</>}
|
content={<>Are you sure want to delete item?</>}
|
||||||
action={
|
action={
|
||||||
<Button
|
<Button
|
||||||
@@ -303,17 +307,17 @@ export function PartyEventListView() {
|
|||||||
heading={t('Product List')}
|
heading={t('Product List')}
|
||||||
links={[
|
links={[
|
||||||
{ name: t('Dashboard'), href: paths.dashboard.root },
|
{ name: t('Dashboard'), href: paths.dashboard.root },
|
||||||
{ name: t('Product'), href: paths.dashboard.product.root },
|
{ name: t('Product'), href: paths.dashboard.partyEvent.root },
|
||||||
{ name: t('List') },
|
{ name: t('List') },
|
||||||
]}
|
]}
|
||||||
action={
|
action={
|
||||||
<Button
|
<Button
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
href={paths.dashboard.product.new}
|
href={paths.dashboard.partyEvent.new}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
startIcon={<Iconify icon="mingcute:add-line" />}
|
startIcon={<Iconify icon="mingcute:add-line" />}
|
||||||
>
|
>
|
||||||
{t('new-product')}
|
{t('new-party-event')}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
sx={{ mb: { xs: 3, md: 5 } }}
|
sx={{ mb: { xs: 3, md: 5 } }}
|
||||||
@@ -333,7 +337,7 @@ export function PartyEventListView() {
|
|||||||
disableRowSelectionOnClick
|
disableRowSelectionOnClick
|
||||||
rows={dataFiltered}
|
rows={dataFiltered}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
loading={productsLoading}
|
loading={partyEventsLoading}
|
||||||
getRowHeight={() => 'auto'}
|
getRowHeight={() => 'auto'}
|
||||||
pageSizeOptions={[5, 10, 20, { value: -1, label: 'All' }]}
|
pageSizeOptions={[5, 10, 20, { value: -1, label: 'All' }]}
|
||||||
initialState={{ pagination: { paginationModel: { pageSize: 10 } } }}
|
initialState={{ pagination: { paginationModel: { pageSize: 10 } } }}
|
||||||
@@ -402,7 +406,7 @@ function CustomToolbar({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<GridToolbarContainer>
|
<GridToolbarContainer>
|
||||||
<ProductTableToolbar
|
<PartyEventTableToolbar
|
||||||
filters={filters}
|
filters={filters}
|
||||||
options={{ stocks: PRODUCT_STOCK_OPTIONS, publishs: PUBLISH_OPTIONS }}
|
options={{ stocks: PRODUCT_STOCK_OPTIONS, publishs: PUBLISH_OPTIONS }}
|
||||||
/>
|
/>
|
||||||
@@ -474,7 +478,7 @@ export function GridActionsLinkItem({ ref, href, label, icon, sx }: GridActionsL
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type ApplyFilterProps = {
|
type ApplyFilterProps = {
|
||||||
inputData: IProductItem[];
|
inputData: IPartyEventItem[];
|
||||||
filters: IProductTableFilters;
|
filters: IProductTableFilters;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -482,11 +486,11 @@ function applyFilter({ inputData, filters }: ApplyFilterProps) {
|
|||||||
const { stock, publish } = filters;
|
const { stock, publish } = filters;
|
||||||
|
|
||||||
if (stock.length) {
|
if (stock.length) {
|
||||||
inputData = inputData.filter((product) => stock.includes(product.inventoryType));
|
inputData = inputData.filter((partyEvent) => stock.includes(partyEvent.inventoryType));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publish.length) {
|
if (publish.length) {
|
||||||
inputData = inputData.filter((product) => publish.includes(product.publish));
|
inputData = inputData.filter((partyEvent) => publish.includes(partyEvent.publish));
|
||||||
}
|
}
|
||||||
|
|
||||||
return inputData;
|
return inputData;
|
||||||
|
@@ -15,7 +15,7 @@ import { EmptyContent } from 'src/components/empty-content';
|
|||||||
import { Iconify } from 'src/components/iconify';
|
import { Iconify } from 'src/components/iconify';
|
||||||
import { RouterLink } from 'src/routes/components';
|
import { RouterLink } from 'src/routes/components';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem } from 'src/types/party-event';
|
||||||
import { useCheckoutContext } from '../../checkout/context';
|
import { useCheckoutContext } from '../../checkout/context';
|
||||||
import { CartIcon } from '../cart-icon';
|
import { CartIcon } from '../cart-icon';
|
||||||
import { ProductDetailsCarousel } from '../party-event-details-carousel';
|
import { ProductDetailsCarousel } from '../party-event-details-carousel';
|
||||||
@@ -47,7 +47,7 @@ const SUMMARY = [
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
product?: IProductItem;
|
product?: IPartyEventItem;
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
error?: any;
|
error?: any;
|
||||||
};
|
};
|
||||||
|
@@ -14,19 +14,19 @@ import {
|
|||||||
} from 'src/_mock';
|
} from 'src/_mock';
|
||||||
import { EmptyContent } from 'src/components/empty-content';
|
import { EmptyContent } from 'src/components/empty-content';
|
||||||
import { paths } from 'src/routes/paths';
|
import { paths } from 'src/routes/paths';
|
||||||
import type { IProductFilters, IProductItem } from 'src/types/party-event';
|
import type { IPartyEventItem, IProductFilters } from 'src/types/party-event';
|
||||||
import { useCheckoutContext } from '../../checkout/context';
|
import { useCheckoutContext } from '../../checkout/context';
|
||||||
import { CartIcon } from '../cart-icon';
|
import { CartIcon } from '../cart-icon';
|
||||||
import { ProductFiltersDrawer } from '../party-event-filters-drawer';
|
import { ProductFiltersDrawer } from '../party-event-filters-drawer';
|
||||||
import { ProductFiltersResult } from '../party-event-filters-result';
|
import { ProductFiltersResult } from '../party-event-filters-result';
|
||||||
import { ProductList } from '../party-event-list';
|
import { PartyEventList } from '../party-event-list';
|
||||||
import { ProductSearch } from '../party-event-search';
|
import { ProductSearch } from '../party-event-search';
|
||||||
import { ProductSort } from '../party-event-sort';
|
import { ProductSort } from '../party-event-sort';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
products: IProductItem[];
|
products: IPartyEventItem[];
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ export function ProductShopView({ products, loading }: Props) {
|
|||||||
{notFound || isEmpty ? (
|
{notFound || isEmpty ? (
|
||||||
renderNotFound()
|
renderNotFound()
|
||||||
) : (
|
) : (
|
||||||
<ProductList products={dataFiltered} loading={loading} />
|
<PartyEventList products={dataFiltered} loading={loading} />
|
||||||
)}
|
)}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
@@ -132,7 +132,7 @@ export function ProductShopView({ products, loading }: Props) {
|
|||||||
type ApplyFilterProps = {
|
type ApplyFilterProps = {
|
||||||
sortBy: string;
|
sortBy: string;
|
||||||
filters: IProductFilters;
|
filters: IProductFilters;
|
||||||
inputData: IProductItem[];
|
inputData: IPartyEventItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
function applyFilter({ inputData, filters, sortBy }: ApplyFilterProps) {
|
function applyFilter({ inputData, filters, sortBy }: ApplyFilterProps) {
|
||||||
|
@@ -27,7 +27,7 @@ export type IProductReview = {
|
|||||||
attachments?: string[];
|
attachments?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type IProductItem = {
|
export type IPartyEventItem = {
|
||||||
id: string;
|
id: string;
|
||||||
createdAt: IDateValue;
|
createdAt: IDateValue;
|
||||||
//
|
//
|
||||||
|
Reference in New Issue
Block a user