Skip to content

Instantly share code, notes, and snippets.

View jermsam's full-sized avatar
🎯
Focusing

Samson Ssali jermsam

🎯
Focusing
View GitHub Profile
@jermsam
jermsam / feathers.js
Created July 13, 2018 06:39
Exposing the remote end to the react app
// src/feathers.js
import io from 'socket.io-client'
import feathers from '@feathersjs/client'
// Socket.io is exposed as the `io` global.
const socket = io('http://localhost:3030')
// @feathersjs/client is exposed as the `feathers` global.
const client = feathers()
.configure(feathers.socketio(socket))
//incase we later have to do authentication
.configure(
@jermsam
jermsam / DisplayGrid.js
Last active July 19, 2018 11:31
A Grid to be used to display Products that are fetched from the remote end by sending a find request
// src/DisplayGrid.js
import React,{Component} from 'react'
import { Container,Divider,Header,Card,Button } from 'semantic-ui-react';
import {Link} from 'react-router-dom'
import client from './feathers'
export default class DisplayGrid extends Component {
state = {
products:[]
};
@jermsam
jermsam / CreateProductForm.js
Last active July 19, 2018 11:09
A Form to be used for sending Create Product requests to the remote end
// src/CreateProductForm.js
import React, { Component } from 'react';
import {Container,Header,Form, Button,Divider,TextArea} from 'semantic-ui-react';
import client from './feathers'
export default class CreateProductForm extends Component {
state = {
product:{
name:'',
description:'',
@jermsam
jermsam / DisplayGrid.js
Last active July 19, 2018 11:30
Editing DisplayGrid to get notified when product is 'emitted' events are emited by remote end
// src/DisplayGrid.js
import React,{Component} from 'react'
import { Container,Divider,Header,Card,Button } from 'semantic-ui-react';
import {Link} from 'react-router-dom'
import client from './feathers'
export default class DisplayGrid extends Component {
state = {
products:[]
};
@jermsam
jermsam / channels.js
Created July 13, 2018 06:22
Enabling product is 'created' event to be emited for anonymous users
//add this to feather's src/channels.js around line 53
app.service(‘products’)
.publish(‘created’, () => app.channel(‘anonymous’));
@jermsam
jermsam / CreateProductForm.js
Last active July 12, 2018 18:11
How to integrate the RESTfull api with the react app
// src/CreateProductForm.js
import React, { Component } from 'react';
import { Form, Button} from 'semantic-ui-react';
import client from './feathers'
export default class CreateProductForm extends Component {
state = {
product:{
name:'',
description:'',
price:null
import React from 'react'
import { Input,Card,Statistic,Button } from 'semantic-ui-react'
import PropTypes from 'prop-types'
import WithStockQuantities from './WithStockQuantities'
function AirtimeCard ({card,name,logedIn}){
return (
import React , {Component} from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux';
import { compose } from 'recompose';
import {services} from '../../services'
class WithNetworks extends Component{
componentDidMount(){
const { findNetworks}=this.props
@jermsam
jermsam / User.js
Last active May 16, 2018 10:36
My this.props.history tends to get lost before it reaches my authenticated component
import React,{Component} from 'react'
import PropTypes from 'prop-types'
import {compose} from 'recompose'
import {connect} from 'react-redux'
import {
Divider, Message,Container
} from 'semantic-ui-react';
import { withRouter,} from 'react-router-dom'
import withAuthorization from './hocs/withAuthorization'
import SetUpProfile from './dashboardComponents/SetUpProfile'
@jermsam
jermsam / LoginPage.js
Last active May 14, 2018 08:17
AUthUser Stays when I logout.
import React,{Component} from 'react'
import PropTypes from 'prop-types'
import { compose } from 'recompose'
import {connect} from 'react-redux'
import {
withRouter,
} from 'react-router-dom';
import {
Divider, Message,Container,Header