How can i add indirect referral earning?

please someone should assist below is what i want to achieve For example if I refer u I will be given 1,200 immediately

If you refer someone I will be given 100 naira immediately

While you be given 1,200

const { accountUnlockedMailer } = require("../../email/mails/accountUnlocked");
const asyncHandler = require("../../helpers/asyncHandler");
const { getCouponByKey, updateCouponByKey } = require("../../helpers/coupon");
const { openToken } = require("../../helpers/jwt");
const { creditReferrer } = require("../../helpers/referral");
const { editUserById, getUserById } = require("../../helpers/user");

exports.userUnlockUpgradePost = asyncHandler(async (req, res, next) => {
    const { id } = await openToken(req.signedCookies[process.env.TOKEN_NAME]);
    
    //Get The Coupon
    const coupon = await getCouponByKey(req.body.code);

    //Check If Available
    if (!coupon) return res.json({ status: false, message: "Coupon not found" });

    //Check If Is Used
    if (coupon.coupon_status === 1) return res.json({ status: false, message: "Coupon has been used" });
    
    //Then Upgrade User
    await editUserById(id, { can_earn: 1 });

    //Used Coupon
    await updateCouponByKey(coupon.coupon_id, { coupon_status: 1, coupon_used_by:id });

    //Credit His Referrer
    await creditReferrer(id);
   
    
    
    //Response Back
    res.json({ status: true, message: "Account has been unlocked successfully" });

    //Send Mail
    const user = await getUserById(id);
    accountUnlockedMailer({
        username: user.username,
        email: user.email
    });



})

Carousel 3element Help for createeeeeeeee [closed]

bootstrap 5 min.css latest version 5.1.3 carousel 3 element
lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum

const elementUSD = document.querySelector('[data-value="USD"]')
const elementEUR = document.querySelector('[data-value="EUR"]')
const elementRUB = document.querySelector('[data-value="RUB"]')
const rates = []

const input = document.querySelector('#input')
const result = document.querySelector('#result')
const select = document.querySelector('#select')
const select2 = document.querySelector('#select2')


const getCourses = async() => {
    const response = await fetch('https://www.cbr-xml-daily.ru/daily_json.js')
    const data = await response.json()
    const result = await  data;
    result.Valute.AMD.Nominal = 1
    result.Valute.AMD.Value = 1
    result.Valute.AMD.Previous = 1
    result.Valute.RUB = {Previous:6.17625, Value: 6.15124}
    console.log(result);

    rates.USD = result.Valute.USD
    rates.EUR = result.Valute.EUR
    rates.AMD = result.Valute.AMD
    rates.RUB = result.Valute.RUB
    rates.USD.Value*=rates.RUB.Value
    rates.EUR.Value*=rates.RUB.Value
    rates.USD.Previous*=rates.RUB.Previous
    rates.EUR.Previous*=rates.RUB.Previous
    console.log(rates);
    elementUSD.textContent=(rates.USD.Value).toFixed(2)
    elementEUR.textContent=(rates.EUR.Value).toFixed(2)
    elementRUB.textContent=rates.RUB.Value.toFixed(2)

    if(rates.USD.Value > rates.USD.Previous){
        elementUSD.classList.add('bottom')
    }else{
        elementUSD.classList.add('top')
    }
    if(rates.EUR.Value > rates.EUR.Previous){
        elementEUR.classList.add('bottom')
    }else{
        elementEUR.classList.add('top')
    }
    if(rates.RUB.Value > rates.RUB.Previous){
        elementRUB.classList.add('bottom')
    }else{
        elementRUB.classList.add('top')
    }
}
getCourses()


const convertValue = () => {
result.value = (rates.AMD.Value * input.value / rates[select2.value].Value).toFixed(2)
}

input.oninput = convertValue

select.oninput = convertValue

select2.oninput = convertValue
*{
    font-family: 'Rubik', sans-serif;
}

.MTitle{
padding-bottom: 15px;
}
.courses{
    display: flex;
    align-items: center;
    margin-bottom: 40px;
}
.CBlock{
    border: 1px solid grey;
    padding: 10px 15px 10px 15px;
    margin-left: 10px;
    margin-right: 10px;
}
.CBTitle{
padding-bottom: 20px;
}
.CBCourse{
    text-align: center;
    font-size: 24px;
}
.bottom{
    color: red;
}
.top
{
    color: green;
}

