How to add a label to an email with Nodemailer?

enter image description hereI’m working on an web application with ReactJS and Nodejs and I use Nodemailer to send email. All work fine but, my current issue is that I’m looking for a way to categorize the sent email so that recipients receive it in for example updates or Promotions category like on this screenshot.

export ‘getToken’ (imported as ‘getToken$1’) was not found in ‘firebase/app-check’ (module has no exports)

I’m developing an application in angular (Angular CLI: 13.1.4) and when integrating Firebase, I’m getting some export errors (given below), any one please suggest me an solution

app.module.js

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { MatToolbarModule } from '@angular/material/toolbar'
import { MatIconModule } from '@angular/material/icon'
import { MatButtonModule } from '@angular/material/button';

import { AngularFireModule } from "@angular/fire/compat";
import { AngularFireAuthModule } from "@angular/fire/compat/auth";
import { AngularFireStorageModule } from "@angular/fire/compat/storage";
import { AngularFirestoreModule } from "@angular/fire/compat/firestore";
import { AngularFireDatabaseModule } from "@angular/fire/compat/database";


@NgModule({
  declarations: [
    AppComponent,
    HeaderComponent,
    FooterComponent,
    IndexComponent,
    PlaceDetailComponent,
    PlacesComponent,
    AdminIndexComponent,
    AdminPlaceComponent,
  ],
  imports: [
    AngularFireModule.initializeApp(environment.config),
    AngularFireAuthModule,
    AngularFirestoreModule,
    AngularFireStorageModule,
    AngularFireDatabaseModule,

    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    BrowserAnimationsModule,
    MatToolbarModule,
    MatIconModule,
    MatButtonModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

package.json

enter image description here

Error

./node_modules/@angular/fire/fesm2015/angular-fire-app-check.js:106:27-37 – Error: export ‘getToken’ (imported as ‘getToken$1’) was not found in ‘firebase/app-check’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire-app-check.js:107:37-57 – Error: export ‘initializeAppCheck’ (imported as ‘initializeAppCheck$1’) was
not found in ‘firebase/app-check’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire-app-check.js:108:33-49 – Error: export ‘onTokenChanged’ (imported as ‘onTokenChanged$1’) was not found in ‘firebase/app-check’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire-app-check.js:109:45-73 – Error: export ‘setTokenAutoRefreshEnabled’ (imported as ‘setTokenAutoRefreshEnabled$1’) was not found in ‘firebase/app-check’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire.js:16:98-109 – Error: export ‘isSupported’ (imported as ‘isSupported’) was not found in ‘firebase/analytics’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire.js:17:98-111 – Error: export ‘isSupported’ (imported as ‘isSupported$1’) was not found in ‘firebase/messaging’ (module has no exports)

./node_modules/@angular/fire/fesm2015/angular-fire.js:18:104-117 – Error: export ‘isSupported’ (imported as ‘isSupported$2’) was not found in ‘firebase/remote-config’ (module has no exports)

× Failed to compile.

ColorPick Javascript Issue

In colorpick.js I can able to change the elements color but I am not able to change the border colors present in css. You can see here

This is the Colorpick Javascript code below:

 /* INITIALIZATION COLOURPICKER FOR ELEMENTS
    *********************************************/
    var newColorColorPickElements = $('.ftco-navbar-light, .btn.btn-primary, .bg-light, .sidebar');
    
    $('#pickerelementscolour').colpick({
        layout: 'hex',
        submit: 1,
        colorScheme: 'dark',
        onChange: function (hsb, hex, rgb, el, bySetColor) {
            $(el).css('border-color', '#' + hex);
            setNewColorUI(hex);
            if (!bySetColor) $(el).val(hex);
        }
    }).keyup(function () {
        setNewColorUI(this.value);
        $(this).colpickSetColor(this.value);
    });
    
    function setNewColorUI(newColor) {
        newColorColorPickElements.css('background', '#' + newColor);
        if (!(/Trident/7./).test(navigator.userAgent)) {
            if (localStorage.getItem('elementsColour') != newColor) localStorage.setItem("elementsColour", newColor);
        }
    }

please help me resolving this, thank you

Why js methods like map, forEach, slice, length not working in React

I have array “comments” of objects like this

{
  "pages": [1, 2, 3],
  "totalPage": 3,
  "totalCount": 26,
  "currentPage": 1,
  "comments": [ {...}, {...},  {...}, {...}, {...}, {...},]
}

But cant get his length bacause it says typeof comments is object. As the same time in jsx i could use map method. And when i write console.log(comments) it show array,but as soon as i write console.log(typeof(comments)). How can i get his length?

Cant make dom manipulation work when making a changeBackgroundColor program

I was practising my js since I’m a beginner and was trying to make a program to change the background color but whenever I was trying to use dom-manipulation nothing happened if anybody knows why that happens I would be very thankful.

const button = document.querySelector('.button')
const body = document.querySelector('body')
const colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple']

body.style.backgroundColor = 'violet'
button.addEventListener('click', changeBackground)

function changeBackground() {
  const colorIndex = parseInt(Math.random() * colors.length)
  body.style.backgroundColor = colors[colorIndex]
}
body {
  background-color: red;
}

.button {
  background: transparent;
}
<script src="app.js"></script>
<link rel="stylesheet" href="style.css">

<div class="button-style">
  <button class="button">Click me!</button>
</div>

How to show description for each and every element present in the image?

I want to add a description for each element present in the image. For example, take picture of a plant, if someone hovers on leaves a div should should appear stating “Leaves”, or if someone hovers on roots a div should should appear stating “roots” or if someone hovers on stem of that flower a div should should appear stating “stem” so on and so forth. How can I achieve the same on html? I mean is there any library or api?

Please suggest.
Thank you in advance

Dynamic dependency injection in JS script

I’m working on a system that has two parts:

  • core
  • pluggable modules

The core consists of multiple components such as:

  • sale orders management
  • purchase orders management
  • payment management

Each component has such a structure:

component
|
| model
| route
| static
|| images
|  js
  templates

Core must not depend on modules at all. Modules can depend on core and other modules. In order to invoke modules functionality I use signals. Modules extending routes functionality and models of core components I managed without problem.

The problem is with JS. Majority of front end is built on DataTables and modules are supposed to extend tables as well. That implies extending of HTML template and table definition in JS. So far I’ve managed to do that by rendering JS from Jinja template this way:

order_products.html

{% extends "base.html" %}

{% block scripts %}
{{ super() }}
<script src="dynamic/order_products.js"></script>
{% endblock %}
    
{% block content %}
{{ super() }}
<div class="container-fluid">
    <h1>Order products</h1>
    <table id="order_products" class="table">
        <thead>
            <tr>
                <td></td>
                <td></td>
                <td><input /></td>
                <td><input /></td>
                <td><input /></td>
                <td><input type="date" /></td>
                <td><input /></td>
                <td><input /></td>
                <td></td>
                <td></td>
                <td><select></select></td>
                <td><select></select></td>
                <td></td>
                {% for column in ext_columns %}
                <td></td>
                {% endfor %}
            </tr>
            <tr>
                <th></th>
                <th scope="col" style="width: 1em;">ID</th>
                <th scope="col" style="width: 1em;">Order ID</th>
                <th scope="col">Customer</th>
                <th scope="col" style="width: 2em;">Subcustomer</th>
                <th scope="col" style="width: 1em;">Purchase date</th>
                <th scope="col" style="width: 1em;">Product ID</th>
                <th scope="col">Product name</th>
                <th scope="col">Price</th>
                <th scope="col" style="width: 1em;">Qty</th>
                <th scope="col">Order status</th>
                <th scope="col">OP Status</th>
                <th scope="col">When created</th>
                {% for column in ext_columns %}
                <th scope="col">{{ column.name }}</th>
                {% endfor %}
            </tr>
        </thead>
        <tbody></tbody>
    </table>
</div>
{% endblock %}

order_products.js

function init_order_products_table() {
    var editor = new $.fn.dataTable.Editor({
        ajax: (_method, _url, data, success_callback, error) => {
            for (var order_product_id in data.data) {
                $.ajax({
                    url: '/api/v1/admin/order/product/' + order_product_id,
                    method: 'post',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(data.data[order_product_id]),
                    success: server_data => success_callback(({data: [server_data]})),
                    error: error
                });     
            }    
        },
        table: '#order_products',
        idSrc: 'id',
        fields: [
            {label: 'Subcustomer', name: 'subcustomer', type: 'readonly'},
            {label: 'Product ID', name: 'product_id'},
            {label: 'Price', name: 'price'},
            {label: 'Quantity', name: 'quantity'},
            {label: 'Status', name: 'status'},
            {label: 'Private Comment', name: 'private_comment'},
            {label: 'Public Comment', name: 'public_comment'},
            {% for field in extension.fields %}
                {{ field }} ,
            {% endfor %}
        ]
    });
    $('#order_products').on( 'click', 'tbody td.editable', function (e) {
        editor.inline( this);
    } );
    var table = $('#order_products').DataTable({
        dom: 'lrBtip',
        buttons: [
            'print',
            {extend: 'edit', editor: editor},
            { 
                extend: 'collection', 
                text: 'Set status',
                buttons: [ g_order_product_statuses.map(s => {
                    return {
                        extend: 'status',
                        text: s
                    }
                })]
            }
        ],        
        ajax: {
            url: '/api/v1/admin/order/product',
            dataSrc: 'data'
        },
        columns: [
            {
                "className":      'details-control',
                "orderable":      false,
                "data":           null,
                "defaultContent": ''
            },
            {data: 'id'},
            {data: 'order_id', name: 'order_id'},
            {data: 'customer'},
            {data: 'subcustomer', className: 'editable'},
            {data: 'buyout_date'},
            {data: 'product_id', className: 'editable'},
            {data: 'product'},
            {data: 'price', className: 'editable'},
            {data: 'quantity', className: 'editable'},
            {data: 'order_status'},
            {data: 'status'},
            {data: 'when_created'},
            {% for column in extension.columns %}
                {{ column }} ,
            {% endfor %}        ],
        order: [[12, 'desc']],
        keys: {
            columns: '.editable',
            keys: [ 9 ],
            editor: editor,
            editOnFocus: true
        }
});

But I have feeling this approach is not good enough and doesn’t utilize standard patterns, which I believe do exist. So my question is – is there a better way to inject dependency into front end components?

javascript executes one function before another whereas I asked the reverse

I have a first function that sends commands and receives data. And a second function to download this data (with href and download). I have a third function that starts function one and then function two but I notice that function two is launched before function one. How do we solve this?

function third(){
    first();
    second();
}
function first(){
//sends and receives commands with websockets
}
function second(){
    console.log("1");
    let save = document.getElementById("photo");
    console.log("2");
    save.href = "http://my_url:my_port/folder/img.jpg";
    console.log("3");
    save.download = "";
    console.log("4");
}

In my console, I can see console.log of the second function before the first function. Why ?
Thanks.

How to deploy adaptive Next Js website on a single domain?

I have built an adaptive website in Next js; Which has two versions one for mobile devices and another for Desktop. I want to deploy both on the same domain and open the respective versions based on user-agent.

example: www.test.com will load mobile site if found mobile User-Agent else Desktop site

I’m able to load the respective version of the site If I have a sub-domain like m.test.com but am not able to do it on the same domain.

Can anyone please help with this?

Thanks.

Bad positioning of element with Masonry layout filter

I’m trying for 2 days to make a filter system with the Masonry layout.

Here is my code : https://codesandbox.io/s/position-of-element-masonry-filter-kn4qi6

If I use the Justice’s filter, the layout is good, but with all other filters the elements have a bad positioning. They have free space to get a horizontal positionment but they keep vertical.

Can you help me please ?

Thanks you.

App not compatible with buildpack – django project with java script

When I try to deploy my app to Heroku then I received:

-----> Building on the Heroku-20 stack
-----> Using buildpacks:
       1. heroku/python
       2. https://github.com/heroku/heroku-buildpack-static.git
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
       More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
 !     Push failed

I’ve been trying to spend a lot of time. Most of the solution is not working. Is it a buildpack issue or something else?
Additionally, I connected my GitHub account to Heroku and tried deploying from the GitHub main branch. However, I still receive the error. Here is my GitHub address: https://github.com/Whitemoon2000/Final-year-project

Saving selection in ant design table. [React]

So I’m using ant design (antd). I have created a table with custom pagination. Each page change an API call is made to retrieve a new set of data.

I have successfully implemented code that saves my individual checked boxes while changing pages. Example: on the first page i select 3 checkboxes, then i go to the second and check 2 there, then go to the third and check 5 there. My final state amounts to 10 checked boxes and they are successfully displayed as checked on the table itself.

The next thing i want to achieve is the same but using the check all button on the antd table. I want to be able to select all items from the first page, then go to the second one and select all, then third one and select all and have it all saved and displayed across pages in the table.

The state for individual checking and check all should be shared.

My selectedKeys state:

 const [selectedRowKeys, setSelectedRowKeys] = useState([]);

My row selection

  const onSelectChange = (row) => {
    setSelectedRowKeys((prevKeys) => [...prevKeys, row]);
  };
  const rowSelection = {
    selectedRowKeys: selectedRowKeys.map((item) => item.id), //error line
    preserveSelectedRowKeys: true,
    onSelect: (row, selected, selectedRows) => {
      if (selected) {
        onSelectChange(row);
        setSelectedRow(selectedRows);
        
      } else {
        setSelectedRowKeys((prevKeys) =>
          prevKeys.filter((key) => key.id !== row.id)
        );
        console.log("else");
      }
    },
    onSelectAll: (selected, row, selectedRows) => {
      if (selected) {
        setSelectedRowKeys(row); //not sure im doing the right thing here
        setSelectedRow(selectedRows); 
      } else {
        //dont know what to put here
      }
    },
  };

The problem arrives after i check everything on the first page and go to the second. When i try to check all items there the app breaks and i get errors such as cant read id of undefined in the //error line and pretty much everywhere where i have to map over selectedRowKeys.