Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
\,,/.<(*_*)>

jan paul janpauldahlke

💻
\,,/.<(*_*)>
  • hamburg, germany
View GitHub Profile
View careplan-editor.component.ts
export class CareplanEditorComponent implements OnInit, OnChanges, OnDestroy {
@Input() carePlanId: string | null = null;
carePlanForm = this.fb.group<CarePlanFormValue>({
//there are more, but those are relavant
start: [null, {
validators: [
Validators.required
],
asyncValidators: [
View plan.query.ts
selectAllScopeCarePlans(scope: string): Observable<GroupedCarePlan> {
const result = this.selectAllScoped(scope).pipe(
distinctUntilChanged(),
first(),
//map by doNotPerform WI-7133
map((plans) => {
let groupedByPerform: GroupedCarePlan;
plans.map((plan) => {
//status active
if (!plan.activity[0]?.detail?.doNotPerform) {
@janpauldahlke
janpauldahlke / example_reduck.tsx
Created Jul 23, 2021
exmaple of reducks pattern in react
View example_reduck.tsx
import { Action } from 'redux';
/* wouldnt it be smarter jsut top pass an argument with _error object*/
//enum
enum NotificationActions {
THROW_NOTIFICATION = 'THROW_NOTIFICATION',
THROW_NOTIFICATION_WITH_MESSAGE = 'THROW_NOTIFICATION_WITH_MESSAGE',
RESET_NOTIFICATION_STORE = 'RESET_NOTIFICATION_STORE',
}
View call_multiple_in_service.ts
save(close?: boolean): void {
this.resourceService
.save(this.formName, this.id, this.workItemForm.value)
.pipe(
tap(res => {
if (close) {
// Sofort Schließen, Rest interessiert uns nicht
this.savedAndClosing.emit({ wi_resourceType: 'researchStudy', wi_id: this.id } as IWorkItem);
return;
}
View fileUpload.ts
onFileSelected(event: Event): void {
const file: File = (<HTMLInputElement>event.target).files[0];
this.fileName = file.name;
const { type } = file;
if (type === 'image/png' || type === 'image/jpg' || type === 'image/jpeg') {
// this is standart browser api
const formData = new FormData();
formData.append('thumbnail', file);
View layout.js
import React from "react"
import { Location } from "@reach/router"
import styled, { ThemeProvider } from "styled-components"
import Favicon from '../../assets/DentaMile.ico';
import Helmet from 'react-helmet';
import Header from "../components/header"
import SideBar from "../components/sidebar"
import Footer from "../components/footer"
View image.jsx
import React, { useEffect } from "react"
import { StaticQuery, graphql } from "gatsby"
import Img from "gatsby-image"
import { connect } from "react-redux"
import { toggleLightBox } from "../state/app"
import { isFunction } from "lodash"
/* props : {
src : String!
description: String!,
View gatsby-node.js
const fs = require('fs');
const path = require('path');
const dirPath = path.join(__dirname + '/data/')
//helpers
//reads all json files
const readFiles = (dir) => {
const returnFiles = [];
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>4.5.1. mit Empfehlung</title>
<style>
@janpauldahlke
janpauldahlke / snippet_collectio.js
Created Mar 26, 2019
a brief collection of my snippets, i should look here BEFORE googling around
View snippet_collectio.js
//-----------------
//random a hex color
//-----------------
const randomColor = () => {
return '#'+Math.floor(Math.random()*16777215).toString(16);
};
//-----------------
//observes a change in an object via proxy
//-----------------