.carousel-control-next{
height: 30%;
 margin-top: 80px;
}
.carousel-control-next-icon{
margin-left:55px;
}
.carousel-control-prev-icon{
margin-right:55px;
}
.carousel-control-prev{
height: 30%;
margin-top: 80px;
margin-right: 50px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Valute Converter</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Rubik:wght@400;900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/bootstrap.min.css">
</head>
<body style="background-color: #1b1b1b;">

<div class="container-xxl">
    <div class="row justify-content-center">
        <div class="col-6 p-5">
            <div class="card p-3" style="background-color: #18191a;">
                <form>
                <h2 class="MTitle" style="color: white;">Converter Valute</h2>

                <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only">Previous</span>
                </a>
                <div class="courses ">
                    <div class="col">
                    <div class="CBlock">    
                    <div class="CBTitle" style="color:white;">Course USD</div>
                    <div class="CBCourse" data-value="USD">--.--</div>
                    </div>
                    </div>
                    <div class="col">
                    <div class="CBlock">
                    <div class="CBTitle" style="color:white;">Course EUR</div>
                    <div class="CBCourse" data-value="EUR">--.--</div>
                    </div>
                    </div>
                    <div class="col">
                    <div class="CBlock">
                    <div class="CBTitle" style="color:white;">Course RUB</div>
                    <div class="CBCourse" data-value="RUB">--.--</div>
                    </div>
                    </div>
                </div>
                <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only">Next</span>
                </a>
                <div class="row mb-1">
                    <div class="col"><label style="color: white;" for="name">From:</label>
                    <select disabled class="form-control" id="select">
                        <option value="AMD" selected>AMD - Դրամ</option>
                    </select>
                    </div>
                    <div class="col"><label style="color: white;" for="name">To:</label>
                    <select style="cursor:pointer;" class="form-control" id="select2">
                        <option value="EUR">EUR - Եվրո</option>
                        <option value="USD">USD - Դոլլար</option>
                        <option value="RUB">RUB - Ռուբլի</option>
                    </select>
                    </div>
                </div>
                <div class="row">
                    <div class="col"><input type="number" id="input" class="form-control"></div>
                    <div class="col"><input type="number" class="form-control" id="result" disabled></div>
                </div>
                </form>
        </div>
            </div>


    </div>
    <h5 style="margin-left:60%;color: white;">Directed by: Me</h5>
</div>    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    <script src="./js/app.js">

    </script>
</body>
</html>

WebGL2 Instanced Drawing indexed

how can I order matrices for texture atlas by using Instanced Drawing in the 2D games?

https://webgl2fundamentals.org/webgl/lessons/webgl-instanced-drawing.html

#version 300 es

uniform mat4 u_projection;
uniform mat4 u_camera;

in mat4 u_matrix;//<--Instanced Drawing
in mat3 u_atlas;//<-- need to index 

out vec2 v_texcoord;
    
const float xp[6] = float[](0.0, 0.0, 1.0, 1.0, 1.0, 0.0);
const float yp[6] = float[](0.0, 1.0, 0.0, 1.0, 0.0, 1.0);

void main() {
    float x = xp[gl_VertexID];
    float y = yp[gl_VertexID];

    gl_Position = u_projection * -u_camera * u_matrix * vec4(x,y,1,1);
    v_texcoord = vec3(u_atlas * vec3(x,y,1)).xy;
}

Forgive me for my bad English

Syncing Two Google Drive Accounts Using Google Scripts

I have two Google Drive accounts that I would like them to be synced automatically using Google Scripts.

I need the script to do the following:

I need the whole folder and files (in the source Google Drive account) to be synced to the destination Google Drive account once there are any changes (new/modified/deleted files/folders).

It should notify me by email once there is an action made.

Please help me figure how to start doing this script as I had this script collected from others that I found in this forum:

function copyfile() {
  var sourceFolderName = "root";
  var destinationFolderName = "Folder 2 ID";
  var source_folder = DriveApp.getFoldersByName(sourceFolderName).next();
  var files = source_folder.getFiles();
  var dest_folder = DriveApp.getFoldersByName(destinationFolderName).next();

  var destination_files = [];
  var fileIterator = dest_folder.getFiles()
  while (fileIterator.hasNext())
    destination_files.push(fileIterator.next().getName());

  while (files.hasNext()) {
    var srcFile = files.next();
    var newName = srcFile.getName();
    if (destination_files.indexOf(newName) == -1) {
      srcFile.makeCopy(dest_folder);
    }
  }
}

How to add a 3rd party Jquery Library in React Functionnal component?

I want to use a 3rd library only for my homepage in a React application. The problem is : the library is developed with Jquery : www.npmjs.com/package/fullview

I need to import : Jquery, js file and css file.

so far, I haven’t found any way to import this type of library into a functionnal component. Only class components.

Can I import these files directly in index.html with or i need to import them in my component with import … from “…”

Thank you !

Datepicker not working on javascript generated html

With jquery, i append some html form inputs to my site on a button click, like these:

html  += '<div class="form-group my-4">';
    html += '<span class="left">Date of ending work <span class="carer_help">Required format: 01-01-2000</span></span>';
    html += '<span class="left"><input class="form-control datepicker" type="text" required="required" name="work_end[' + works_row_melleklet + ']" value="'+work_end+'" /></span>';
html += '</div>';

You can see, that the input have the datepicker class.
But my problem is, that the datepicker calendar isnt showing up. I think, because the html input, where i wanna use the calendar, is not in the site’s source, its just added by javascript on button click.

How can i fix this?

 $('.datepicker').datepicker({
        format: 'dd-mm-yyyy',
        language: 'en',
        autoclose: true,
        todayHighlight: true
    });

atleast one of the value’s in the array1 obj “data” array matches the “data” array in array2 object

at least one of the value’s in the array1 obj “data” array matches the “data” array in array2 object


> array1

array1 = [
  {
      id: '1',
      name: 'ron',
      data: ['p1']
  },
  {
      id: '2',
      name: 'lon',
      data: ['p2']
  },
{
      id: '3',
      name: 'voon',
      data: ['p4']
  }
];


> array2

array2 = [
  {
      id: '1',
      name: 'fgr',
      data:['p1','p2','p3']
  },
  {
      id: '2',
      name: 'gone',
      data:['p1','p2','p3']
  }
]


output: {
id: ‘1’,
name: ‘ron’,
data: [‘p1’]
},
{
id: ‘2’,
name: ‘lon’,
data: [‘p2’]
}

how to resolve the warning: AudioContext was not allowed to start. while playing songs in the loop

I’m trying to make loop options in the audio player (using wavesurfer.js) I have made a button for a loop. when use hits the button the loop mode turns on and after finishing the current song next, the next song plays itself. But the problem is that when next song has loaded the browser give me the following warning:

The AudioContext was not allowed to start. It must be resumed (or
created) after a user gesture on the page.

how can this issue be solved?

here is my jQuery code:

var playcounter = false;
      $("#playAll").click(function(){
        $(this).toggleClass('play-all-btn2');
        playcounter = !playcounter;
      });
      wavesurfer.on('finish', function () {
        if(!playcounter){
          wavesurfer.stop();
        }else{
          songAdrr++;
          songAdrr1 = songAdrr;
          songlinktest = $(".player-playlist .songlink").eq(songAdrr).attr('href');
          if (typeof songlinktest === 'undefined') { //if no song found, stop loading song
            wavesurfer.stop();
            wavesurfer.cancelAjax();
            songAdrr--;
            songAdrr1 = songAdrr;
          }else{
            $(".wavetest").show();
            $(".player-playlist .player-song-detail .wavetest").eq(songAdrr).hide();
            $(".player-playlist .player-song-detail #songwave").remove();
            $(".player-playlist .player-song-detail #testdiv").eq(songAdrr).append("<div id='songwave'> </div>");
            wavesurfer = WaveSurfer.create({
              container: '#songwave',
              waveColor: '#CCCCCC',
              progressColor: '#E64C51',
              barWidth:2,
              height:40,
              barGap:2,
              backgroundColor: 'transparent'
          });
            wavesurfer.load(songlinktest);
            wavesurfer.play();
            wavesurfer.stop();
          }
          
        }
        if (songAdrr > 0) {
          $("#preSong").prop('disabled', false);
        }
        if (songAdrr == totalSongs) {
          $("#nextSong").prop('disabled', true);
        }

      });

Django STATIC FILES not loading in actual Production

I have tried many things to solve this like adding whitenoise middleware, also added STATICFILES_DIRS = [], added mimetypes for css
in settings.py file CSS/JS Won’t load.

Here is my settings.py

from pathlib import Path
import environ
import mimetypes

mimetypes.add_type("text/css", ".css", True)

BASE_DIR = Path(__file__).resolve().parent.parent

env = environ.Env()
environ.Env.read_env()

STRIPE_PUB_KEY = env('STRIPE_PUB_KEY') 

DEBUG = True

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'users',
    'addresses',
    'orders',
    'feedback',
    'message',
    'gifts_coupons',
    'core',
    'product',
    'fulfillment',
    'cart',
    'discounts',
    'stripe_pay',
    
    'rest_framework',
    'rest_framework.authtoken',
    'phonenumber_field',
    'django_filters',
    'creditcards',
    'mptt',
    'corsheaders',
    'import_export',
    'django_inlinecss',
]

