Skip to content

Commit

Permalink
Changes to be committed:
Browse files Browse the repository at this point in the history
	modified:   client/package-lock.json
	modified:   client/package.json
	modified:   client/src/pages/products/index.tsx
  • Loading branch information
Thith-thith committed Aug 25, 2023
1 parent 3641a67 commit 3d6a3d4
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 7 deletions.
72 changes: 72 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dependencies": {
"@solidjs/router": "^0.8.2",
"aos": "^2.3.4",
"axios": "^1.4.0",
"babel-preset-solid": "^1.7.4",
"flowbite": "^1.7.0",
"json-server": "^0.17.3",
Expand Down
33 changes: 26 additions & 7 deletions client/src/pages/products/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import { Component, For, createResource } from "solid-js";
import {
Component,
For,
createResource,
createSignal,
createEffect,
} from "solid-js";
import { A } from "@solidjs/router";
import Cards from "../../components/cards/Cards";
import axios from "axios";

const Products: Component = () => {
const fetchData = async () => {
const res = await fetch("https://cptdb.koompi.com/CoreProducts");
return res.json();
};
const [coreProducts] = createResource(fetchData);
// const fetchData = async () => {
// const res = await fetch("https://cptdb.koompi.com/CoreProducts");
// return res.json();
// };
// const [coreProducts] = createResource(fetchData);

const [data, setData] = createSignal([]);

createEffect(() => {
axios
.get("https://cptdb.koompi.com/CoreProducts")
.then((res) => {
console.log("res", res.data);
setData(res?.data);
})
.catch((err) => console.log(err));
});

return (
<div class="mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-2 lg:px-24 xl:px-24 2xl:px-2">
Expand Down Expand Up @@ -480,7 +499,7 @@ const Products: Component = () => {

<div class="lg:col-span-3">
<div class="grid md:grid-cols-3 gap-4 mt-4">
<For each={coreProducts()}>
<For each={data()}>
{(res) => {
return <Cards product={res} />;
}}
Expand Down

0 comments on commit 3d6a3d4

Please sign in to comment.