import {Component, OnInit} from '@angular/core';

import {TransactionService} from 'm2-core';
import {CdDemoComponent} from '../../../abstract/CdDemoComponent';
import {CdHelperService} from '../../../../../service/cd-helper.service';


@Component({
    template: `
        <div *ngIf="!isInitialized" class="h-100 busy-modal"></div>
        
        <div class="cd-demo-widget">
            <node-card-lazy
                    [nodeId]="nodeId"
                    [editModeON]="editModeON$ | async"
                    (initialized)="isInitialized = true"
            >
            </node-card-lazy>
        </div>
    `
})
export class CdNodeCardDemoComponent extends CdDemoComponent implements OnInit {

    constructor(
        private cdHelperService: CdHelperService,
        private transactionService: TransactionService
    ) {
        super();
    }

    isInitialized = false;
    nodeId?: number;
    editModeON$ = this.transactionService.editModeON$;

    async ngOnInit() {
        this.nodeId = await this.cdHelperService.getAnyNodeId();
    }

}