IMPORT_EXPORT_USE_TRANSACTIONS = True

AUTH_USER_MODEL = 'users.User'

# If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect
CORS_ALLOW_ALL_ORIGINS = True 


# TODO: Change urls while going online

CORS_ALLOWED_ORIGINS = [
    'https://estreetmart.in',
    'https://estreetmart.sg',
    'https://ims.estreetmart.in',
    'http://localhost:8000',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'orders.middlewares.cart_middleware',
]

ROOT_URLCONF = 'estreetmart.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'estreetmart.wsgi.application'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': '',
        'USER': '',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '5432',
    },
}

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

MEDIA_ROOT = BASE_DIR / 'media'

MEDIA_URL = '/media/'

STATIC_URL = '/static/'

STATIC_ROOT = BASE_DIR / 'static'

I also added following in my main urls.py

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

but still css/js is not loading so I inspected the code and found following:
403 Forbidden error for static file

and also sources is empty:
Sources are empty

nextjs: Warning: Prop `className` did not match. Server: “x” Client: “y”

This is my code:

export default function Nav() {
    const { userLogin } = useUser()
    console.log(userLogin)
    
    return (
        <nav className={styles.nav}>
            {!userLogin ? (
                <Link href={"/login"}><a className={`${styles.top}`}></a></Link>
            ) : (
                <Link href={"/profile"}><a className={`${styles.userLogged}`}></a></Link>
            )}
        </nav>
    )
}

