#!/bin/bash

sqlite_db="$HOME/databases/demo.db"
db_schema="../../sqlite/schema.sql"
# svg_path="$HOME/svgs/flaticon_colored_svgs"
# svg_path="$HOME/svgs/flaticon_colored_pngs"
#svg_path="$HOME/icons"
svg_path="$HOME/svgs/warfighter_icons"


# remove existing test database
if [ -f "$sqlite_db" ]; then
    echo "Removing existing test database at $sqlite_db"
    rm "$sqlite_db"
else
    echo "No existing test database found at $sqlite_db"
fi

# rebuild database
sqlite3 "$sqlite_db" < "$db_schema"

cli="../../bin/cli"
# build go cli
echo "building cli"
go build -o $cli ../../cmd/cli/main.go

# build db
echo "building db"
$cli build-db -db-path "$sqlite_db" -img-path "$svg_path"

# create customer
echo "creating customer"
customer_id="ed9ed6e0-082c-4b57-8d8c-f00ed6493457"
$cli create-customer -customer-id "$customer_id" -db-path "$sqlite_db"

## create admin user
#user_email="donovan.a.kelly@pm.me"
#keypad_path="$HOME/svgs/my_icons/"
#$nkode_cli add-user \
#  -img-path "$keypad_path" \
#  -img-type "svg" \
#  -customer-id "$customer_id" \
#  -user-email "$user_email" \
#  -attrs-per-key 9 -numb-of-keys 6 \
#  -db-path "$sqlite_db" \
#  -role admin \
#  -nkode-icons ae-86.svg,arkansas.svg,banana-slug.svg,blockchain.svg
#
