Sunday, November 2, 2025
  • Home
  • About Us
  • Disclaimer
  • Contact Us
  • Terms & Conditions
  • Privacy Policy
T3llam
  • Home
  • App
  • Mobile
    • IOS
  • Gaming
  • Computing
  • Tech
  • Services & Software
  • Home entertainment
No Result
View All Result
  • Home
  • App
  • Mobile
    • IOS
  • Gaming
  • Computing
  • Tech
  • Services & Software
  • Home entertainment
No Result
View All Result
T3llam
No Result
View All Result
Home Services & Software

Tips on how to construct Odoo class web page utilizing ReactJS

admin by admin
October 18, 2024
in Services & Software
0
Tips on how to construct Odoo class web page utilizing ReactJS
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter


Constructing an Odoo class web page utilizing React.js entails making a Odoo headless eCommerce answer that communicates with Odoo’s backend, sometimes by way of its Odoo REST API.

Introduction

Odoo Headless growth is a system that splits the frontend and backend of an Odoo e-commerce website, boosting its effectivity, velocity, and user-friendliness

This separation improves scalability through the use of the strengths of every half, resulting in a greater and extra satisfying person expertise.

Webkul Odoo REST API affords a varient of API endpoints that mean you can carry out totally different actions like ‘merchandise’, ‘category-list’, and ‘cart’ however we’ll work with the ‘category-list’ endpoint.

Getting Begin

We are going to information you thru this weblog step-by-step that easy methods to construct class web page utilizing Odoo REST API.

  1. Set up Tailwind CSS
  2. Setup React Router
  3. Configuring Odoo API
  4. Constructing the Class Web page Element
  5. Integrating the Element
  6. Operating Your Software

Assumption: We’re conversant in the Create React App and you’ve got setup the React Software.

Observe: We are going to arrange the undertaking with the title “odoo-category-page.“

Step 1: Set up Tailwind CSS

You want to implement the Tailwind CSS to efficient web page UI design.

1. Set up the tailwind CSS by way of npm: This command set up the tailwind CSS and Dev depencies. run the next command:

npm set up -D tailwindcss postcss autoprefixer

2. Initialize Tailwind CSS: This command creates a configuration file for Tailwind CSS.

npx tailwindcss init -p

3. Configure Tailwind CSS: Open the tailwind.config.js file and Exchange the content material with the next configuration to set the purge paths to your recordsdata:

/** @sort {import('tailwindcss').Config} */
module.exports = {
  content material: [
    "./src/**/*.{js,jsx,ts,tsx}", // Adjust if needed
  ],
  theme: {
    prolong: {
       colours: {
          main: "#35979C",
      },
    },
  },
  plugins: [],
}

4. Import Tailwind CSS: Within the src listing, open the index.css file and add the next traces to import tailwind’s base, parts, and utilities types.

@tailwind base;
@tailwind parts;
@tailwind utilities;

Over all setup the undertaking, and you’ll see the ultimate folder construction.

.
├── src/
│   ├── App.js
│   ├── App.css
│   ├── App.take a look at.js
|   ├── index.js
|   ├── index.css
│   └── emblem.svg
├── public/
│   ├── index.html
│   ├── emblem.svg
│   ├── robots.txt
│   └── manifest.json
├── package-lock.json
├── bundle.json
├── tailwind.config.js
└── README.md

Step 2: Setup the React Router

React Router is used to outline a number of routes within the software, so it is advisable to set up the react router library.

1. Set up the React Router: Run the next command in your undertaking listing.

npm set up react-router-dom

2. Mount React Router: Open App.js File and change the code to import BrowserRouter, Route, and Routes for displaying the router element.

import "./App.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Structure from "./pages/Structure";

perform App() {
  return (
    <>
      
        
          }>
             Render house web page } />
          
        
      
    >
  );
}

export default App;

After this you possibly can create the format for class web page and different pages like Odoo cart and Odoo product web page.

We’ll begin by making a file named Structure.js within the src/pages folder.

import { Outlet } from "react-router-dom";
import Header from "../parts/Header";
import Footer from "../parts/Footer";

const Structure = () => {
  return (
    <>
      {/* You may add the Header Right here */}
      
{/* You may add the Footer Right here */}
> ); }; export default Structure;

Step 3: Configuring Odoo API

1. Odoo Setup: Guarantee you have got entry to your Odoo occasion and the API Authenticate token.

const ODOO_URL = "Odoo_API_URL";
const Authenticate = "AUTH_TOKEN";

2. Create an API Helper: Create a file named index.js to deal with API requests within the src/fetcher listing .

const ODOO_URL = "Odoo_API_URL";
const Authenticate = "AUTH_TOKEN";

const callOdooApi = async ({ question, technique = "GET", variables }) => {
  attempt {
    const response = await fetch(`${ODOO_URL}/${question}`, {
      technique: technique,
      headers: {
        "Content material-Sort": "software/json",
        Authenticate: Authenticate,
      },
      bosy: JSON.stringify({
        ...(variables && variables),
      }),
    });
    const physique = await response.json();

    if (physique.errors) {
      throw physique.errors[0];
    }
    return {
      standing: response.standing,
      physique,
    };
  } catch (e) {
    console.log(e);
  }
};

export const fetchCategories = async () => {
  const res = await callOdooApi({
    question: "category-list",
    technique: "POST",
  });

  const end result = res.physique;
  return { end result };
};

