Skip to content

Instantly share code, notes, and snippets.


Chris Overstreet chrisoverstreet

View GitHub Profile

V1 - Support charging final payments + showing payment in-app

Goal of V1 is to support adding line items to an order, auto-charging final payment (including notification to organizers).

To reduce risk, we will have a flag per order to turn auto-charging on or off. This can be used to show or hide the payments tab as well.


  1. BE - Add an autocharge_balance flag to orders.
View footer.html
View settings.json
"editor.formatOnSave": true,
"javascript.validate.enable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.renderWhitespace": "all"
View ApiService.ts
type Result<Response> = {
get(): Promise<Response>;
delete(): Promise<Response>;
post(body?: BodyInit): Promise<Response>;
put(body?: BodyInit): Promise<Response>;
patch(body?: BodyInit): Promise<Response>;
type Options = {
headers?: Record<string, string>;
View DbHandler.php
class DbHandler
private $conn;
private $pdo;
* DbHandler constructor.
* Pass in connections to prevent race conditions being cause by multiple connections being created
* @param {mysqli} $dbConnection - optional mysqli connection
* @param {PDO} $pdoConnection - optional pdo connection
View patchEstimateHandler.js
export const patchEstimateHandler = async (req, res) => {
const {
body: { canStartToday },
params: { estimateId },
} = req;
const originalEstimate = await getEstimateById(estimateId);
if (!originalEstimate) {
return responseService.createErrorResponse(res, createError.NotFound());
View UserPermissionsLoader.js
import DataLoader from 'dataloader';
import UserPermission from '../../../models/user-permission.model';
async function batchUserPermissions(userIds) {
const userPermissionListMap = new Map();
const userPermissions = await UserPermission.query()
.select(['userId', 'permission'])
.whereIn('userId', userIds);
View test.jsx
// @flow
// pages/test.jsx
import React from 'react';
import Link from 'next/link';
import LinkButton from '../components/homee-ui/LinkButton';
export default () => (
<Link href="/workbench/[bucket]" as="/workbench/active" passHref>
View LinkButton.jsx
// @flow
import classnames from 'classnames';
import css from 'styled-jsx/css';
import PropTypes from 'prop-types';
import React from 'react';
import type { Node } from 'react';
import Icon from './Icon';
import Text from './Text';
View TimeClock.jsx
// @flow
import React from 'react';
import css from 'styled-jsx/css';
import classnames from 'classnames';
import { useDispatch, useSelector } from 'react-redux';
import { useApolloClient } from '@apollo/react-hooks';
import pluralize from 'pluralize';
import PropTypes from 'prop-types';
import userHasLoginRole from '../../utils/userHasLoginRole';