JSFiddle - React, Tailwind, and code Playground

by beshanoe

JavaScript

var tooth = {
	type: ToothType.EMPTY,
  state: ToothState.NORMAL,
  disabled: false
}

function onToothClick(toothId, tooth) {
	var empty = true;
	restorations.forEach(function(r) {
  	if (isInRange(toothId, r.file.range)) {
    	var newState = toggleToothState(ToothState.HIDDEN, ...r.teeth);
      
      empty = false;
    }
  });
  if (empty) {
  	var sliceArgs = toothId < 16? [0, 16]: [16:32];
    var emptyTeeth = ToothChart.teeth
    	.slice(...sliceArgs)
      .filter(tooth => tooth.type !== ToothType.RESTORATION);
  	toggleToothState(ToothState.HIDDEN, ...emptyTeeth);
  }
}

function toggleToothState(state, ...teeth) {
	var oldState = teeth[0].state;
  var newState;
	teeth.forEach();
}