Skip to content

Instantly share code, notes, and snippets.

@bryzettler
bryzettler / context_example.ts
Created January 25, 2023 22:28
example of simple context with a provider
import React, {
FC,
ReactNode,
createContext,
useContext,
useState,
useCallback,
} from "react";
export interface IDrawerProviderProps {
{(spas.length >= 0) && (
<ModelList
inverted
infiniteScroll
onInfiniteLoad={this.handleFetchNextPageOfSpas}
shouldInfiniteLoad={!onLastPaginationPage}
onRowClick={this.handleRowClick}
modelType="Spas"
models={spas}
tableRowNumbers
// @flow
import * as React from 'react';
import {
get as _get,
throttle as _throttle,
orderBy as _orderBy,
} from 'lodash';
import { Table, Icon } from 'semantic-ui-react';
import EmptyListPlaceholder from '../emptyListPlaceholder/EmptyListPlaceholder';
import styles from './ModelList.scss';
import { format, addDays, differenceInDays } from 'date-fns';
import BaseModel from './BaseModel';
export default class Milestone extends BaseModel {
static tableName = 'Milestones';
static tracker = true;
static timestamps = true;
static auditKeys = ['isComplete', 'startDate', 'endDate', 'name', 'status', 'parentMilestoneId'];
static jsonSchema = {
type: 'object',
import { Model } from 'objection';
import { pick as _pick } from 'lodash';
import User from './User';
import utils from '../utils';
export default class AuditLog extends Model {
static tableName = 'AuditLog';
static jsonAttributes = [];
static jsonSchema = {
type: 'object',
import { Model } from 'objection';
import AuditLog from './AuditLog';
export default class BaseModel extends Model {
static auditKeys = [];
static auditSanitize = modelObj => (
// upto other models to implent their own logic
// for auditSanitize
this.constructor.auditSanitize
? this.constructor.auditSanitize(modelObj)
import { createNamespacedAction } from '../../utils/actionsUtils';
const stompAction = createNamespacedAction('@stomp');
export const connect = stompAction('CONNECT');
export const messageRecevied = stompAction('MESSAGE_RECEVIED');
export const disconnect = stompAction('DISCONNECT');
export const subscribe = stompAction('SUBSCRIBE', ({ subscriptionName, destination, onmessage }) => ({
subscriptionName,
destination,
onmessage,
import Stomp from 'stompjs';
import {
APP_STOMP_URL,
APP_STOMP_LOGIN,
APP_STOMP_PASSCODE,
} from '../../constants';
import {
connect,
connecting,
connected,
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const Bundler = requrie('parcel-bundler');
const express = require('express');
const chalk = require('chalk');
const httpProxyMiddleware = require('http-proxy-middleware');
const openBrowser = require('react-dev-utils/openBrowser');
const devServer = express();
// setup parcel
const bundle = new Bundler(paths.appHtml, {
outDir: paths.appBuild,