How to reactivate deleted item

Published

I am working on a web app and I need to implement reactivation of deleted items.
I have a method that checks if the item exists already:

getExistence(
        item: string
    ): Observable<any> {
        if (item) {
            return this.http.get<any>(
                this.existenceUrl + item
            );
        }
    }

and its interface looks like this

export interface ItemExistence {
    short: string;
    exists: boolean;
    isActive: boolean;
    isDeleted: boolean;
    deletedItemsId: number;
}

When this method says that item isDeleted: true then I need to call reactivateItem().

My issue is that I only have

createItem(
        costObject: IItem
    ): Observable<any> {
        return this.http.get(this.url, costObject)
    }

Please help.
So far I have this:

const input = this.form.get('short').value;

this.service
                .getExistence(input)
                .subscribe((existence: any) => {
                    this.itemsExistence = existence.data.attributes;
                    if (this.itemsExistence.isDeleted) {
                        this.reactivateItem()
                    }
                });

reactivateItem(): void {
        this.service
            .createItem(
                - here I should implement reactivation of item with create method but I don't know how
            )
            .subscribe(data => console.log(data);
    }

Source: Angular Questions

Published
Categorized as angular, canactivate, service, typescript Tagged , , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq