Refactor ProductItemProps type definition
Moved `ProductItemProps` from `product-item.tsx` to `product-service.ts` for centralized access. Updated `product-item.tsx` to import the type from the new location. Adjusted imports in `products-view.tsx` to streamline dependencies and reduce redundancy. This improves code organization and maintains a single source of truth for the `ProductItemProps` type.
This commit is contained in:
parent
a155c991c6
commit
b7c5734a1b
@ -1,4 +1,12 @@
|
|||||||
import { ProductItemProps } from "src/sections/product/product-item";
|
export type ProductItemProps = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
price: number;
|
||||||
|
status: string;
|
||||||
|
coverUrl: string;
|
||||||
|
colors: string[];
|
||||||
|
priceSale: number | null;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* send a request to the server to get the products
|
* send a request to the server to get the products
|
||||||
|
|||||||
@ -8,21 +8,13 @@ import Typography from '@mui/material/Typography';
|
|||||||
|
|
||||||
import { fCurrency } from 'src/utils/format-number';
|
import { fCurrency } from 'src/utils/format-number';
|
||||||
|
|
||||||
|
import { ProductItemProps } from 'src/api/product-service';
|
||||||
|
|
||||||
import { Label } from 'src/components/label';
|
import { Label } from 'src/components/label';
|
||||||
import { ColorPreview } from 'src/components/color-utils';
|
import { ColorPreview } from 'src/components/color-utils';
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
export type ProductItemProps = {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
price: number;
|
|
||||||
status: string;
|
|
||||||
coverUrl: string;
|
|
||||||
colors: string[];
|
|
||||||
priceSale: number | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function ProductItem({ product }: { product: ProductItemProps }) {
|
export function ProductItem({ product }: { product: ProductItemProps }) {
|
||||||
const renderStatus = (
|
const renderStatus = (
|
||||||
<Label
|
<Label
|
||||||
|
|||||||
@ -6,13 +6,13 @@ import Pagination from '@mui/material/Pagination';
|
|||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
|
|
||||||
import { _products } from 'src/_mock';
|
import { _products } from 'src/_mock';
|
||||||
import { getProducts } from 'src/api/product-service';
|
|
||||||
import { DashboardContent } from 'src/layouts/dashboard';
|
import { DashboardContent } from 'src/layouts/dashboard';
|
||||||
|
import { getProducts, ProductItemProps } from 'src/api/product-service';
|
||||||
|
|
||||||
import { ProductSort } from '../product-sort';
|
import { ProductSort } from '../product-sort';
|
||||||
|
import { ProductItem } from '../product-item';
|
||||||
import { CartIcon } from '../product-cart-widget';
|
import { CartIcon } from '../product-cart-widget';
|
||||||
import { ProductFilters } from '../product-filters';
|
import { ProductFilters } from '../product-filters';
|
||||||
import { ProductItem, ProductItemProps } from '../product-item';
|
|
||||||
|
|
||||||
import type { FiltersProps } from '../product-filters';
|
import type { FiltersProps } from '../product-filters';
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user