package com.gwt.app.client.components;
import static gwt.react.client.api.React.DOM.*;
import gwt.react.client.elements.DOMElement;
import gwt.react.client.events.MouseEventHandler;
import gwt.react.client.proptypes.BaseProps;
import gwt.react.client.proptypes.html.BtnProps;
import gwt.react.client.proptypes.html.HtmlProps;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;

public class EmbeddedReact {

	@JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "Object")
	public
	static class ReactComponentProps extends BaseProps {
		// Add getters instead of public identifiers
		public String currentLoggedUser;
		public MouseEventHandler onGoToGWTAppClicked;
	}

	public static DOMElement<HtmlProps> loggedInComponent(ReactComponentProps props) {
		return div(null, 
				h1(null, "Test application - React"),
				table(new HtmlProps().className("tableCenter"), 
						tr(new HtmlProps().className("largeTextField"),
								div(null, "Current logged in user: " + props.currentLoggedUser)),
						tr(new HtmlProps().className("tableCenterRow"),
								button(
										new BtnProps()
										.className("gwt-Button")
										.onClick(props.onGoToGWTAppClicked),
										"GO TO GWT APP"
										)
								)));

	};
}

