Skip to content

Commit

Permalink
chore:cleaned prettier issues + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
BuyankhuuTsCAl committed Oct 12, 2023
1 parent ef57265 commit 2f485e4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/app/storefront/helperFunction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ export async function filterProduct(productType) {
.select('*')
.eq('category', productType);

console.log(data);

return data;
}
6 changes: 5 additions & 1 deletion src/app/storefront/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ export default function App() {
{
name: 'All',
value: 'All',
count: 0,
},
{
name: 'Dog',
value: 'Dog',
count: 1,
},
{
name: 'Cat',
value: 'Cat',
count: 2,
},
{
name: 'Misc.',
value: 'Misc.',
count: 3,
},
];
const [filtredProduct, setFiltredProducts] = useState(null);
Expand All @@ -35,7 +39,7 @@ export default function App() {
<ButtonsContainer>
{buttons.map((type, index) => (
<ProductButtons
key={index}
key={type.count}
value={type.value}
setFiltredProducts={setFiltredProducts}
content={type.name}
Expand Down
23 changes: 20 additions & 3 deletions src/app/storefront/productButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
// 'use client';

import React, { useState } from 'react';

import { Button, Label, IndividualContainer } from './styles';

import { getProduct, filterProduct } from './helperFunction';

interface Product {
description: string;
category: string;
quantity: number;
photo: string;
product_id: number;
name: string;
updated_at: Date;
}
export default function ProductButtons(props: {
key: number;
value: string;
setFiltredProducts: Function;
setFiltredProducts: (category: Product[]) => void;
content: string;
}) {
const { key, value, content, setFiltredProducts } = props;
Expand All @@ -21,9 +32,15 @@ export default function ProductButtons(props: {
console.log(category);

if (category !== 'All') {
setFiltredProducts(await filterProduct(category));
const products = await filterProduct(category);
if (products !== null) {
setFiltredProducts(products);
}
} else {
setFiltredProducts(await getProduct());
const products = await getProduct();
if (products !== null) {
setFiltredProducts(products);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/InputFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default function InputFields(props: {
text: string;
placeholder: string;
inputType: string;
changeUserName: Function;
changePassword: Function;
changeUserName: (newUsername: string) => void;
changePassword: (newPassword: string) => void;
isPassword: boolean;
}) {
const {
Expand Down
4 changes: 2 additions & 2 deletions src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import InputFields from './InputFields';

export default function LoginForm(props: {
changeUserName: Function;
changePassword: Function;
changeUserName: (newUsername: string) => void;
changePassword: (newPassword: string) => void;
}) {
const { changeUserName, changePassword } = props;
return (
Expand Down

0 comments on commit 2f485e4

Please sign in to comment.