Skip to content

Instantly share code, notes, and snippets.

krissanawat101 krissnawat

View GitHub Profile
View create.js
import * as stockActions from "./../../../actions/stock.action";
import React from "react";
import Container from "@material-ui/core/Container";
import Button from "@material-ui/core/Button";
import { makeStyles } from "@material-ui/core/styles";
import { useDispatch } from "react-redux";
import { Link } from "react-router-dom";
import { Formik, Form, Field } from "formik";
View create.js
import * as stockActions from "./../../../actions/stock.action";
import React from "react";
import Container from "@material-ui/core/Container";
import Button from "@material-ui/core/Button";
import { makeStyles } from "@material-ui/core/styles";
import { useDispatch } from "react-redux";
import { Link } from "react-router-dom";
import { Formik, Form, Field } from "formik";
View create data.js
const mongoose = require('mongoose');
const AutoIncrement = require('mongoose-sequence')(mongoose);
const productSchema = mongoose.Schema({
_id: {type: mongoose.Schema.Types.ObjectId, auto: true },
name: String,
image: String,
stock: Number,
price: Number,
created: {type: Date, default: Date.now}
View register.js
import React, { Component } from "react";
import { Formik } from "formik";
import * as Yup from "yup";
import Recaptcha from "react-recaptcha";
import * as registerActions from "./../../actions/register.action";
import { useSelector, useDispatch } from "react-redux";
const SignupSchema = Yup.object().shape({
username: Yup.string()
.min(2, "username is Too Short!")
View combineReducers.js
import { combineReducers } from "redux";
import loginReducer from "./login.reducer";
import registerReducer from "./register.reducer";
export default combineReducers({
loginReducer,
registerReducer,
});
View register.reducer.js
import {
REGISTER_FETCHING,
REGISTER_FAILED,
REGISTER_SUCCESS,
} from "../constants";
const initialState = {
isFetching: false,
isError: false,
result: null,
View register.action.js
import {
REGISTER_FETCHING,
REGISTER_FAILED,
REGISTER_SUCCESS,
server,
} from "../constants";
import swal from "sweetalert";
import { httpClient } from "./../utils/HttpClient";
export const setRegisterStateToFetching = () => ({
View runDetection-sound
function runDetection() {
model.detect(video).then((predictions) => {
if (predictions.length > 0) {
audio.play();
}
});
}
View setInterval.js
handTrack.startVideo(video).then((status) => {
if (status) {
navigator.mediaDevices
.getUserMedia({ video: {} })
.then((stream) => {
setInterval(runDetection,1000)
})
.catch((err) => console.log(err));
}
});
View runDetection.js
function runDetection() {
model.detect(video).then((predictions) => {
console.log(predictions)
});
}
You can’t perform that action at this time.