Skip to content

Instantly share code, notes, and snippets.

@anjula-sack
anjula-sack / Locations.tsx
Last active November 6, 2022 05:19
Locations dropdown
import React, { useState } from "react";
import { showToast } from "@openmrs/esm-framework";
import { Column, Dropdown } from "carbon-components-react";
import { useLocations } from ".resources";
const SearchByEncounters: React.FC = () => {
const { locations, error, isLoading } = useLocations();
@anjula-sack
anjula-sack / resources.ts
Last active November 6, 2022 04:51
SWR example
import { openmrsFetch, FetchResponse } from "@openmrs/esm-framework";
import useSWR from 'swr';
import { Location, Response } from "./types";
export const useLocations = () => {
const { data, error } = useSWR<{
data: { results: Response[] };
}>("/ws/rest/v1/location", openmrsFetch);
@anjula-sack
anjula-sack / sendEmail
Created December 7, 2020 03:05
Function for send the email
sendEmail = (e) => {
e.preventDefault();
emailjs.sendForm('YOUR_EMAIL_SERVICE_NAME', 'YOUR_EMAIL_TEMPLATE_NAME', e.target, 'YOUR_USER_ID')
.then((result) => {
this.setState({isAlertVisible: true})
}, (error) => {
console.log(error.text);
});
}
<form className="php-email-form" onSubmit={this.sendEmail}>
<div className="form-row">
<div className="col-md-6 form-group">
<input required={true} type="text" name="name" className="form-control" placeholder="Your Name"/>
</div>
<div className="col-md-6 form-group">
<input required={true} type="email" className="form-control" name="email"
placeholder="Your Email"/>
</div>
</div>
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();