This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const algoliasearch= require("algoliasearch") | |
module.exports={ | |
getAlgoliaResults: function (request_object={},name){ | |
const SearchIndex=name=='name'?'Demo-Index-desc(name)':name=='price'?'Demo-Index-desc(price)':'Demo-Index' | |
return new Promise((resolve,reject)=>{ | |
algoliasearch(<APPLICATION ID>,<ADMIN API KEY>).initIndex(SearchIndex).search('',request_object).then(response=>{ | |
resolve(response) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const constants=require('../data') | |
const IndexManager=require('./algoliaIndexManager') | |
function getFieldObject(name,value=''){ | |
if(value===null){ | |
value='' | |
} | |
return{ | |
[name]:value | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { getWriteClient } =require('./algoliaClient') | |
class IndexManager { | |
constructor(name){ | |
if(!name){ | |
throw new Error('Algolia index name cannot be empty') | |
} | |
this.name=name | |
this.index=getWriteClient(name) | |
this.replaceAll=this.replaceAll.bind(this) | |
this.createReplica=this.createReplica.bind(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports={data:[ | |
{ | |
imgUrl :"https://guesseu.scene7.com/is/image/GuessEU/M63H24W7JF0-L302-ALTGHOST?wid=1500&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0", | |
name : "CHECK PRINT SHIRT", | |
price : 110, | |
facets:["Shirt",'All'] | |
}, | |
{ | |
imgUrl :"https://guesseu.scene7.com/is/image/GuessEU/FLGLO4FAL12-BEIBR?wid=700&fmt=jpeg&qlt=80&op_sharpen=0&op_usm=1.0,1.0,5,0&iccEmbed=0", | |
name : "GLORIA HIGH LOGO SNEAKER", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const algoliasearch=require('algoliasearch') | |
const getWriteClient=(name)=>{ | |
// API keys below contain actual values tied to your Algolia account | |
const client = algoliasearch(<Application Id>,<Admin API Key>) | |
return client.initIndex(name) | |
} | |
module.exports={ | |
getWriteClient | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './App.css'; | |
import { useState, useEffect } from 'react' | |
import { getAlgoliaResults,getAlgoliaSearchResults } from './adapter/algolia.adapter'; | |
function App() { | |
const [data,setData] = useState([]); | |
const[loading,setLoading]=useState(true); | |
const [inputQuery,setInputQuery]=useState(''); | |
useEffect(() => { | |
const loadData = async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const algoliasearch= require("algoliasearch") | |
module.exports={ | |
getAlgoliaResults: function (request_object={},name){ | |
const SearchIndex=name=='name'?'Demo-Index-desc(name)':name=='price'?'Demo-Index-desc(price)':'Demo-Index' | |
return new Promise((resolve,reject)=>{ | |
algoliasearch('AAFOFP264H','47a036007d9665e81cd85914d7b83913').initIndex(SearchIndex).search('',request_object).then(response=>{ | |
resolve(response) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
// import axios from 'axios'; | |
import {Stitch,RemoteMongoClient} from 'mongodb-stitch-browser-sdk'; | |
// import Products from '../../components/Products/Products'; | |
import BSON from 'bson'; | |
import './EditProduct.css'; | |
import Input from '../../components/Input/Input'; | |
import Button from '../../components/Button/Button'; | |
class ProductEditPage extends Component { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import axios from 'axios'; | |
import {Stitch,RemoteMongoClient} from 'mongodb-stitch-browser-sdk'; | |
// import Products from '../../components/Products/Products'; | |
import BSON from 'bson'; | |
import './Product.css'; | |
class ProductPage extends Component { | |
state = { isLoading: true, product: null }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import axios from 'axios'; | |
import {Stitch,RemoteMongoClient} from 'mongodb-stitch-browser-sdk'; | |
import Products from '../../components/Products/Products'; | |
import BSON from 'bson'; | |
class ProductsPage extends Component { | |
state = { isLoading: true, products: [] }; | |
componentDidMount() { | |
this.fetchData(); | |
} |
NewerOlder