And this is useUser:

export default function useUser(){
    var userLogin = false

    const cookies = parseCookies()
    if (cookies.token) {
        userLogin = true
    }

    return { userLogin }
}

So, if userLogin is false, everything is OK.

But if userLogin is true I get this error:

Warning: Prop `className` did not match. Server: "x" Client: "y"

This error show when I use cookies.

I don’t want to use next/dynamic. because dynamic reload component again on click.

Can’t place a background image in next JS and Tailwind CSS

I’m stuck and can’t place the background image on my next JS app
Here is My Code
globals.css

    padding: 0 2rem;
    background-image: url(../public/images/landing-page-illustration.svg);
}
```
**index.js**
```import Head from 'next/head'
import Image from 'next/image'
import Navbar from '../components/navbar';
import styles from '../styles/Home.module.css'

export default function Home() {
  
  return (
    <div className={styles.container}>
      
       
      <Navbar/>
    </div>
  );
}

I get this error trying to install canvas

I’ve been trying to install canvas for a NFT generator, but it everytime I try to do it, I get this error. what do you think is the problem? what am I supposed to do?

THE ERROR :

npm ERR! code 6
npm ERR! path C:UsersKeramDesktopgenerative-art-node-mainnode_modulescanvas
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c node-pre-gyp install –fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using [email protected]
npm ERR! node-pre-gyp info using [email protected] | win32 | x64
npm ERR! node-pre-gyp info check checked for “C:UsersKeramDesktopgenerative-art-node-mainnode_modulescanvasbuildReleasecanvas.node” (not found)
npm ERR! node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.0/canvas-v2.9.0-node-v93-win32-unknown-x64.tar.gz
npm ERR! node-pre-gyp info install unpacking Release/
npm ERR! node-pre-gyp info install unpacking Release/canvas.exp
npm ERR! node-pre-gyp info install unpacking Release/canvas.ilk
npm ERR! node-pre-gyp ERR! Completion callback never invoked!
npm ERR! node-pre-gyp ERR! System Windows_NT 6.1.7601
npm ERR! node-pre-gyp ERR! command “C:node jsnode.exe” “C:UsersKeramDesktopgenerative-art-node-mainnode_modules@mapboxnode-pre-gypbinnode-pre-gyp” “install” “–fallback-to-build”
npm ERR! node-pre-gyp ERR! cwd C:UsersKeramDesktopgenerative-art-node-mainnode_modulescanvas
npm ERR! node-pre-gyp ERR! node -v v16.6.2
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.5

npm ERR! A complete log of this run can be found in:
npm ERR! C:UsersKeramAppDataLocalnpm-cache_logs2022-01-29T08_29_22_396Z-debug.log
PS C:UsersKeramDesktopgenerative-art-node-main>

read response from redirection url using webView in flutter

I was trying to add a payment gateway using WebView flutter library.On successful completion of payment, the gateway redirects to a return url or webhook with transaction response. Now instead of redirection to some outside url, I want redirection to my app and want to read the status of transaction from response that is sent.
All I want to know whether transaction is success or fail.

”’

WebView(
  navigationDelegate: (action) {
    return NavigationDecision.navigate;
  },
  onPageStarted: (url) => _onPageStart(url),
  onPageFinished: (url) => _onPageFinish(url),
   gestureNavigationEnabled: true,
  debuggingEnabled: true,
  javascriptMode: JavascriptMode.unrestricted,
  initialUrl: url,
  onWebViewCreated: (WebViewController webcontroller) {
    _controller = webcontroller;
  },
),

void _onPageStart(url) {
  Future<String> future = _controller
      .runJavascriptReturningResult("window.document.body.outerHTML");
  future.then((data) {
    print("ONpage start $data");
  });
}


Future<void> _onPageFinish(url) async {
    Future<String> future = _controller
        .runJavascriptReturningResult("window.document.body.outerHTML");
    future.then((data) {
      print(data);
    });
  }

”’