Skip to content

Instantly share code, notes, and snippets.

View Verthon's full-sized avatar
🐢

Krzysztof Sordyl Verthon

🐢
View GitHub Profile
@Verthon
Verthon / setstate.js
Last active March 16, 2019 20:55
Fixin async set state
//----------------First---------------------------
componentDidMount() {
const events = [];
firebase
.collection("events")
.get()
.then(function(querySnapshot) {
querySnapshot.forEach(function(doc) {
events.push(doc.data());
@Verthon
Verthon / package.json
Created April 8, 2019 08:20
eventoo package
{
"name": "event-app",
"version": "0.1.0",
"private": true,
"homepage": "https://verthon.github.io/event-app",
"dependencies": {
"@material-ui/core": "^1.2.3",
"autoprefixer": "7.1.6",
"babel-core": "6.26.0",
"babel-eslint": "7.2.3",
//Reducer
const reducer = (state = initialState, action) => {
switch(action.type){
case types.SEND_EVENT_DATA:
return Object.assign({}, state, {
event: state.event
})
case types.ADD_EVENT_DATA:
return{
=== npm audit security report ===
# Run npm install @angular/compiler-cli@8.2.14 to resolve 1 vulnerability
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Low │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ braces │
├───────────────┼──────────────────────────────────────────────────────────────┤
@Verthon
Verthon / chips.js
Last active December 26, 2019 14:43
Select ion-chip tags
constructor(public navCtrl: NavController, public navParams: NavParams) {
this.information = navParams.data.data;
this.children = [{ id: 1, name: 'Ginny Weasley' }, { id: 2, name: 'Harry Potter' }, { id: 3, name: 'Ronald Weasley' }, { id: 4, name: 'Luna Lovegood' }];
this.selectButtonText = 'SELECT ALL';
this.tagDefaultColor = "secondary";
this.quantity = 0.0;
this.bottleNote = "";
this.bottleDate = new Date().toISOString()
this.shareWithFamily = true;
this.bottleDefaultTime = moment().format('hh:mm a');
@Verthon
Verthon / search.js
Created January 7, 2020 09:34
Search children
const arr = [
{
"name": "Thea Sidiropoulos",
"daycareComment": null,
"parentComment": null,
"id": "86",
"away": null,
"checkin": [],
"additionalDay": false,
"remarks": "",
@Verthon
Verthon / api.js
Last active January 7, 2020 16:41
api_call
fetchData(): Observable<any[]> {
this.attendanceService.getDayOverViewByGroupId(this.dateForDayOverView, this.defaultGroup).then(
(res1: any) => {
let dayOverViewByGroup = res1.mobile_employee_dayoverview;
dayOverViewByGroup.forEach(element => {
element.children.forEach(children => {
if (null !== children.away) {
children.awayClass = "awayClass";
children.reason = children.away.reason;
} else {
ngOnInit() {
console.log('ngOnInit() invokes with default group', this.defaultGroup);
const filter$: Observable<string> = this.filterControl.valueChanges.pipe(
startWith(''),
debounceTime(100),
distinctUntilChanged(),
share()
);
this.dayOverViewByGroup$ = this.attendanceService.getDayOverViewByGroupIdObservable(moment().format("YYYY-MM-DD"), 3).pipe(
// If the Observable from your service can emit 'null' and you do
import React from 'react'
import styled from 'styled-components'
import dayjs from 'dayjs'
import { Link } from 'react-router-dom'
import { useDispatch } from 'react-redux'
import { EventModel } from '../interfaces'
import { showEventDetails } from '../reducers/event'
const EventItem = (props: any) => {
@Verthon
Verthon / auth.ts
Last active April 3, 2020 19:10
Ionic4 React Firestore problem with setting protected route for the '/account'
// useAuth.ts
export default () => {
const dispatch = useDispatch()
const currentUser = useSelector(selectCurrentUser)
console.log('current User in useAuth hook', currentUser)
useEffect(() => {
const setUser = (user: any) => {
if(user) {
dispatch(login({ uid: user.uid, email: user.email }))