export const getCollectionProducts = async (class) => {
  const deal with = {
    filter: { category_url: { eq: class } },
    search: "",
    pageSize: 12,
    currentPage: 1,
  };

  const res = await callOdooApi({
    question: "product-list",
    technique: "POST",
    variables: {
      ...deal with,
    },
  });
  const end result = res.physique;

  return { end result };
};

Step 4: Constructing the Class Web page Element

1.Create a Class Element: Create a brand new file Class.js within the src/pages/store/class.js

import { useEffect, useState } from "react";
import { Hyperlink, useParams } from "react-router-dom";
import { fetchCategories, getCollectionProducts } from "../../../fetcher";

const Class = () => {
  const { categorySlug } = useParams();
  const [products, setProducts] = useState([]);
  const [categories, setCategories] = useState([]);

  useEffect(() => {
    const fetchProducts = async () => {
      const { end result: classes } = await fetchCategories();
      setCategories(classes);
      const { end result } = await getCollectionProducts(categorySlug);
      setProducts(end result);
    };
    fetchProducts();
  }, [categorySlug]);

  const itemList = merchandise?.merchandise;
  const aggregations = merchandise?.aggregations;
  const categoryList = classes?.class;

  return (
    
{Array.isArray(aggregations) && aggregations?.map((aggregation, index) => aggregation?.attribute_code !== "value" ? ( ) : ( ) )}

{Array.isArray(categoryList) && categoryList?.map((cat, index) => ( {cat?.title} ))}

{itemList?.gadgets && Array.isArray(itemList?.gadgets) && itemList?.gadgets?.map((product, index) => (
{product?.name}

{product?.title}

${product?.price_range.minimum_price?.regular_price?.worth}

))}
); }; export default Class;

Step 5: Integrating the Element

1. Replace App.js: Import and render the Class.js element in your App.js.

RelatedPosts

The state of strategic portfolio administration

The state of strategic portfolio administration

June 11, 2025
You should utilize PSVR 2 controllers together with your Apple Imaginative and prescient Professional – however you’ll want to purchase a PSVR 2 headset as properly

You should utilize PSVR 2 controllers together with your Apple Imaginative and prescient Professional – however you’ll want to purchase a PSVR 2 headset as properly

June 11, 2025
Consumer Information For Magento 2 Market Limit Vendor Product

Consumer Information For Magento 2 Market Limit Vendor Product

June 11, 2025
import "./App.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Structure from "./pages/Structure";
import NoPage from "./pages/NoPage";
import Class from "./pages/Store/Class";

perform App() {
  return (
    
      
        }>
           Render house web page } />
          } />
          } />
        
      
    
  );
}

export default App;

Step 6: Operating Your Software

1. Begin the Improvement Server: Run the next command to begin your React app.

npm run begin
Terminal view for starrt react js server

2. View in Browser: Open your browser and navigate to http://localhost:3000/store/class/desks-1 to see your class web page in motion.

Final Output of the category page using react js

Conclusion

You’ve efficiently constructed a class web page utilizing React.js that fetches knowledge from Odoo! This strategy will be additional enhanced with options like sorting, and filtering to enhance person expertise.

We would require the Webkul Odoo REST APIs for headless growth companies with Webkul and you may also try our Open Supply Odoo React headless eCommerce Software.

Thanks for studying this weblog.

Comfortable Coding!

author-thumb


Abhishek Kumar
2 Badges

Abhishek Kumar, a talented software program engineer, makes a speciality of crafting immersive digital experiences. With a give attention to frontend growth, he excels in creating headless themes . Proficient in JavaScript and subsequent.js, Abhishek’s experience provides a novel and dynamic dimension to any undertaking, making certain a seamless and fascinating person journey.

Previous Post

Dinosaur Polo Membership Interview – CEO Amie Wolken on Mini Metro, Mini Motorways, the Staff, Free DLC, Working With Apple, Ports, and Extra – TouchArcade

Next Post

The MacRumors Present: iPad Mini 7 Is Right here!

Next Post
The MacRumors Present: iPad Mini 7 Is Right here!

The MacRumors Present: iPad Mini 7 Is Right here!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • App (3,061)
  • Computing (4,401)
  • Gaming (9,599)
  • Home entertainment (633)
  • IOS (9,534)
  • Mobile (11,881)
  • Services & Software (4,006)
  • Tech (5,315)
  • Uncategorized (4)

Recent Posts

  • WWDC 2025 Rumor Report Card: Which Leaks Had been Proper or Unsuitable?
  • The state of strategic portfolio administration
  • 51 of the Greatest TV Exhibits on Netflix That Will Maintain You Entertained
  • ‘We’re previous the occasion horizon’: Sam Altman thinks superintelligence is inside our grasp and makes 3 daring predictions for the way forward for AI and robotics
  • Snap will launch its AR glasses known as Specs subsequent 12 months, and these can be commercially accessible
  • App
  • Computing
  • Gaming
  • Home entertainment
  • IOS
  • Mobile
  • Services & Software
  • Tech
  • Uncategorized
  • Home
  • About Us
  • Disclaimer
  • Contact Us
  • Terms & Conditions
  • Privacy Policy

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • App
  • Mobile
    • IOS
  • Gaming
  • Computing
  • Tech
  • Services & Software
  • Home entertainment

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. However you may visit Cookie Settings to provide a controlled consent.
Cookie settingsACCEPT
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analyticsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functionalThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessaryThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-othersThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performanceThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policyThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Save & Accept