Skip to content

Commit

Permalink
#10 [ Sonarcloud ] check all code
Browse files Browse the repository at this point in the history
  • Loading branch information
fdhhhdjd committed Oct 20, 2023
1 parent dcc8c92 commit 921c9cd
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/app/categories/[categoryId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useEffect } from 'react';

import Error from '../../error';
import ErrorPage from '../../error';

import { fetchDetailCategory } from '@/src/api/categories/GET';
import Border from '@/src/components/Border';
Expand Down Expand Up @@ -50,7 +50,7 @@ const CategoryIdPage = (props: PageProps) => {

if (isError) {
return (
<Error
<ErrorPage
error={{
message: 'Error page Category Detail',
}}
Expand Down
4 changes: 2 additions & 2 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface ErrorProps {
reset: () => void;
}

const Error: React.FC<ErrorProps> = ({ error, reset }) => {
const ErrorPage: React.FC<ErrorProps> = ({ error, reset }) => {
useEffect(() => {
console.error(error);
}, [error]);
Expand All @@ -28,4 +28,4 @@ const Error: React.FC<ErrorProps> = ({ error, reset }) => {
);
};

export default Error;
export default ErrorPage;
4 changes: 2 additions & 2 deletions src/components/CategorySection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CategoryCard } from './cards/CategoryCard';
import Loader from './loaders/Loader';
import NotFoundText from './NotFoundText';
import { fetchAllCategory } from '../api/categories/GET';
import Error from '../app/error';
import ErrorPage from '../app/error';

const CategorySection = ({
displaySeeAllButton = true,
Expand All @@ -33,7 +33,7 @@ const CategorySection = ({

if (isError) {
return (
<Error
<ErrorPage
error={{
message: 'Error page CategorySection',
}}
Expand Down
24 changes: 11 additions & 13 deletions src/components/sections/AllProductsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Loader from '../loaders/Loader';
import ProductGrids from '../ProductGrids';

import { fetchAllProducts } from '@/src/api/products/GET';
import Error from '@/src/app/error';
import ErrorPage from '@/src/app/error';
import { PRODUCTS_PER_PAGE } from '@/src/utils/constants';

interface Props {
Expand All @@ -33,7 +33,7 @@ const AllProductsSection = ({ page }: Props) => {

if (isError) {
return (
<Error
<ErrorPage
error={{
message: 'Error page CategorySection',
}}
Expand All @@ -43,17 +43,15 @@ const AllProductsSection = ({ page }: Props) => {
}

return (
<>
<div className="sm:mx-3 px-2 sm:py-10 py-5">
<h2 className="mx-auto max-w-6xl text-2xl font-black mb-4">All Available Products:</h2>
<ProductGrids products={products} />
<PaginationButtons
currentPage={page}
route="/products"
disableNextPage={products.length < PRODUCTS_PER_PAGE}
/>
</div>
</>
<div className="sm:mx-3 px-2 sm:py-10 py-5">
<h2 className="mx-auto max-w-6xl text-2xl font-black mb-4">All Available Products:</h2>
<ProductGrids products={products} />
<PaginationButtons
currentPage={page}
route="/products"
disableNextPage={products.length < PRODUCTS_PER_PAGE}
/>
</div>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/PopularProductsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Loader from '../loaders/Loader';
import ProductGrids from '../ProductGrids';

import { fetchAllProducts } from '@/src/api/products/GET';
import Error from '@/src/app/error';
import ErrorPage from '@/src/app/error';

const ProductComponent = () => {
const skip = 1;
Expand All @@ -29,7 +29,7 @@ const ProductComponent = () => {

if (isError) {
return (
<Error
<ErrorPage
error={{
message: 'Error page CategorySection',
}}
Expand Down
4 changes: 2 additions & 2 deletions src/components/sections/ProductSuggestionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ProductGrids from '../ProductGrids';

import { fetchDetailCategory } from '@/src/api/categories/GET';
import { fetchAllProducts } from '@/src/api/products/GET';
import Error from '@/src/app/error';
import ErrorPage from '@/src/app/error';

interface ProductSuggestionSectionProps {
product: FullProductClient;
Expand Down Expand Up @@ -38,7 +38,7 @@ const ProductSuggestionSection = ({ product }: ProductSuggestionSectionProps) =>

if (isError) {
return (
<Error
<ErrorPage
error={{
message: 'Error page CategorySection',
}}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/numbers.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// display numbers with comma (form string)
export const displayNumbers = (num: number): string => num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
export const displayNumbers = (num: number): string => num.toString().replace(/((\d{3})+(?!$))/g, '$2,');
5 changes: 3 additions & 2 deletions src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type UserSession =
})
| undefined;

export interface FullProduct extends Product {
export interface FullProduct {
id: string;
name: string;
image: string;
Expand All @@ -17,7 +17,8 @@ export interface FullProduct extends Product {
};
}

export interface FullProductClient extends Omit<FullProduct, 'sizes' | 'createdAt' | 'updatedAt'> {
export interface FullProductClient {
id: string;
sizes: string[];
createdAt: string;
categoryId: string;
Expand Down

0 comments on commit 921c9cd

Please sign in to comment.