commit ee7cfdfeaa6ab5a2b0f96f96afefcf864459a1e6 Author: AppCakes Date: Sat Jun 20 01:45:23 2026 +0000 build: b0d8399f-81d7-4ccc-8711-0f8b1506676e diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9fe4e25 Binary files /dev/null and b/.DS_Store differ diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz new file mode 100644 index 0000000..17c9b3b Binary files /dev/null and b/.yarn/install-state.gz differ diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..3186f3f --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/android/.DS_Store b/android/.DS_Store new file mode 100644 index 0000000..77e3856 Binary files /dev/null and b/android/.DS_Store differ diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,101 @@ +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/android/app/.gitignore b/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/android/app/build.gradle b/android/app/build.gradle new file mode 100644 index 0000000..e45fa43 --- /dev/null +++ b/android/app/build.gradle @@ -0,0 +1,55 @@ +apply plugin: 'com.android.application' + +android { + namespace = "io.ionic.starter" + compileSdk = rootProject.ext.compileSdkVersion + defaultConfig { + applicationId "com.qoutelink.app" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 3 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + manifestPlaceholders = [googleMapsApiKey: System.getenv("VITE_GOOGLE_MAPS_KEY") ?: ""] + aaptOptions { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation project(':capacitor-android') + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java b/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f2c2217 --- /dev/null +++ b/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import android.content.Context; +import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import org.junit.Test; +import org.junit.runner.RunWith; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + assertEquals("com.getcapacitor.app", appContext.getPackageName()); + } +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2539fd3 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/io/ionic/starter/MainActivity.java b/android/app/src/main/java/io/ionic/starter/MainActivity.java new file mode 100644 index 0000000..73e3a98 --- /dev/null +++ b/android/app/src/main/java/io/ionic/starter/MainActivity.java @@ -0,0 +1,5 @@ +package io.ionic.starter; + +import com.getcapacitor.BridgeActivity; + +public class MainActivity extends BridgeActivity {} diff --git a/android/app/src/main/res/drawable-land-hdpi/splash.png b/android/app/src/main/res/drawable-land-hdpi/splash.png new file mode 100644 index 0000000..213ca3f Binary files /dev/null and b/android/app/src/main/res/drawable-land-hdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-land-mdpi/splash.png b/android/app/src/main/res/drawable-land-mdpi/splash.png new file mode 100644 index 0000000..6ea8f5d Binary files /dev/null and b/android/app/src/main/res/drawable-land-mdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-land-xhdpi/splash.png b/android/app/src/main/res/drawable-land-xhdpi/splash.png new file mode 100644 index 0000000..b5e8845 Binary files /dev/null and b/android/app/src/main/res/drawable-land-xhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-land-xxhdpi/splash.png b/android/app/src/main/res/drawable-land-xxhdpi/splash.png new file mode 100644 index 0000000..3958708 Binary files /dev/null and b/android/app/src/main/res/drawable-land-xxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-land-xxxhdpi/splash.png b/android/app/src/main/res/drawable-land-xxxhdpi/splash.png new file mode 100644 index 0000000..ef02852 Binary files /dev/null and b/android/app/src/main/res/drawable-land-xxxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-port-hdpi/splash.png b/android/app/src/main/res/drawable-port-hdpi/splash.png new file mode 100644 index 0000000..575ae5e Binary files /dev/null and b/android/app/src/main/res/drawable-port-hdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-port-mdpi/splash.png b/android/app/src/main/res/drawable-port-mdpi/splash.png new file mode 100644 index 0000000..9d9caea Binary files /dev/null and b/android/app/src/main/res/drawable-port-mdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-port-xhdpi/splash.png b/android/app/src/main/res/drawable-port-xhdpi/splash.png new file mode 100644 index 0000000..fbfe83b Binary files /dev/null and b/android/app/src/main/res/drawable-port-xhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-port-xxhdpi/splash.png b/android/app/src/main/res/drawable-port-xxhdpi/splash.png new file mode 100644 index 0000000..153c226 Binary files /dev/null and b/android/app/src/main/res/drawable-port-xxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-port-xxxhdpi/splash.png b/android/app/src/main/res/drawable-port-xxxhdpi/splash.png new file mode 100644 index 0000000..4e48eaa Binary files /dev/null and b/android/app/src/main/res/drawable-port-xxxhdpi/splash.png differ diff --git a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/drawable/splash.png b/android/app/src/main/res/drawable/splash.png new file mode 100644 index 0000000..6ea8f5d Binary files /dev/null and b/android/app/src/main/res/drawable/splash.png differ diff --git a/android/app/src/main/res/drawable/splash_logo.png b/android/app/src/main/res/drawable/splash_logo.png new file mode 100644 index 0000000..459d45d Binary files /dev/null and b/android/app/src/main/res/drawable/splash_logo.png differ diff --git a/android/app/src/main/res/layout/activity_main.xml b/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5ad138 --- /dev/null +++ b/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..d652931 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..97859f2 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..d652931 Binary files /dev/null and b/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..f0a25ad Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..805a032 Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..f0a25ad Binary files /dev/null and b/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..9739717 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..18be271 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..9739717 Binary files /dev/null and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..0611feb Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..bd4febf Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..0611feb Binary files /dev/null and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..8446197 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..b2ba236 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..8446197 Binary files /dev/null and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..f42ada6 --- /dev/null +++ b/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + diff --git a/android/app/src/main/res/values/splash_background.xml b/android/app/src/main/res/values/splash_background.xml new file mode 100644 index 0000000..9b116cc --- /dev/null +++ b/android/app/src/main/res/values/splash_background.xml @@ -0,0 +1,4 @@ + + + #FFFFFF + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..9d25aa6 --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,7 @@ + + + Qoutelink + Qoutelink + io.ionic.starter + io.ionic.starter + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..1596ed9 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/xml/file_paths.xml b/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..bd0c4d8 --- /dev/null +++ b/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java b/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java new file mode 100644 index 0000000..0297327 --- /dev/null +++ b/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java @@ -0,0 +1,18 @@ +package com.getcapacitor.myapp; + +import static org.junit.Assert.*; + +import org.junit.Test; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..f8f0e43 --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.13.0' + classpath 'com.google.gms:google-services:4.4.4' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7705927 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 0000000..23d15a9 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 0000000..5eed7ee --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/settings.gradle b/android/settings.gradle new file mode 100644 index 0000000..3b4431d --- /dev/null +++ b/android/settings.gradle @@ -0,0 +1,5 @@ +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + +apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/android/variables.gradle b/android/variables.gradle new file mode 100644 index 0000000..ff89f79 --- /dev/null +++ b/android/variables.gradle @@ -0,0 +1,18 @@ +ext { + minSdkVersion = 24 + compileSdkVersion = 36 + targetSdkVersion = 36 + androidxActivityVersion = '1.11.0' + androidxAppCompatVersion = '1.7.1' + androidxCoordinatorLayoutVersion = '1.3.0' + androidxCoreVersion = '1.17.0' + androidxFragmentVersion = '1.8.9' + coreSplashScreenVersion = '1.2.0' + androidxWebkitVersion = '1.14.0' + junitVersion = '4.13.2' + androidxJunitVersion = '1.3.0' + androidxEspressoCoreVersion = '3.7.0' + cordovaAndroidVersion = '14.0.1' + rgcfaIncludeGoogle = true + androidxCredentialsVersion = '1.3.0' +} \ No newline at end of file diff --git a/capacitor.config.ts b/capacitor.config.ts new file mode 100644 index 0000000..1543375 --- /dev/null +++ b/capacitor.config.ts @@ -0,0 +1,15 @@ +import type { CapacitorConfig } from '@capacitor/cli'; + +const config: CapacitorConfig = { + appId: 'com.qoutelink.app', + appName: 'Qoutelink', + webDir: 'dist', + plugins: { + FirebaseAuthentication: { + skipNativeAuth: false, + providers: [], + }, + }, +}; + +export default config; diff --git a/codemagic.yaml b/codemagic.yaml new file mode 100644 index 0000000..96bfc2b --- /dev/null +++ b/codemagic.yaml @@ -0,0 +1,380 @@ +workflows: + android-debug: + name: Android – Debug APK + max_build_duration: 45 + instance_type: mac_mini_m2 + environment: + node: 22 + java: 21 + cache: + cache_paths: + - $HOME/.gradle/caches + - $HOME/.gradle/wrapper + scripts: + # Template ships with optional native plugins (maps, push, firebase auth) that most apps + # won't use. Keeping unused plugins in package.json adds SPM/Gradle deps and bloats the + # build. Strip any that have no import in src/ so only actually-used plugins are compiled. + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + # Delete package-lock.json (generated if user ever ran npm locally) so it doesn't + # conflict with yarn.lock. --legacy-peer-deps silences peer dep warnings from older + # Ionic/React packages that haven't updated their peerDependencies for React 18/19. + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + # Firebase config files are injected as base64 env vars by the Appcakes backend at + # build time. Decode them here so cap sync and Gradle can pick them up. Optional — + # builds without Firebase still succeed; native Firebase SDK just won't initialise. + - name: Write Firebase config + script: | + if [ -n "$GOOGLE_SERVICES_JSON" ]; then + echo "$GOOGLE_SERVICES_JSON" | base64 --decode > android/app/google-services.json + echo "Wrote google-services.json ($(wc -c < android/app/google-services.json) bytes)" + else + echo "GOOGLE_SERVICES_JSON is empty — skipping" + fi + if [ -n "$GOOGLE_SERVICE_INFO_PLIST" ]; then + echo "$GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > ios/App/App/GoogleService-Info.plist + echo "Wrote GoogleService-Info.plist ($(wc -c < ios/App/App/GoogleService-Info.plist) bytes)" + fi + # cap sync copies the built web assets (dist/) into android/app/src/main/assets/public/ + # and updates Capacitor plugin registrations in MainActivity. Must run after npm build. + - name: Capacitor sync + script: npx cap sync android + - name: Set up debug keystore + script: | + if [ -n "$CM_DEBUG_KEYSTORE" ]; then + echo "$CM_DEBUG_KEYSTORE" | base64 --decode > /tmp/debug-keystore.p12 + fi + - name: Build debug APK + script: | + cd android + if [ -n "$CM_DEBUG_KEYSTORE" ]; then + ./gradlew assembleDebug \ + -Pandroid.injected.signing.store.file=/tmp/debug-keystore.p12 \ + -Pandroid.injected.signing.store.password=$CM_DEBUG_KEYSTORE_PASSWORD \ + -Pandroid.injected.signing.key.alias=debug \ + -Pandroid.injected.signing.key.password=$CM_DEBUG_KEYSTORE_PASSWORD \ + --no-daemon + else + ./gradlew assembleDebug --no-daemon + fi + artifacts: + - android/app/build/outputs/apk/debug/app-debug.apk + + android-release-apk: + name: Android – Release APK + max_build_duration: 45 + instance_type: mac_mini_m2 + environment: + node: 22 + java: 21 + cache: + cache_paths: + - $HOME/.gradle/caches + - $HOME/.gradle/wrapper + scripts: + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + - name: Write Firebase config + script: | + if [ -n "$GOOGLE_SERVICES_JSON" ]; then + echo "$GOOGLE_SERVICES_JSON" | base64 --decode > android/app/google-services.json + fi + - name: Capacitor sync + script: npx cap sync android + - name: Set up keystore + script: echo "$CM_KEYSTORE" | base64 --decode > /tmp/keystore.jks + - name: Build Release APK + script: | + cd android + ./gradlew assembleRelease \ + -Pandroid.injected.signing.store.file=/tmp/keystore.jks \ + -Pandroid.injected.signing.store.password=$CM_KEYSTORE_PASSWORD \ + -Pandroid.injected.signing.key.alias=$CM_KEY_ALIAS \ + -Pandroid.injected.signing.key.password=$CM_KEY_PASSWORD \ + --no-daemon + artifacts: + - android/app/build/outputs/apk/release/app-release.apk + + android-release-aab: + name: Android – Release AAB + max_build_duration: 45 + instance_type: mac_mini_m2 + environment: + node: 22 + java: 21 + cache: + cache_paths: + - $HOME/.gradle/caches + - $HOME/.gradle/wrapper + scripts: + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + - name: Write Firebase config + script: | + if [ -n "$GOOGLE_SERVICES_JSON" ]; then + echo "$GOOGLE_SERVICES_JSON" | base64 --decode > android/app/google-services.json + fi + - name: Capacitor sync + script: npx cap sync android + - name: Set up keystore + script: echo "$CM_KEYSTORE" | base64 --decode > /tmp/keystore.jks + - name: Build Release AAB + script: | + cd android + ./gradlew bundleRelease \ + -Pandroid.injected.signing.store.file=/tmp/keystore.jks \ + -Pandroid.injected.signing.store.password=$CM_KEYSTORE_PASSWORD \ + -Pandroid.injected.signing.key.alias=$CM_KEY_ALIAS \ + -Pandroid.injected.signing.key.password=$CM_KEY_PASSWORD \ + --no-daemon + artifacts: + - android/app/build/outputs/bundle/release/app-release.aab + + android-release: + name: Android – Publish to Google Play + max_build_duration: 60 + instance_type: mac_mini_m2 + environment: + node: 22 + java: 21 + cache: + cache_paths: + - $HOME/.gradle/caches + - $HOME/.gradle/wrapper + scripts: + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + - name: Write Firebase config + script: | + if [ -n "$GOOGLE_SERVICES_JSON" ]; then + echo "$GOOGLE_SERVICES_JSON" | base64 --decode > android/app/google-services.json + fi + - name: Capacitor sync + script: npx cap sync android + - name: Set up keystore + script: echo "$CM_KEYSTORE" | base64 --decode > /tmp/keystore.jks + - name: Build Release AAB + script: | + cd android + ./gradlew bundleRelease \ + -Pandroid.injected.signing.store.file=/tmp/keystore.jks \ + -Pandroid.injected.signing.store.password=$CM_KEYSTORE_PASSWORD \ + -Pandroid.injected.signing.key.alias=$CM_KEY_ALIAS \ + -Pandroid.injected.signing.key.password=$CM_KEY_PASSWORD \ + --no-daemon + publishing: + google_play: + credentials: $GOOGLE_PLAY_SERVICE_ACCOUNT_CREDENTIALS + track: $GOOGLE_PLAY_TRACK + submit_as_draft: false + artifacts: + - android/app/build/outputs/bundle/release/app-release.aab + + ios-debug: + name: iOS – Debug IPA + max_build_duration: 60 + instance_type: mac_mini_m2 + environment: + node: 22 + xcode: latest + scripts: + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + # First sync: regenerates CapApp-SPM/Package.swift with the correct plugin list. + # Note: this project uses Capacitor SPM (no CocoaPods/Podfile), so cap sync replaces + # pod install — it regenerates CapApp-SPM/Package.swift and copies web assets. + - name: Capacitor sync + script: npx cap sync ios + # Decode Firebase plist to disk so it is present during the second sync. + - name: Write Firebase config + script: | + if [ -n "$GOOGLE_SERVICE_INFO_PLIST" ]; then + echo "$GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > ios/App/App/GoogleService-Info.plist + fi + # Second sync ensures CapApp-SPM/Package.swift is consistent after the plist write. + - name: Capacitor sync + script: npx cap sync ios + # Run configure_xcode.rb after both syncs so its xcodeproj changes (plist file + # reference + SPM product linking) are not overwritten by a subsequent cap sync. + # configure_xcode.rb is stamped fresh from template on every build push. + - name: Configure Xcode project + script: ruby configure_xcode.rb + - name: Set up signing + script: | + keychain initialize + if [ -n "$APP_STORE_CONNECT_PRIVATE_KEY" ]; then + app-store-connect fetch-signing-files \ + $(xcode-project detect-bundle-id) \ + --type IOS_APP_DEVELOPMENT \ + --certificate-key=@env:APP_STORE_CONNECT_PRIVATE_KEY \ + --issuer-id=$APP_STORE_CONNECT_ISSUER_ID \ + --key-id=$APP_STORE_CONNECT_KEY_IDENTIFIER \ + --create + xcode-project use-profiles + elif [ -n "$CM_CERTIFICATE" ]; then + echo "$CM_CERTIFICATE" | base64 --decode > /tmp/cert.p12 + keychain add-certificates \ + --certificate /tmp/cert.p12 \ + --certificate-password "$CM_CERTIFICATE_PASSWORD" + mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" + echo "$CM_PROVISIONING_PROFILE" | base64 --decode > "$HOME/Library/MobileDevice/Provisioning Profiles/profile.mobileprovision" + xcode-project use-profiles + else + echo "No signing credentials configured — build will fail at signing" + exit 1 + fi + # --workspace: Capacitor SPM projects require workspace context for Xcode to resolve + # the CapApp-SPM local package. Using --project causes xcodebuild to fail on + # Xcode 26+ because SPM resolution requires workspace scope. App.xcworkspace is a + # static file committed to the template (not generated by cap sync) that wraps + # App.xcodeproj for this purpose. + # --no-show-build-settings: xcode-project runs xcodebuild -showBuildSettings as a + # pre-build diagnostic. Xcode 26 fails this step for SPM projects even with + # --workspace, so we skip it. The actual archive step still surfaces real errors. + # --disable-xcpretty: xcpretty reformats and filters xcodebuild output, swallowing + # the actual error lines when a build fails. Raw output makes failures debuggable. + - name: Build IPA + script: | + xcode-project build-ipa \ + --workspace ios/App/App.xcworkspace \ + --scheme App \ + --no-show-build-settings \ + --disable-xcpretty + artifacts: + - build/ios/ipa/*.ipa + + ios-release: + name: iOS – Release IPA + max_build_duration: 90 + instance_type: mac_mini_m2 + environment: + node: 22 + xcode: latest + scripts: + - name: Strip unused scaffold packages + script: | + for pkg in "@capacitor/google-maps" "@capacitor/push-notifications" "@capacitor-firebase/authentication"; do + if ! grep -rq "$pkg" src/; then + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json','utf8'));delete p.dependencies['${pkg}'];fs.writeFileSync('package.json',JSON.stringify(p,null,2));" + echo "Stripped $pkg (not used in src/)" + else + echo "Keeping $pkg (used in src/)" + fi + done + - name: Install dependencies + script: rm -f package-lock.json && npm install --legacy-peer-deps + - name: Build web assets + script: npm run build + - name: Capacitor sync + script: npx cap sync ios + - name: Configure Xcode project + script: | + if [ -n "$GOOGLE_SERVICE_INFO_PLIST" ]; then + echo "$GOOGLE_SERVICE_INFO_PLIST" | base64 --decode > ios/App/App/GoogleService-Info.plist + fi + - name: Capacitor sync + script: npx cap sync ios + - name: Configure Xcode project + script: ruby configure_xcode.rb + - name: Set up signing + script: | + keychain initialize + if [ -n "$APP_STORE_CONNECT_PRIVATE_KEY" ]; then + app-store-connect fetch-signing-files \ + $(xcode-project detect-bundle-id) \ + --type IOS_APP_STORE \ + --certificate-key=@env:APP_STORE_CONNECT_PRIVATE_KEY \ + --issuer-id=$APP_STORE_CONNECT_ISSUER_ID \ + --key-id=$APP_STORE_CONNECT_KEY_IDENTIFIER \ + --create + xcode-project use-profiles + else + echo "$CM_CERTIFICATE" | base64 --decode > /tmp/cert.p12 + keychain add-certificates \ + --certificate /tmp/cert.p12 \ + --certificate-password "$CM_CERTIFICATE_PASSWORD" + mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles" + echo "$CM_PROVISIONING_PROFILE" | base64 --decode > "$HOME/Library/MobileDevice/Provisioning Profiles/profile.mobileprovision" + xcode-project use-profiles + fi + # See ios-debug Build IPA comments for --workspace, --no-show-build-settings, + # and --disable-xcpretty rationale — same reasons apply here. + - name: Build IPA + script: | + xcode-project build-ipa \ + --workspace ios/App/App.xcworkspace \ + --scheme App \ + --config Release \ + --no-show-build-settings \ + --disable-xcpretty + - name: Publish + script: | + if [ "$SUBMIT_TO_TESTFLIGHT" = "true" ] || [ "$SUBMIT_TO_APP_STORE" = "true" ]; then + app-store-connect publish \ + --certificate-key=@env:APP_STORE_CONNECT_PRIVATE_KEY \ + --issuer-id=$APP_STORE_CONNECT_ISSUER_ID \ + --key-id=$APP_STORE_CONNECT_KEY_IDENTIFIER \ + --submit-to-testflight=$SUBMIT_TO_TESTFLIGHT \ + --submit-to-app-store=$SUBMIT_TO_APP_STORE + fi + artifacts: + - build/ios/ipa/*.ipa diff --git a/configure_xcode.rb b/configure_xcode.rb new file mode 100644 index 0000000..85e1e40 --- /dev/null +++ b/configure_xcode.rb @@ -0,0 +1,118 @@ +#!/usr/bin/env ruby +# configure_xcode.rb — stamped fresh from template on every build (see gitea.service.ts) +# +# 1. Adds GoogleService-Info.plist to the Xcode target if present (xcodeproj gem) +# 2. Scans Swift sources for Firebase imports and injects matching products into +# CapApp-SPM/Package.swift — the correct approach for Capacitor SPM projects +# where all native linking goes through CapApp-SPM, not App.xcodeproj directly. + +require 'xcodeproj' + +PROJECT_PATH = 'ios/App/App.xcodeproj' +TARGET_NAME = 'App' +PLIST_SRC = 'ios/App/App/GoogleService-Info.plist' +CAP_APP_SPM = 'ios/App/CapApp-SPM/Package.swift' + +# ── 1. GoogleService-Info.plist ─────────────────────────────────────────────── +if File.exist?(PLIST_SRC) + project = Xcodeproj::Project.open(PROJECT_PATH) + target = project.targets.find { |t| t.name == TARGET_NAME } + if target + app_group = project.main_group['App'] + unless app_group&.files&.find { |f| f.path == 'GoogleService-Info.plist' } + file_ref = app_group.new_reference('GoogleService-Info.plist') + target.resources_build_phase.add_file_reference(file_ref) + project.save + puts "Added GoogleService-Info.plist to target" + end + end +end + +# ── 2. Scan Swift sources for Firebase imports ──────────────────────────────── +swift_files = Dir['ios/App/App/**/*.swift'] +firebase_imports = swift_files + .flat_map { |f| File.readlines(f) rescue [] } + .grep(/^\s*import\s+Firebase\w+/) + .map { |l| l.strip.split(/\s+/).last } + .uniq + .sort + +if firebase_imports.empty? + puts "No Firebase imports found — skipping CapApp-SPM update" + exit 0 +end + +puts "Firebase imports detected: #{firebase_imports.join(', ')}" + +unless File.exist?(CAP_APP_SPM) + warn "WARNING: #{CAP_APP_SPM} not found — was cap sync run?" + exit 0 +end + +# ── 3. Detect firebase-ios-sdk URL and version from node_modules ────────────── +# Read from the ACTUAL node_modules on this build machine (populated by npm install) +# so the version we inject matches what @capacitor-firebase/* already resolved. +firebase_url = nil +firebase_version = nil + +Dir['node_modules/@capacitor-firebase/**/Package.swift', + 'node_modules/@capacitor/push-notifications/**/Package.swift'].each do |f| + content = File.read(f) rescue next + url_m = content.match(/\.package\(url:\s*"(https:\/\/github\.com\/firebase\/firebase-ios-sdk[^"]*)"/) + ver_m = content.match(/firebase-ios-sdk[^)]+from:\s*"(\d+)\.(\d+)\.(\d+)"/) + next unless url_m && ver_m + + firebase_url = url_m[1] + major = ver_m[1].to_i + firebase_version = "#{major}.0.0" + puts "Detected firebase-ios-sdk from #{f}: url=#{firebase_url} → using from: \"#{firebase_version}\"" + break +end + +# Fallback — should rarely be needed +unless firebase_url + firebase_url = 'https://github.com/firebase/firebase-ios-sdk.git' + firebase_version = '11.0.0' + puts "Could not detect firebase-ios-sdk version from node_modules — using fallback #{firebase_version}" +end + +firebase_pkg = 'firebase-ios-sdk' + +lines = File.read(CAP_APP_SPM).split("\n") + +# ── 4. Inject firebase-ios-sdk as a direct package dependency if missing ────── +# Normalise URL check to handle both with and without .git suffix +firebase_url_base = firebase_url.sub(/\.git$/, '') +unless lines.any? { |l| l.include?(firebase_url_base) } + last_pkg_idx = lines.rindex { |l| l.include?('.package(') } + if last_pkg_idx + lines[last_pkg_idx] = lines[last_pkg_idx].rstrip + lines[last_pkg_idx] += ',' unless lines[last_pkg_idx].end_with?(',') + lines.insert(last_pkg_idx + 1, + " .package(url: \"#{firebase_url}\", from: \"#{firebase_version}\")") + puts "Added #{firebase_pkg} to CapApp-SPM package dependencies" + else + warn "WARNING: no .package( line found in #{CAP_APP_SPM} — cannot inject dependency" + end +end + +# ── 5. Inject each detected product into the target dependencies if missing ─── +firebase_imports.each do |product| + next if product == 'Firebase' # umbrella import — not a linkable SPM product + + product_str = ".product(name: \"#{product}\", package: \"#{firebase_pkg}\")" + next if lines.any? { |l| l.include?(product_str) } + + last_prod_idx = lines.rindex { |l| l.include?('.product(') } + if last_prod_idx + lines[last_prod_idx] = lines[last_prod_idx].rstrip + lines[last_prod_idx] += ',' unless lines[last_prod_idx].end_with?(',') + lines.insert(last_prod_idx + 1, " #{product_str}") + puts "Added #{product} to CapApp-SPM target dependencies" + else + warn "WARNING: no .product( line found in #{CAP_APP_SPM} — cannot inject #{product}" + end +end + +File.write(CAP_APP_SPM, lines.join("\n")) +puts "CapApp-SPM/Package.swift updated" diff --git a/index.html b/index.html new file mode 100644 index 0000000..e19807b --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + + + Ionic App + + + + + + + + + + + + + + + + +
+ + + diff --git a/ionic.config.json b/ionic.config.json new file mode 100644 index 0000000..a1d1b22 --- /dev/null +++ b/ionic.config.json @@ -0,0 +1,5 @@ +{ + "name": "app", + "integrations": {}, + "type": "react-vite" +} diff --git a/ios/.DS_Store b/ios/.DS_Store new file mode 100644 index 0000000..b49404c Binary files /dev/null and b/ios/.DS_Store differ diff --git a/ios/.gitignore b/ios/.gitignore new file mode 100644 index 0000000..f470299 --- /dev/null +++ b/ios/.gitignore @@ -0,0 +1,13 @@ +App/build +App/Pods +App/output +App/App/public +DerivedData +xcuserdata + +# Cordova plugins for Capacitor +capacitor-cordova-ios-plugins + +# Generated Config files +App/App/capacitor.config.json +App/App/config.xml diff --git a/ios/App/.DS_Store b/ios/App/.DS_Store new file mode 100644 index 0000000..0864069 Binary files /dev/null and b/ios/App/.DS_Store differ diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj new file mode 100644 index 0000000..406cdd7 --- /dev/null +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -0,0 +1,380 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 60; + objects = { + +/* Begin PBXBuildFile section */ + 2FAD9763203C412B000D30F8 /* config.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2FAD9762203C412B000D30F8 /* config.xml */; }; + 4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */ = {isa = PBXBuildFile; productRef = 4D22ABE82AF431CB00220026 /* CapApp-SPM */; }; + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */ = {isa = PBXBuildFile; fileRef = 50379B222058CBB4000EE86E /* capacitor.config.json */; }; + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC3071FED79650016851F /* AppDelegate.swift */; }; + 504EC30D1FED79650016851F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30B1FED79650016851F /* Main.storyboard */; }; + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; }; + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; }; + 50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = ""; }; + 50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = ""; }; + 504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 504EC3071FED79650016851F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 504EC30C1FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 504EC30E1FED79650016851F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 1A4EB3C21FED79650016851F /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = ""; }; + 50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = ""; }; + 958DCC722DB07C7200EA8C5F /* debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../debug.xcconfig; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 504EC3011FED79650016851F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4D22ABE92AF431CB00220026 /* CapApp-SPM in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 504EC2FB1FED79650016851F = { + isa = PBXGroup; + children = ( + 958DCC722DB07C7200EA8C5F /* debug.xcconfig */, + 504EC3061FED79650016851F /* App */, + 504EC3051FED79650016851F /* Products */, + ); + sourceTree = ""; + }; + 504EC3051FED79650016851F /* Products */ = { + isa = PBXGroup; + children = ( + 504EC3041FED79650016851F /* App.app */, + ); + name = Products; + sourceTree = ""; + }; + 504EC3061FED79650016851F /* App */ = { + isa = PBXGroup; + children = ( + 50379B222058CBB4000EE86E /* capacitor.config.json */, + 504EC3071FED79650016851F /* AppDelegate.swift */, + 504EC30B1FED79650016851F /* Main.storyboard */, + 504EC30E1FED79650016851F /* Assets.xcassets */, + 504EC3101FED79650016851F /* LaunchScreen.storyboard */, + 504EC3131FED79650016851F /* Info.plist */, + 1A4EB3C21FED79650016851F /* App.entitlements */, + 2FAD9762203C412B000D30F8 /* config.xml */, + 50B271D01FEDC1A000F3C39B /* public */, + ); + path = App; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 504EC3031FED79650016851F /* App */ = { + isa = PBXNativeTarget; + buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */; + buildPhases = ( + 504EC3001FED79650016851F /* Sources */, + 504EC3011FED79650016851F /* Frameworks */, + 504EC3021FED79650016851F /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = App; + packageProductDependencies = ( + 4D22ABE82AF431CB00220026 /* CapApp-SPM */, + ); + productName = App; + productReference = 504EC3041FED79650016851F /* App.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 504EC2FC1FED79650016851F /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 0920; + TargetAttributes = { + 504EC3031FED79650016851F = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 504EC2FB1FED79650016851F; + packageReferences = ( + D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */, + ); + productRefGroup = 504EC3051FED79650016851F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 504EC3031FED79650016851F /* App */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 504EC3021FED79650016851F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */, + 50B271D11FEDC1A000F3C39B /* public in Resources */, + 504EC30F1FED79650016851F /* Assets.xcassets in Resources */, + 50379B232058CBB4000EE86E /* capacitor.config.json in Resources */, + 504EC30D1FED79650016851F /* Main.storyboard in Resources */, + 2FAD9763203C412B000D30F8 /* config.xml in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 504EC3001FED79650016851F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 504EC3081FED79650016851F /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 504EC30B1FED79650016851F /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC30C1FED79650016851F /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 504EC3101FED79650016851F /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 504EC3111FED79650016851F /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 504EC3141FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 504EC3151FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 504EC3171FED79650016851F /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 958DCC722DB07C7200EA8C5F /* debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 3; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; + PRODUCT_BUNDLE_IDENTIFIER = com.qoutelink.app; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 504EC3181FED79650016851F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = App/App.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 3; + INFOPLIST_FILE = App/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.qoutelink.app; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 504EC2FF1FED79650016851F /* Build configuration list for PBXProject "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3141FED79650016851F /* Debug */, + 504EC3151FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 504EC3171FED79650016851F /* Debug */, + 504EC3181FED79650016851F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = "CapApp-SPM"; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 4D22ABE82AF431CB00220026 /* CapApp-SPM */ = { + isa = XCSwiftPackageProductDependency; + package = D4C12C0A2AAA248700AAC8A2 /* XCLocalSwiftPackageReference "CapApp-SPM" */; + productName = "CapApp-SPM"; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 504EC2FC1FED79650016851F /* Project object */; +} diff --git a/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/App/App.xcworkspace/contents.xcworkspacedata b/ios/App/App.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..b3795ee --- /dev/null +++ b/ios/App/App.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios/App/App/App.entitlements b/ios/App/App/App.entitlements new file mode 100644 index 0000000..6631ffa --- /dev/null +++ b/ios/App/App/App.entitlements @@ -0,0 +1,6 @@ + + + + + + diff --git a/ios/App/App/AppDelegate.swift b/ios/App/App/AppDelegate.swift new file mode 100644 index 0000000..c3cd83b --- /dev/null +++ b/ios/App/App/AppDelegate.swift @@ -0,0 +1,49 @@ +import UIKit +import Capacitor + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { + // Called when the app was launched with a url. Feel free to add additional processing here, + // but if you want the App API to support tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(app, open: url, options: options) + } + + func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { + // Called when the app was launched with an activity, including Universal Links. + // Feel free to add additional processing here, but if you want the App API to support + // tracking app url opens, make sure to keep this call + return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler) + } + +} diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png new file mode 100644 index 0000000..adf6ba0 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..6c95d9f --- /dev/null +++ b/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images": [ + { + "idiom": "iphone", + "scale": "1x", + "size": "20x20", + "filename": "icon-20.png" + }, + { + "idiom": "ipad", + "scale": "1x", + "size": "20x20", + "filename": "icon-20.png" + }, + { + "idiom": "iphone", + "scale": "1x", + "size": "29x29", + "filename": "icon-29.png" + }, + { + "idiom": "ipad", + "scale": "1x", + "size": "29x29", + "filename": "icon-29.png" + }, + { + "idiom": "ipad", + "scale": "1x", + "size": "40x40", + "filename": "icon-40.png" + }, + { + "idiom": "iphone", + "scale": "2x", + "size": "20x20", + "filename": "icon-40.png" + }, + { + "idiom": "iphone", + "scale": "2x", + "size": "29x29", + "filename": "icon-58.png" + }, + { + "idiom": "ipad", + "scale": "2x", + "size": "29x29", + "filename": "icon-58.png" + }, + { + "idiom": "iphone", + "scale": "3x", + "size": "20x20", + "filename": "icon-60.png" + }, + { + "idiom": "ipad", + "scale": "1x", + "size": "76x76", + "filename": "icon-76.png" + }, + { + "idiom": "iphone", + "scale": "2x", + "size": "40x40", + "filename": "icon-80.png" + }, + { + "idiom": "ipad", + "scale": "2x", + "size": "40x40", + "filename": "icon-80.png" + }, + { + "idiom": "iphone", + "scale": "3x", + "size": "29x29", + "filename": "icon-87.png" + }, + { + "idiom": "iphone", + "scale": "2x", + "size": "60x60", + "filename": "icon-120.png" + }, + { + "idiom": "iphone", + "scale": "3x", + "size": "40x40", + "filename": "icon-120.png" + }, + { + "idiom": "ipad", + "scale": "2x", + "size": "76x76", + "filename": "icon-152.png" + }, + { + "idiom": "ipad", + "scale": "2x", + "size": "83.5x83.5", + "filename": "icon-167.png" + }, + { + "idiom": "iphone", + "scale": "3x", + "size": "60x60", + "filename": "icon-180.png" + }, + { + "idiom": "ios-marketing", + "scale": "1x", + "size": "1024x1024", + "filename": "icon-1024.png" + } + ], + "info": { + "author": "appsuite", + "version": 1 + } +} \ No newline at end of file diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-1024.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-1024.png new file mode 100644 index 0000000..378f051 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-1024.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-120.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-120.png new file mode 100644 index 0000000..aab445a Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-120.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-152.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-152.png new file mode 100644 index 0000000..31ce5a8 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-152.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-167.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-167.png new file mode 100644 index 0000000..aafb720 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-167.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-180.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-180.png new file mode 100644 index 0000000..dc14084 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-180.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-20.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-20.png new file mode 100644 index 0000000..892472e Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-20.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-29.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-29.png new file mode 100644 index 0000000..80ccf1e Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-29.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-40.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-40.png new file mode 100644 index 0000000..0d610ac Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-40.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-58.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-58.png new file mode 100644 index 0000000..51cd0a4 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-58.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-60.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-60.png new file mode 100644 index 0000000..744a54f Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-60.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-76.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-76.png new file mode 100644 index 0000000..4da94e1 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-76.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-80.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-80.png new file mode 100644 index 0000000..fab5340 Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-80.png differ diff --git a/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-87.png b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-87.png new file mode 100644 index 0000000..34eaa4c Binary files /dev/null and b/ios/App/App/Assets.xcassets/AppIcon.appiconset/icon-87.png differ diff --git a/ios/App/App/Assets.xcassets/Contents.json b/ios/App/App/Assets.xcassets/Contents.json new file mode 100644 index 0000000..da4a164 --- /dev/null +++ b/ios/App/App/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json b/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json new file mode 100644 index 0000000..fd86df6 --- /dev/null +++ b/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json @@ -0,0 +1,13 @@ +{ + "images": [ + { + "idiom": "universal", + "filename": "splash.png", + "scale": "1x" + } + ], + "info": { + "author": "appsuite", + "version": 1 + } +} \ No newline at end of file diff --git a/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png differ diff --git a/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png differ diff --git a/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png new file mode 100644 index 0000000..33ea6c9 Binary files /dev/null and b/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png differ diff --git a/ios/App/App/Assets.xcassets/Splash.imageset/splash.png b/ios/App/App/Assets.xcassets/Splash.imageset/splash.png new file mode 100644 index 0000000..9d1a6f1 Binary files /dev/null and b/ios/App/App/Assets.xcassets/Splash.imageset/splash.png differ diff --git a/ios/App/App/Base.lproj/LaunchScreen.storyboard b/ios/App/App/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..e7ae5d7 --- /dev/null +++ b/ios/App/App/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ios/App/App/Base.lproj/Main.storyboard b/ios/App/App/Base.lproj/Main.storyboard new file mode 100644 index 0000000..b44df7b --- /dev/null +++ b/ios/App/App/Base.lproj/Main.storyboard @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/ios/App/App/Info.plist b/ios/App/App/Info.plist new file mode 100644 index 0000000..607ea8e --- /dev/null +++ b/ios/App/App/Info.plist @@ -0,0 +1,66 @@ + + + + + CAPACITOR_DEBUG + $(CAPACITOR_DEBUG) + CFBundleDevelopmentRegion + en + CFBundleDisplayName + Qoutelink + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(MARKETING_VERSION) + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + NSPhotoLibraryUsageDescription + We need access to your photo library so you can attach site photos and references to your requests. + NSCameraUsageDescription + We need access to your camera so you can take site photos for your requests. + CFBundleURLTypes + + + CFBundleURLName + com.qoutelink.app + CFBundleURLSchemes + + com.qoutelink.app + + + + + diff --git a/ios/App/CapApp-SPM/.gitignore b/ios/App/CapApp-SPM/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/ios/App/CapApp-SPM/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/ios/App/CapApp-SPM/Package.swift b/ios/App/CapApp-SPM/Package.swift new file mode 100644 index 0000000..5cde8b6 --- /dev/null +++ b/ios/App/CapApp-SPM/Package.swift @@ -0,0 +1,25 @@ +// swift-tools-version: 5.9 +import PackageDescription + +// DO NOT MODIFY THIS FILE - managed by Capacitor CLI commands +let package = Package( + name: "CapApp-SPM", + platforms: [.iOS(.v15)], + products: [ + .library( + name: "CapApp-SPM", + targets: ["CapApp-SPM"]) + ], + dependencies: [ + .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0") + ], + targets: [ + .target( + name: "CapApp-SPM", + dependencies: [ + .product(name: "Capacitor", package: "capacitor-swift-pm"), + .product(name: "Cordova", package: "capacitor-swift-pm") + ] + ) + ] +) diff --git a/ios/App/CapApp-SPM/README.md b/ios/App/CapApp-SPM/README.md new file mode 100644 index 0000000..03964db --- /dev/null +++ b/ios/App/CapApp-SPM/README.md @@ -0,0 +1,5 @@ +# CapApp-SPM + +This package is used to host SPM dependencies for your Capacitor project + +Do not modify the contents of it or there may be unintended consequences. diff --git a/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift b/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift new file mode 100644 index 0000000..945afec --- /dev/null +++ b/ios/App/CapApp-SPM/Sources/CapApp-SPM/CapApp-SPM.swift @@ -0,0 +1 @@ +public let isCapacitorApp = true diff --git a/ios/debug.xcconfig b/ios/debug.xcconfig new file mode 100644 index 0000000..53ce18d --- /dev/null +++ b/ios/debug.xcconfig @@ -0,0 +1 @@ +CAPACITOR_DEBUG = true diff --git a/package.json b/package.json new file mode 100644 index 0000000..8fdecda --- /dev/null +++ b/package.json @@ -0,0 +1,54 @@ +{ + "name": "app", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "lint": "eslint" + }, + "dependencies": { + "@capacitor-firebase/authentication": "^8.0.0", + "@capacitor/android": "8.3.4", + "@capacitor/app": "8.1.0", + "@capacitor/core": "8.3.4", + "@capacitor/google-maps": "^8.0.0", + "@capacitor/haptics": "8.0.2", + "@capacitor/ios": "8.3.4", + "@capacitor/keyboard": "8.0.3", + "@capacitor/preferences": "^8.0.1", + "@capacitor/push-notifications": "^8.1.1", + "@capacitor/status-bar": "8.0.2", + "@hookform/resolvers": "^3.9.0", + "@ionic/pwa-elements": "^3.0.0", + "@ionic/react": "8.8.7", + "@ionic/react-router": "8.8.7", + "@supabase/supabase-js": "^2.108.1", + "firebase": "^11.0.0", + "ionicons": "^7.4.0", + "katex": "^0.16.0", + "react": "18.2.0", + "react-dom": "18.2.0", + "react-hook-form": "^7.54.0", + "react-katex": "^3.0.1", + "react-router": "^5.3.4", + "react-router-dom": "^5.3.4", + "zod": "^3.24.0", + "zustand": "^5.0.0" + }, + "devDependencies": { + "@capacitor/cli": "8.3.4", + "@types/katex": "^0.16.0", + "@types/react": "^19.0.0", + "@types/react-dom": "^19.0.0", + "@types/react-router": "^5.1.20", + "@types/react-router-dom": "^5.3.3", + "@vitejs/plugin-react": "^4.0.1", + "terser": "^5.4.0", + "typescript": "~5.9.0", + "vite": "^5.0.0" + }, + "description": "An Ionic project" +} diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..2ce8c03 --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "Ionic App", + "name": "My Ionic App", + "icons": [ + { + "src": "assets/icon/favicon.png", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#ffffff", + "background_color": "#ffffff" +} diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..71ce1e6 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..4f63f26 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,56 @@ +import React, { useEffect } from 'react'; +import { IonApp } from '@ionic/react'; +import { IonReactRouter } from '@ionic/react-router'; + +import { AuthProvider } from './contexts/AuthContext'; +import { ProfileProvider, useProfile } from './contexts/ProfileContext'; +import AppRoutes from './AppRoutes'; +import { setStatusBarStyle, Style } from './utils/statusBar'; + +/* Core CSS required for Ionic components to work properly */ +import '@ionic/react/css/core.css'; + +/* Basic CSS for apps built with Ionic */ +import '@ionic/react/css/normalize.css'; +import '@ionic/react/css/structure.css'; +import '@ionic/react/css/typography.css'; + +/* Optional CSS utils that can be commented out */ +import '@ionic/react/css/padding.css'; +import '@ionic/react/css/float-elements.css'; +import '@ionic/react/css/text-alignment.css'; +import '@ionic/react/css/text-transformation.css'; +import '@ionic/react/css/flex-utils.css'; +import '@ionic/react/css/display.css'; + +/* Theme variables */ +import './theme/variables.css'; + +const AppShell: React.FC = () => { + const { themeMode } = useProfile(); + + useEffect(() => { + document.body.classList.toggle('dark', themeMode === 'dark'); + setStatusBarStyle(themeMode === 'dark' ? Style.Dark : Style.Light); + }, [themeMode]); + + return ( + + + + ); +}; + +const App: React.FC = () => { + return ( + + + + + + + + ); +}; + +export default App; diff --git a/src/AppRoutes.tsx b/src/AppRoutes.tsx new file mode 100644 index 0000000..d457a88 --- /dev/null +++ b/src/AppRoutes.tsx @@ -0,0 +1,105 @@ +import React from 'react'; +import { Route, Redirect } from 'react-router-dom'; +import { + IonRouterOutlet, + IonTabs, + IonTabBar, + IonTabButton, + IonIcon, + IonLabel, +} from '@ionic/react'; +import { + homeOutline, + documentTextOutline, + personOutline, +} from 'ionicons/icons'; +import { useAuth } from './contexts/AuthContext'; + +import Auth from './pages/Auth'; +import VerifyEmail from './pages/VerifyEmail'; +import ForgotPassword from './pages/ForgotPassword'; +import VerifyReset from './pages/VerifyReset'; +import SetupProfile from './pages/SetupProfile'; +import Home from './pages/Home'; +import BuyerRequests from './pages/BuyerRequests'; +import NewRfq from './pages/NewRfq'; +import RfqDetail from './pages/RfqDetail'; +import SupplierQuoteForm from './pages/SupplierQuoteForm'; +import BuyerQuoteList from './pages/BuyerQuoteList'; +import Profile from './pages/Profile'; +import EditProfile from './pages/EditProfile'; +import ProtectedRoute from './components/ProtectedRoute'; + +const AppRoutes: React.FC = () => { + const { user } = useAuth(); + + return ( + + {/* Auth routes */} + + + + + + {/* Setup Profile (guarded manually by user presence, not ProtectedRoute to avoid loop) */} + (!user ? : )} + /> + + {/* Pushed routes without tab bar */} + + + + + + + {/* Tabs */} + ( + + + + + + + + + + + Home + + + + Requests + + + + Profile + + + + )} + /> + + {/* Default Redirect */} + } /> + + ); +}; + +export default AppRoutes; diff --git a/src/components/DashboardMetricCard.tsx b/src/components/DashboardMetricCard.tsx new file mode 100644 index 0000000..ffb364a --- /dev/null +++ b/src/components/DashboardMetricCard.tsx @@ -0,0 +1,97 @@ +import React from 'react'; +import { IonIcon } from '@ionic/react'; + +interface DashboardMetricCardProps { + label: string; + value: string; + hint: string; + icon: string; + onClick?: () => void; +} + +const DashboardMetricCard: React.FC = ({ + label, + value, + hint, + icon, + onClick, +}) => { + return ( +
+
+ + {label} + +
+ +
+
+
+
+ {value} +
+
+ {hint} +
+
+
+ ); +}; + +export default DashboardMetricCard; diff --git a/src/components/OtpInput.tsx b/src/components/OtpInput.tsx new file mode 100644 index 0000000..fdaedbd --- /dev/null +++ b/src/components/OtpInput.tsx @@ -0,0 +1,82 @@ +import React, { useRef, useState } from 'react'; +import { IonInput } from '@ionic/react'; + +interface OtpInputProps { + value: string; + onChange: (value: string) => void; + disabled?: boolean; +} + +const OtpInput: React.FC = ({ value, onChange, disabled }) => { + const inputsRef = useRef<(HTMLInputElement | null)[]>([]); + + // Convert current value string into an array of 6 chars + const digits = value.split('').concat(Array(6).fill('')).slice(0, 6); + + const handleChange = (e: any, index: number) => { + let val = e.target.value; + // Allow only numeric + if (!/^[0-9]*$/.test(val)) return; + + // Grab the last character if they typed multiple + val = val.substring(val.length - 1); + + const newDigits = [...digits]; + newDigits[index] = val; + onChange(newDigits.join('')); + + // Move to next input if filled + if (val !== '' && index < 5) { + const nextInput = inputsRef.current[index + 1]; + if (nextInput) nextInput.focus(); + } + }; + + const handleKeyDown = ( + e: React.KeyboardEvent, + index: number + ) => { + if (e.key === 'Backspace' && !digits[index] && index > 0) { + // Move to previous input on backspace if current is empty + const prevInput = inputsRef.current[index - 1]; + if (prevInput) { + prevInput.focus(); + } + } + }; + + return ( +
+ {digits.map((digit, index) => ( + { + inputsRef.current[index] = el; + }} + type="text" + inputMode="numeric" + pattern="[0-9]*" + maxLength={2} + value={digit} + onChange={(e) => handleChange(e, index)} + onKeyDown={(e) => handleKeyDown(e, index)} + disabled={disabled} + style={{ + width: '100%', + maxWidth: '48px', + height: '52px', + borderRadius: '12px', + border: 'none', + background: '#f4f7f4', + color: '#0f1720', + textAlign: 'center', + fontSize: '24px', + fontWeight: '600', + }} + /> + ))} +
+ ); +}; + +export default OtpInput; diff --git a/src/components/ProfileInfoRow.tsx b/src/components/ProfileInfoRow.tsx new file mode 100644 index 0000000..f97de4f --- /dev/null +++ b/src/components/ProfileInfoRow.tsx @@ -0,0 +1,92 @@ +import React from 'react'; +import { IonIcon } from '@ionic/react'; + +interface ProfileInfoRowProps { + icon: string; + label: string; + value?: string; + onClick?: () => void; +} + +const ProfileInfoRow: React.FC = ({ + icon, + label, + value, + onClick, +}) => { + return ( +
+
+
+ +
+
+ + {label} + + {value && ( + + {value} + + )} +
+
+
+ ); +}; + +export default ProfileInfoRow; diff --git a/src/components/ProtectedRoute.tsx b/src/components/ProtectedRoute.tsx new file mode 100644 index 0000000..6f44b38 --- /dev/null +++ b/src/components/ProtectedRoute.tsx @@ -0,0 +1,57 @@ +import React, { useEffect } from 'react'; +import { Route, Redirect, RouteProps } from 'react-router-dom'; +import { IonSpinner } from '@ionic/react'; +import { useAuth } from '../contexts/AuthContext'; +import { useProfile } from '../contexts/ProfileContext'; +import { useProfileLoader } from '../hooks/useProfileLoader'; + +interface ProtectedRouteProps extends RouteProps { + component: React.ComponentType; +} + +const ProtectedRoute: React.FC = ({ + component: Component, + ...rest +}) => { + const { user } = useAuth(); + const { status } = useProfile(); + const { loadProfileAndNavigate } = useProfileLoader(); + + useEffect(() => { + // If user is logged in but profile is still loading (e.g. cold start direct link) + if (user && status === 'loading') { + loadProfileAndNavigate(); + } + }, [user, status, loadProfileAndNavigate]); + + return ( + { + if (!user) { + return ; + } + if (status === 'loading') { + return ( +
+ +
+ ); + } + if (status === 'missing') { + return ; + } + return ; + }} + /> + ); +}; + +export default ProtectedRoute; diff --git a/src/components/QuotationCard.tsx b/src/components/QuotationCard.tsx new file mode 100644 index 0000000..4c3518a --- /dev/null +++ b/src/components/QuotationCard.tsx @@ -0,0 +1,121 @@ +import React from 'react'; + +interface QuotationCardProps { + supplierName: string; + priceLabel: string; + deliveryOption: string; + status: string; + onAccept: () => void; + onDecline: () => void; +} + +const QuotationCard: React.FC = ({ + supplierName, + priceLabel, + deliveryOption, + status, + onAccept, + onDecline, +}) => { + return ( +
+
+ {supplierName} +
+ +
+ {priceLabel} +
+ +
+ {deliveryOption} +
+ + {status === 'submitted' ? ( +
+ + +
+ ) : ( +
+ {status} +
+ )} +
+ ); +}; + +export default QuotationCard; diff --git a/src/components/QuoteSummaryRow.tsx b/src/components/QuoteSummaryRow.tsx new file mode 100644 index 0000000..f200852 --- /dev/null +++ b/src/components/QuoteSummaryRow.tsx @@ -0,0 +1,90 @@ +import React from 'react'; + +interface QuoteSummaryRowProps { + supplierName: string; + priceLabel: string; + deliveryOption: string; + status: string; + onClick?: () => void; +} + +const QuoteSummaryRow: React.FC = ({ + supplierName, + priceLabel, + deliveryOption, + status, + onClick, +}) => { + return ( +
+
+ + {supplierName} + + + {priceLabel} + +
+
+ + {deliveryOption} + + + {status} + +
+
+ ); +}; + +export default QuoteSummaryRow; diff --git a/src/components/RecentActivityCard.tsx b/src/components/RecentActivityCard.tsx new file mode 100644 index 0000000..543e505 --- /dev/null +++ b/src/components/RecentActivityCard.tsx @@ -0,0 +1,83 @@ +import React from 'react'; + +interface RecentActivityCardProps { + title: string; + subtitle: string; + meta: string; + onClick: () => void; +} + +const RecentActivityCard: React.FC = ({ + title, + subtitle, + meta, + onClick, +}) => { + return ( +
+
+
+ + {title} + + + {subtitle} + +
+
+ {meta} +
+
+
+ ); +}; + +export default RecentActivityCard; diff --git a/src/components/RequestListCard.tsx b/src/components/RequestListCard.tsx new file mode 100644 index 0000000..711000c --- /dev/null +++ b/src/components/RequestListCard.tsx @@ -0,0 +1,135 @@ +import React from 'react'; + +interface RequestListCardProps { + title: string; + subtitle: string; + referenceNumber: string; + status: string; + trailingText?: string; + onClick: () => void; +} + +const RequestListCard: React.FC = ({ + title, + subtitle, + referenceNumber, + status, + trailingText, + onClick, +}) => { + let statusBg = 'rgba(23,33,43,0.10)'; + let statusColor = '#4b5563'; + + if (status === 'open') { + statusBg = 'var(--color-success-soft)'; + statusColor = 'var(--color-success-text)'; + } else if (status === 'quoted') { + statusBg = 'var(--color-warning-soft)'; + statusColor = 'var(--color-warning-text)'; + } else if (status === 'closed') { + statusBg = 'rgba(23,33,43,0.10)'; + statusColor = '#4b5563'; + } + + return ( +
+
+
+ + {title} + + + {subtitle} + +
+ {trailingText && ( + + {trailingText} + + )} +
+
+
+ {referenceNumber} +
+
+ {status} +
+
+
+ ); +}; + +export default RequestListCard; diff --git a/src/components/SupplierPickerRow.tsx b/src/components/SupplierPickerRow.tsx new file mode 100644 index 0000000..3391eca --- /dev/null +++ b/src/components/SupplierPickerRow.tsx @@ -0,0 +1,63 @@ +import React from 'react'; +import { IonIcon } from '@ionic/react'; +import { checkmarkCircle, ellipseOutline } from 'ionicons/icons'; + +export interface SupplierOption { + id: string; + full_name: string; + company_name: string | null; + city: string | null; +} + +interface SupplierPickerRowProps { + supplier: SupplierOption; + selected: boolean; + onToggle: () => void; +} + +const SupplierPickerRow: React.FC = ({ + supplier, + selected, + onToggle, +}) => { + return ( +
+ +
+ + {supplier.company_name || supplier.full_name} + + + {supplier.company_name ? supplier.full_name : 'Independent'} + {supplier.city ? ` • ${supplier.city}` : ''} + +
+
+ ); +}; + +export default SupplierPickerRow; diff --git a/src/contexts/AuthContext.tsx b/src/contexts/AuthContext.tsx new file mode 100644 index 0000000..f5085ac --- /dev/null +++ b/src/contexts/AuthContext.tsx @@ -0,0 +1,51 @@ +import React, { createContext, useContext, useEffect, useState } from 'react'; +import { User } from '@supabase/supabase-js'; +import { supabase } from '../supabase'; + +interface AuthContextType { + user: User | null; + signOut: () => Promise; +} + +const AuthContext = createContext({ + user: null, + signOut: async () => {}, +}); + +export const useAuth = () => useContext(AuthContext); + +export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => { + const [user, setUser] = useState(null); + const [initializing, setInitializing] = useState(true); + + useEffect(() => { + supabase.auth.getSession().then(({ data }) => { + setUser(data.session?.user ?? null); + setInitializing(false); + }); + + const { + data: { subscription }, + } = supabase.auth.onAuthStateChange((_event, session) => { + setUser(session?.user ?? null); + }); + + return () => subscription.unsubscribe(); + }, []); + + const signOut = async () => { + await supabase.auth.signOut(); + }; + + if (initializing) { + return null; // Or a simple spinner if preferred, but usually handled nicely + } + + return ( + + {children} + + ); +}; diff --git a/src/contexts/ProfileContext.tsx b/src/contexts/ProfileContext.tsx new file mode 100644 index 0000000..c711fe5 --- /dev/null +++ b/src/contexts/ProfileContext.tsx @@ -0,0 +1,81 @@ +import React, { + createContext, + useContext, + useEffect, + useMemo, + useState, +} from 'react'; +import { Preferences } from '@capacitor/preferences'; +import { Database } from '../database.types'; + +export type Profile = Database['public']['Tables']['profiles']['Row']; +export type ThemeMode = 'light' | 'dark'; + +interface ProfileContextType { + profile: Profile | null; + status: 'loading' | 'loaded' | 'missing'; + themeMode: ThemeMode; + setProfile: (profile: Profile | null) => void; + setStatus: (status: 'loading' | 'loaded' | 'missing') => void; + setThemeMode: (mode: ThemeMode) => Promise; + clearProfile: () => void; +} + +const ProfileContext = createContext({ + profile: null, + status: 'loading', + themeMode: 'light', + setProfile: () => {}, + setStatus: () => {}, + setThemeMode: async () => {}, + clearProfile: () => {}, +}); + +export const useProfile = () => useContext(ProfileContext); + +export const ProfileProvider: React.FC<{ children: React.ReactNode }> = ({ + children, +}) => { + const [profile, setProfile] = useState(null); + const [status, setStatus] = useState<'loading' | 'loaded' | 'missing'>( + 'loading' + ); + const [themeModeState, setThemeModeState] = useState('light'); + + useEffect(() => { + const loadThemeMode = async () => { + const { value } = await Preferences.get({ key: 'theme_mode' }); + const mode = value === 'dark' ? 'dark' : 'light'; + setThemeModeState(mode); + }; + + loadThemeMode(); + }, []); + + const setThemeMode = async (mode: ThemeMode) => { + setThemeModeState(mode); + await Preferences.set({ key: 'theme_mode', value: mode }); + }; + + const clearProfile = () => { + setProfile(null); + setStatus('loading'); + }; + + const value = useMemo( + () => ({ + profile, + status, + themeMode: themeModeState, + setProfile, + setStatus, + setThemeMode, + clearProfile, + }), + [profile, status, themeModeState] + ); + + return ( + {children} + ); +}; diff --git a/src/database.types.ts b/src/database.types.ts new file mode 100644 index 0000000..3ceb7b0 --- /dev/null +++ b/src/database.types.ts @@ -0,0 +1,353 @@ +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[] + +export type Database = { + // Allows to automatically instantiate createClient with right options + // instead of createClient(URL, KEY) + __InternalSupabase: { + PostgrestVersion: "14.5" + } + public: { + Tables: { + profiles: { + Row: { + avatar_url: string | null + city: string | null + company_name: string | null + created_at: string + full_name: string + id: string + phone: string | null + role: string + updated_at: string + } + Insert: { + avatar_url?: string | null + city?: string | null + company_name?: string | null + created_at?: string + full_name: string + id: string + phone?: string | null + role: string + updated_at?: string + } + Update: { + avatar_url?: string | null + city?: string | null + company_name?: string | null + created_at?: string + full_name?: string + id?: string + phone?: string | null + role?: string + updated_at?: string + } + Relationships: [] + } + quotations: { + Row: { + created_at: string + currency_code: string + delivery_option: string + id: string + note: string | null + price_amount: number + rfq_id: string + status: string + supplier_id: string + updated_at: string + } + Insert: { + created_at?: string + currency_code?: string + delivery_option: string + id?: string + note?: string | null + price_amount: number + rfq_id: string + status?: string + supplier_id: string + updated_at?: string + } + Update: { + created_at?: string + currency_code?: string + delivery_option?: string + id?: string + note?: string | null + price_amount?: number + rfq_id?: string + status?: string + supplier_id?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "quotations_rfq_id_fkey" + columns: ["rfq_id"] + isOneToOne: false + referencedRelation: "rfqs" + referencedColumns: ["id"] + }, + { + foreignKeyName: "quotations_supplier_id_fkey" + columns: ["supplier_id"] + isOneToOne: false + referencedRelation: "profiles" + referencedColumns: ["id"] + }, + ] + } + rfq_images: { + Row: { + created_at: string + id: string + owner_id: string + rfq_id: string + storage_path: string + } + Insert: { + created_at?: string + id?: string + owner_id: string + rfq_id: string + storage_path: string + } + Update: { + created_at?: string + id?: string + owner_id?: string + rfq_id?: string + storage_path?: string + } + Relationships: [ + { + foreignKeyName: "rfq_images_rfq_id_fkey" + columns: ["rfq_id"] + isOneToOne: false + referencedRelation: "rfqs" + referencedColumns: ["id"] + }, + ] + } + rfq_recipients: { + Row: { + created_at: string + id: string + rfq_id: string + supplier_id: string + } + Insert: { + created_at?: string + id?: string + rfq_id: string + supplier_id: string + } + Update: { + created_at?: string + id?: string + rfq_id?: string + supplier_id?: string + } + Relationships: [ + { + foreignKeyName: "rfq_recipients_rfq_id_fkey" + columns: ["rfq_id"] + isOneToOne: false + referencedRelation: "rfqs" + referencedColumns: ["id"] + }, + { + foreignKeyName: "rfq_recipients_supplier_id_fkey" + columns: ["supplier_id"] + isOneToOne: false + referencedRelation: "profiles" + referencedColumns: ["id"] + }, + ] + } + rfqs: { + Row: { + buyer_id: string + created_at: string + id: string + reference_number: string + request_text: string + status: string + title: string + updated_at: string + } + Insert: { + buyer_id: string + created_at?: string + id?: string + reference_number: string + request_text: string + status?: string + title: string + updated_at?: string + } + Update: { + buyer_id?: string + created_at?: string + id?: string + reference_number?: string + request_text?: string + status?: string + title?: string + updated_at?: string + } + Relationships: [ + { + foreignKeyName: "rfqs_buyer_id_fkey" + columns: ["buyer_id"] + isOneToOne: false + referencedRelation: "profiles" + referencedColumns: ["id"] + }, + ] + } + } + Views: { + [_ in never]: never + } + Functions: { + [_ in never]: never + } + Enums: { + [_ in never]: never + } + CompositeTypes: { + [_ in never]: never + } + } +} + +type DatabaseWithoutInternals = Omit + +type DefaultSchema = DatabaseWithoutInternals[Extract] + +export type Tables< + DefaultSchemaTableNameOrOptions extends + | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) + | { schema: keyof DatabaseWithoutInternals }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals + } + ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & + DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) + : never = never, +> = DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals +} + ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & + DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R + } + ? R + : never + : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & + DefaultSchema["Views"]) + ? (DefaultSchema["Tables"] & + DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { + Row: infer R + } + ? R + : never + : never + +export type TablesInsert< + DefaultSchemaTableNameOrOptions extends + | keyof DefaultSchema["Tables"] + | { schema: keyof DatabaseWithoutInternals }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals + } + ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals +} + ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I + } + ? I + : never + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never + : never + +export type TablesUpdate< + DefaultSchemaTableNameOrOptions extends + | keyof DefaultSchema["Tables"] + | { schema: keyof DatabaseWithoutInternals }, + TableName extends DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals + } + ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] + : never = never, +> = DefaultSchemaTableNameOrOptions extends { + schema: keyof DatabaseWithoutInternals +} + ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U + } + ? U + : never + : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] + ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { + Update: infer U + } + ? U + : never + : never + +export type Enums< + DefaultSchemaEnumNameOrOptions extends + | keyof DefaultSchema["Enums"] + | { schema: keyof DatabaseWithoutInternals }, + EnumName extends DefaultSchemaEnumNameOrOptions extends { + schema: keyof DatabaseWithoutInternals + } + ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] + : never = never, +> = DefaultSchemaEnumNameOrOptions extends { + schema: keyof DatabaseWithoutInternals +} + ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] + : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] + ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] + : never + +export type CompositeTypes< + PublicCompositeTypeNameOrOptions extends + | keyof DefaultSchema["CompositeTypes"] + | { schema: keyof DatabaseWithoutInternals }, + CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { + schema: keyof DatabaseWithoutInternals + } + ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] + : never = never, +> = PublicCompositeTypeNameOrOptions extends { + schema: keyof DatabaseWithoutInternals +} + ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] + : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] + ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] + : never + +export const Constants = { + public: { + Enums: {}, + }, +} as const diff --git a/src/hooks/useProfileLoader.ts b/src/hooks/useProfileLoader.ts new file mode 100644 index 0000000..8399949 --- /dev/null +++ b/src/hooks/useProfileLoader.ts @@ -0,0 +1,86 @@ +import { useHistory } from 'react-router-dom'; +import { Preferences } from '@capacitor/preferences'; +import { supabase } from '../supabase'; +import { useAuth } from '../contexts/AuthContext'; +import { useProfile, Profile } from '../contexts/ProfileContext'; + +export const useProfileLoader = () => { + const history = useHistory(); + const { user } = useAuth(); + const { setProfile, setStatus } = useProfile(); + + const loadProfileAndNavigate = async ( + setOverlayVisible?: (v: boolean) => void, + setOverlayError?: (v: boolean) => void + ) => { + if (!user) return; + + try { + // 1. Check cache + const { value } = await Preferences.get({ key: `profile_${user.id}` }); + if (value) { + const cachedProfile = JSON.parse(value) as Profile; + setProfile(cachedProfile); + setStatus('loaded'); + history.replace('/home'); + + // Silent refresh + const { data } = await supabase + .from('profiles') + .select('*') + .eq('id', user.id) + .single(); + if (data) { + setProfile(data); + await Preferences.set({ + key: `profile_${user.id}`, + value: JSON.stringify(data), + }); + } else { + // If silent refresh finds no row, they somehow lost their profile (or deleted it) + // We can handle this by redirecting them next time, or immediately + setStatus('missing'); + history.replace('/setup-profile'); + } + return; + } + + // 2. Cache miss, fetch from remote + if (setOverlayVisible) setOverlayVisible(true); + const { data, error } = await supabase + .from('profiles') + .select('*') + .eq('id', user.id) + .single(); + + if (error && error.code !== 'PGRST116') { + // PGRST116 means no rows found + console.error('Error fetching profile:', error); + if (setOverlayError) setOverlayError(true); + return; // Keep overlay visible so they see the error or can retry + } + + if (data) { + // Row found + setProfile(data); + setStatus('loaded'); + await Preferences.set({ + key: `profile_${user.id}`, + value: JSON.stringify(data), + }); + if (setOverlayVisible) setOverlayVisible(false); + history.replace('/home'); + } else { + // No row found + setStatus('missing'); + if (setOverlayVisible) setOverlayVisible(false); + history.replace('/setup-profile'); + } + } catch (err) { + console.error('Unexpected error loading profile:', err); + if (setOverlayError) setOverlayError(true); + } + }; + + return { loadProfileAndNavigate }; +}; diff --git a/src/main.tsx b/src/main.tsx new file mode 100644 index 0000000..dfb03f0 --- /dev/null +++ b/src/main.tsx @@ -0,0 +1,111 @@ +import React from 'react'; +import { createRoot } from 'react-dom/client'; +import { setupIonicReact } from '@ionic/react'; +import { Capacitor } from '@capacitor/core'; +import App from './App'; + +// ── Ionic initialisation ────────────────────────────────────────────────────── +// ?mode=md|ios overrides (used by Appcakes preview); otherwise follow the platform. +const _urlMode = new URLSearchParams(window.location.search).get('mode'); +const _platform = Capacitor.getPlatform(); // 'ios' | 'android' | 'web' +setupIonicReact({ + mode: (_urlMode === 'md' ? 'md' : _urlMode === 'ios' ? 'ios' : _platform === 'android' ? 'md' : 'ios'), +}); + +// Derive the studio parent origin dynamically so this works in both dev +// (parent at localhost:3000) and production (parent at studio.appcakes.dev). +const studioOrigin = (() => { + try { + if (document.referrer) return new URL(document.referrer).origin; + } catch {} + return 'http://localhost:3000'; +})(); + +// ── Safe area bridge ────────────────────────────────────────────────────────── +// Priority: URL params (first load) → sessionStorage (HMR full-reloads) → postMessage. +// Capacitor sets env() natively in compiled apps; these paths cover the browser preview. +function _applyInsets(sat: string | null, sab: string | null) { + if (sat) { document.documentElement.style.setProperty('--ion-safe-area-top', `${sat}px`); sessionStorage.setItem('__apsuite_sat', sat); } + if (sab) { document.documentElement.style.setProperty('--ion-safe-area-bottom', `${sab}px`); sessionStorage.setItem('__apsuite_sab', sab); } +} + +const _sp = new URLSearchParams(window.location.search); +_applyInsets( + _sp.get('sat') ?? sessionStorage.getItem('__apsuite_sat'), + _sp.get('sab') ?? sessionStorage.getItem('__apsuite_sab'), +); + +window.addEventListener('message', (e) => { + if (e.data?.type !== '__apsuite_insets') return; + const { sat, sab } = e.data as { sat?: number; sab?: number }; + _applyInsets(sat != null ? String(sat) : null, sab != null ? String(sab) : null); +}); + +// Re-apply after React Fast Refresh so insets survive soft HMR cycles. +if (import.meta.hot) { + import.meta.hot.on('vite:afterUpdate', () => { + _applyInsets(sessionStorage.getItem('__apsuite_sat'), sessionStorage.getItem('__apsuite_sab')); + }); +} + +// ── Session bridge ──────────────────────────────────────────────────────────── +// Post auth session to the Appcakes parent frame so the AI can test auth-protected +// Edge Functions. Uses import.meta.glob so Vite never errors if supabase.ts is absent. +(async () => { + const mods = import.meta.glob('./supabase.ts', { eager: false }); + if ('./supabase.ts' in mods) { + try { + const { supabase } = await mods['./supabase.ts']() as { supabase: any }; + supabase.auth.onAuthStateChange((_event: unknown, session: any) => { + window.parent.postMessage( + { + type: '__apsuite_session', + access_token: session?.access_token ?? null, + email: session?.user?.email ?? null, + }, + studioOrigin, + ); + }); + } catch { + // supabase client failed to initialise — session bridge unavailable + } + } +})(); + +// ── Runtime error reporting ─────────────────────────────────────────────────── +// Forward uncaught errors to the Appcakes dev server so the AI can read them. +// Extract projectId from the preview URL (/preview/{projectId}/) so errors are +// scoped per-project on the server rather than mixed into a global queue. +const _previewMatch = window.location.pathname.match(/\/preview\/([^/]+)/); +const _projectId = _previewMatch?.[1] ?? null; + +function reportError(message: string, stack?: string) { + fetch(`${studioOrigin}/api/agent/runtime-error`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ message, stack, projectId: _projectId }), + }).catch(() => {}); +} + +window.onerror = (_msg, _src, _line, _col, err) => { + reportError(String(_msg), err?.stack); + return false; +}; + +window.addEventListener('unhandledrejection', (e) => { + const err = e.reason as Error | undefined; + reportError(err?.message ?? String(e.reason), err?.stack); +}); + +// ── PWA Elements (Action Sheet, Camera, Toast etc. in browser preview) ──────── +import { defineCustomElements } from '@ionic/pwa-elements/loader'; +defineCustomElements(window); + +// ── App bootstrap ───────────────────────────────────────────────────────────── +const container = document.getElementById('root'); +const root = createRoot(container!); +root.render( + + + , +); diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx new file mode 100644 index 0000000..0539642 --- /dev/null +++ b/src/pages/Auth.tsx @@ -0,0 +1,576 @@ +import React, { useState, useEffect } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonContent, + IonSpinner, + IonIcon, + useIonViewWillEnter, +} from '@ionic/react'; +import { eyeOutline, eyeOffOutline } from 'ionicons/icons'; +import { supabase } from '../supabase'; +import { useAuth } from '../contexts/AuthContext'; +import { useProfileLoader } from '../hooks/useProfileLoader'; + +const Auth: React.FC = () => { + const history = useHistory(); + const { user } = useAuth(); + const { loadProfileAndNavigate } = useProfileLoader(); + + const [tab, setTab] = useState<'login' | 'register'>('login'); + + const [loginEmail, setLoginEmail] = useState(''); + const [loginPassword, setLoginPassword] = useState(''); + const [showLoginPassword, setShowLoginPassword] = useState(false); + + const [registerEmail, setRegisterEmail] = useState(''); + const [registerPassword, setRegisterPassword] = useState(''); + const [confirmPassword, setConfirmPassword] = useState(''); + const [showRegisterPassword, setShowRegisterPassword] = useState(false); + const [showConfirmPassword, setShowConfirmPassword] = useState(false); + + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + + const [overlayVisible, setOverlayVisible] = useState(false); + const [overlayError, setOverlayError] = useState(false); + + useIonViewWillEnter(() => { + setTab('login'); + }); + + useEffect(() => { + if (user) { + loadProfileAndNavigate(setOverlayVisible, setOverlayError); + } + }, [user, loadProfileAndNavigate]); + + const showError = (msg: string) => { + setError(msg); + setTimeout(() => setError(''), 4000); + }; + + const handleSignIn = async (e: React.FormEvent) => { + e.preventDefault(); + setError(''); + setLoading(true); + + const { error } = await supabase.auth.signInWithPassword({ + email: loginEmail, + password: loginPassword, + }); + + if (error) { + if (error.message.toLowerCase().includes('email not confirmed')) { + await supabase.auth.resend({ type: 'signup', email: loginEmail }); + history.push('/verify-email', { email: loginEmail, resent: true }); + } else { + showError(error.message); + } + setLoading(false); + return; + } + // keep loading true waiting for user effect + }; + + const handleSignUp = async (e: React.FormEvent) => { + e.preventDefault(); + if (registerPassword !== confirmPassword) { + showError('Passwords do not match'); + return; + } + setLoading(true); + setError(''); + + const { error } = await supabase.auth.signUp({ + email: registerEmail, + password: registerPassword, + }); + + if (error) { + showError(error.message); + setLoading(false); + return; + } + + setLoading(false); + history.push('/verify-email', { email: registerEmail }); + }; + + const handleForgotPassword = () => { + history.push('/forgot-password'); + }; + + return ( + + +
+
+
+ QuoteLink +
+
+
+ Instant prices.{' '} + + Smart decisions. + +
+
+ Modern procurement for buyers and suppliers. +
+
+ Send a request, compare real quotes, and move faster with a + clean professional workflow. +
+
+
+ +
+
+
+ {tab === 'login' ? 'Welcome back' : 'Create your account'} +
+
+ {tab === 'login' + ? 'Sign in to manage requests and supplier quotations.' + : 'Join QuoteLink to start sending or responding to RFQs.'} +
+
+ +
+ + +
+ + {error && ( +
+ {error} +
+ )} + + {tab === 'login' ? ( +
+ setLoginEmail(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + /> +
+ setLoginPassword(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 40px 0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + /> + setShowLoginPassword(!showLoginPassword)} + style={{ + position: 'absolute', + right: '14px', + top: '14px', + fontSize: '20px', + color: 'var(--color-text-tertiary)', + cursor: 'pointer', + }} + /> +
+
+ +
+ +
+ ) : ( +
+ setRegisterEmail(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + /> +
+ setRegisterPassword(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 40px 0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + minLength={6} + /> + + setShowRegisterPassword(!showRegisterPassword) + } + style={{ + position: 'absolute', + right: '14px', + top: '14px', + fontSize: '20px', + color: 'var(--color-text-tertiary)', + cursor: 'pointer', + }} + /> +
+
+ setConfirmPassword(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 40px 0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + minLength={6} + /> + setShowConfirmPassword(!showConfirmPassword)} + style={{ + position: 'absolute', + right: '14px', + top: '14px', + fontSize: '20px', + color: 'var(--color-text-tertiary)', + cursor: 'pointer', + }} + /> +
+ +
+ )} +
+
+ + {overlayVisible && ( +
+ {overlayError ? ( +
+ Error loading profile. Please restart the app. +
+ ) : ( + + )} +
+ )} +
+
+ ); +}; + +export default Auth; diff --git a/src/pages/BuyerQuoteList.tsx b/src/pages/BuyerQuoteList.tsx new file mode 100644 index 0000000..0db15c9 --- /dev/null +++ b/src/pages/BuyerQuoteList.tsx @@ -0,0 +1,324 @@ +import React, { useState } from 'react'; +import { useHistory, useParams } from 'react-router-dom'; +import { + IonPage, + IonHeader, + IonToolbar, + IonButtons, + IonButton, + IonIcon, + IonTitle, + IonContent, + IonSpinner, + useIonViewWillEnter, +} from '@ionic/react'; +import { chevronBackOutline, mailOpenOutline } from 'ionicons/icons'; +import { supabase } from '../supabase'; +import QuotationCard from '../components/QuotationCard'; + +const BuyerQuoteList: React.FC = () => { + const history = useHistory(); + const { id } = useParams<{ id: string }>(); + + const [rfqSummary, setRfqSummary] = useState<{ + title: string; + referenceNumber: string; + } | null>(null); + const [quotes, setQuotes] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(''); + const [sortMode, setSortMode] = useState<'price' | 'supplier'>('price'); + + useIonViewWillEnter(() => { + loadQuotes(); + }); + + const loadQuotes = async () => { + setLoading(true); + setError(''); + try { + const { data: rfq, error: rfqErr } = await supabase + .from('rfqs') + .select('title, reference_number') + .eq('id', id) + .single(); + if (rfqErr) throw rfqErr; + setRfqSummary({ + title: rfq.title, + referenceNumber: rfq.reference_number, + }); + + const { data: qData, error: qErr } = await supabase + .from('quotations') + .select( + 'id, price_amount, delivery_option, status, supplier_id, profiles(full_name, company_name)' + ) + .eq('rfq_id', id); + if (qErr) throw qErr; + + const mapped = (qData || []).map((q) => ({ + id: q.id, + priceAmount: q.price_amount, + deliveryOption: q.delivery_option, + status: q.status, + supplierName: + q.profiles?.company_name || q.profiles?.full_name || 'Supplier', + })); + + setQuotes(mapped); + } catch (err: any) { + console.error(err); + setError('Failed to load quotations.'); + } finally { + setLoading(false); + } + }; + + const getSortedQuotes = () => { + if (sortMode === 'price') { + return [...quotes].sort((a, b) => a.priceAmount - b.priceAmount); + } else { + return [...quotes].sort((a, b) => + a.supplierName.localeCompare(b.supplierName) + ); + } + }; + + const handleAcceptQuote = async (quoteId: string) => { + try { + setLoading(true); + + // Update selected quotation to accepted + const { error: accErr } = await supabase + .from('quotations') + .update({ status: 'accepted', updated_at: new Date().toISOString() }) + .eq('id', quoteId); + if (accErr) throw accErr; + + // Update sibling quotations to declined + const { error: decErr } = await supabase + .from('quotations') + .update({ status: 'declined', updated_at: new Date().toISOString() }) + .eq('rfq_id', id) + .neq('id', quoteId); + if (decErr) throw decErr; + + // Close RFQ + const { error: rfqErr } = await supabase + .from('rfqs') + .update({ status: 'closed', updated_at: new Date().toISOString() }) + .eq('id', id); + if (rfqErr) throw rfqErr; + + await loadQuotes(); + } catch (err: any) { + console.error(err); + setError(err.message || 'Failed to accept quote.'); + setLoading(false); + setTimeout(() => setError(''), 4000); + } + }; + + const handleDeclineQuote = async (quoteId: string) => { + try { + setLoading(true); + const { error } = await supabase + .from('quotations') + .update({ status: 'declined', updated_at: new Date().toISOString() }) + .eq('id', quoteId); + if (error) throw error; + + await loadQuotes(); + } catch (err: any) { + console.error(err); + setError(err.message || 'Failed to decline quote.'); + setLoading(false); + setTimeout(() => setError(''), 4000); + } + }; + + const sortedQuotes = getSortedQuotes(); + + return ( + + + + + history.goBack()} + style={{ color: '#14532d' }} + > + + + + + Compare Quotes + + + + + + {loading && quotes.length === 0 ? ( +
+ +
+ ) : ( + <> + {rfqSummary && ( +
+
+ {rfqSummary.referenceNumber} +
+
+ {rfqSummary.title} +
+
+ )} + + {error && ( +
+ {error} +
+ )} + +
+ + +
+ + {sortedQuotes.length > 0 ? ( +
+ {sortedQuotes.map((q) => ( + handleAcceptQuote(q.id)} + onDecline={() => handleDeclineQuote(q.id)} + /> + ))} +
+ ) : ( +
+ +
+ No quotations available yet. +
+
+ )} + + )} +
+
+ ); +}; + +export default BuyerQuoteList; diff --git a/src/pages/BuyerRequests.tsx b/src/pages/BuyerRequests.tsx new file mode 100644 index 0000000..a814940 --- /dev/null +++ b/src/pages/BuyerRequests.tsx @@ -0,0 +1,343 @@ +import React, { useState } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonContent, + IonSpinner, + useIonViewWillEnter, + IonIcon, +} from '@ionic/react'; +import { + addOutline, + searchOutline, + optionsOutline, + documentTextOutline, +} from 'ionicons/icons'; +import { supabase } from '../supabase'; +import { useProfile } from '../contexts/ProfileContext'; +import { useAuth } from '../contexts/AuthContext'; +import RequestListCard from '../components/RequestListCard'; + +interface RFQListItem { + id: string; + title: string; + referenceNumber: string; + status: string; + createdAt: string; +} + +const BuyerRequests: React.FC = () => { + const history = useHistory(); + const { user } = useAuth(); + const { profile } = useProfile(); + + const [items, setItems] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(''); + + const [searchText, setSearchText] = useState(''); + const [activeStatus, setActiveStatus] = useState< + 'all' | 'open' | 'quoted' | 'closed' + >('all'); + + useIonViewWillEnter(() => { + loadRequests(); + }); + + const loadRequests = async () => { + if (!user || !profile) return; + setLoading(true); + setError(''); + + try { + if (profile.role === 'buyer') { + const { data, error: err } = await supabase + .from('rfqs') + .select('*') + .eq('buyer_id', user.id) + .order('created_at', { ascending: false }); + if (err) throw err; + setItems( + data.map((d) => ({ + id: d.id, + title: d.title, + referenceNumber: d.reference_number, + status: d.status, + createdAt: d.created_at, + })) + ); + } else { + const { data, error: err } = await supabase + .from('rfq_recipients') + .select('id, rfqs!inner(*)') + .eq('supplier_id', user.id) + .order('created_at', { ascending: false }); + if (err) throw err; + const mapped = (data || []).map((row: any) => ({ + id: row.rfqs.id, + title: row.rfqs.title, + referenceNumber: row.rfqs.reference_number, + status: row.rfqs.status, + createdAt: row.rfqs.created_at, + })); + setItems(mapped); + } + } catch (err: any) { + console.error(err); + setError('Failed to load requests.'); + } finally { + setLoading(false); + } + }; + + const filteredItems = items.filter((item) => { + const matchStatus = activeStatus === 'all' || item.status === activeStatus; + const searchLower = searchText.toLowerCase(); + const matchSearch = + item.title.toLowerCase().includes(searchLower) || + item.referenceNumber.toLowerCase().includes(searchLower); + return matchStatus && matchSearch; + }); + + const handleResetFilters = () => { + setSearchText(''); + setActiveStatus('all'); + }; + + if (!profile) return null; + + return ( + + +
+
+
+ {profile.role === 'buyer' ? 'Buyer Workspace' : 'Supplier Inbox'} +
+
+ {profile.role === 'buyer' ? 'My Requests' : 'Assigned RFQs'} +
+
+ {profile.role === 'buyer' && ( +
history.push('/rfq/new')} + style={{ + width: '40px', + height: '40px', + borderRadius: '12px', + background: 'var(--color-brand)', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + cursor: 'pointer', + flexShrink: 0, + }} + > + +
+ )} +
+ + {error && ( +
+ {error} +
+ )} + +
+
+ + setSearchText(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + borderRadius: '24px', + border: 'none', + padding: '0 16px 0 40px', + height: '44px', + width: '100%', + fontSize: '14px', + color: 'var(--color-text-primary)', + }} + /> +
+ +
+ +
+ {(['all', 'open', 'quoted', 'closed'] as const).map((status) => ( + + ))} +
+ + {loading ? ( +
+ +
+ ) : filteredItems.length > 0 ? ( +
+ {filteredItems.map((item) => ( + history.push(`/rfq/${item.id}`)} + /> + ))} +
+ ) : ( +
+ +
+ No requests found. +
+
+ )} +
+
+ ); +}; + +export default BuyerRequests; diff --git a/src/pages/EditProfile.tsx b/src/pages/EditProfile.tsx new file mode 100644 index 0000000..b334c03 --- /dev/null +++ b/src/pages/EditProfile.tsx @@ -0,0 +1,309 @@ +import React, { useState, useEffect } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonHeader, + IonToolbar, + IonButtons, + IonButton, + IonIcon, + IonTitle, + IonContent, + IonSpinner, +} from '@ionic/react'; +import { chevronBackOutline } from 'ionicons/icons'; +import { supabase } from '../supabase'; +import { useAuth } from '../contexts/AuthContext'; +import { useProfile } from '../contexts/ProfileContext'; +import { Preferences } from '@capacitor/preferences'; + +const EditProfile: React.FC = () => { + const history = useHistory(); + const { user } = useAuth(); + const { profile, setProfile } = useProfile(); + + const [fullName, setFullName] = useState(''); + const [companyName, setCompanyName] = useState(''); + const [phone, setPhone] = useState(''); + const [city, setCity] = useState(''); + const [saving, setSaving] = useState(false); + const [error, setError] = useState(''); + + useEffect(() => { + if (profile) { + setFullName(profile.full_name || ''); + setCompanyName(profile.company_name || ''); + setPhone(profile.phone || ''); + setCity(profile.city || ''); + } + }, [profile]); + + const showError = (msg: string) => { + setError(msg); + setTimeout(() => setError(''), 4000); + }; + + const handleSaveProfile = async (e: React.FormEvent) => { + e.preventDefault(); + if (!user || !profile) return; + if (!fullName) { + showError('Please enter your full name'); + return; + } + + setSaving(true); + setError(''); + + const updates = { + full_name: fullName, + company_name: companyName || null, + phone: phone || null, + city: city || null, + updated_at: new Date().toISOString(), + }; + + const { error: updateError } = await supabase + .from('profiles') + .update(updates) + .eq('id', user.id); + + if (updateError) { + showError(updateError.message); + setSaving(false); + return; + } + + const updatedProfile = { ...profile, ...updates }; + setProfile(updatedProfile); + await Preferences.set({ + key: `profile_${user.id}`, + value: JSON.stringify(updatedProfile), + }); + + setSaving(false); + history.goBack(); + }; + + return ( + + + + + history.goBack()} + style={{ color: 'var(--color-brand-strong)' }} + > + + + + + Edit Profile + + + + + +
+ {error && ( +
+ {error} +
+ )} + +
+
+ + setFullName(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + required + /> +
+ +
+ + setCompanyName(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + /> +
+ +
+ + setCity(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + /> +
+ +
+ + setPhone(e.target.value)} + style={{ + background: 'var(--color-surface-raised)', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: 'var(--color-text-primary)', + width: '100%', + }} + /> +
+ + +
+
+
+
+ ); +}; + +export default EditProfile; diff --git a/src/pages/ForgotPassword.tsx b/src/pages/ForgotPassword.tsx new file mode 100644 index 0000000..214c78a --- /dev/null +++ b/src/pages/ForgotPassword.tsx @@ -0,0 +1,177 @@ +import React, { useState } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonHeader, + IonToolbar, + IonButtons, + IonButton, + IonIcon, + IonTitle, + IonContent, + IonSpinner, +} from '@ionic/react'; +import { chevronBackOutline } from 'ionicons/icons'; +import { supabase } from '../supabase'; + +const ForgotPassword: React.FC = () => { + const history = useHistory(); + const [email, setEmail] = useState(''); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + + const showError = (msg: string) => { + setError(msg); + setTimeout(() => setError(''), 4000); + }; + + const handleRequestReset = async (e: React.FormEvent) => { + e.preventDefault(); + setLoading(true); + setError(''); + + const { error } = await supabase.auth.resetPasswordForEmail(email); + + if (error) { + showError(error.message); + setLoading(false); + return; + } + + history.push('/verify-reset', { email }); + setLoading(false); + }; + + return ( + + + + + history.goBack()} + style={{ color: '#14532d' }} + > + + + + + Reset Password + + + + + +
+
+

+ Forgot password? +

+

+ Enter your email address and we'll send you a 6-digit code to + reset your password. +

+
+ + {error && ( +
+ {error} +
+ )} + +
+ setEmail(e.target.value)} + style={{ + background: '#f4f7f4', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: '#0f1720', + width: '100%', + }} + required + /> + +
+
+
+
+ ); +}; + +export default ForgotPassword; diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx new file mode 100644 index 0000000..e16cde2 --- /dev/null +++ b/src/pages/Home.tsx @@ -0,0 +1,470 @@ +import React, { useState } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonContent, + IonSpinner, + useIonViewWillEnter, + IonIcon, +} from '@ionic/react'; +import { documentTextOutline, addOutline, searchOutline } from 'ionicons/icons'; +import { supabase } from '../supabase'; +import { useProfile } from '../contexts/ProfileContext'; +import { useAuth } from '../contexts/AuthContext'; +import DashboardMetricCard from '../components/DashboardMetricCard'; +import RecentActivityCard from '../components/RecentActivityCard'; +import { Database } from '../database.types'; + +type RfqRow = Database['public']['Tables']['rfqs']['Row']; + +const Home: React.FC = () => { + const history = useHistory(); + const { user } = useAuth(); + const { profile } = useProfile(); + + const [loading, setLoading] = useState(true); + const [error, setError] = useState(''); + + const [rfqSummary, setRfqSummary] = useState({ + open: 0, + quoted: 0, + closed: 0, + }); + const [supplierSummary, setSupplierSummary] = useState({ + assignedOpen: 0, + myQuotes: 0, + accepted: 0, + }); + const [recentItems, setRecentItems] = useState([]); + + useIonViewWillEnter(() => { + loadDashboardData(); + }); + + const loadDashboardData = async () => { + if (!user || !profile) return; + setLoading(true); + setError(''); + + try { + if (profile.role === 'buyer') { + // Aggregate counts + const { data: allRfqs, error: countErr } = await supabase + .from('rfqs') + .select('id, status') + .eq('buyer_id', user.id); + + if (countErr) throw countErr; + + let open = 0, + quoted = 0, + closed = 0; + allRfqs?.forEach((r) => { + if (r.status === 'open') open++; + else if (r.status === 'quoted') quoted++; + else if (r.status === 'closed') closed++; + }); + setRfqSummary({ open, quoted, closed }); + + // Recent items + const { data: recent, error: recentErr } = await supabase + .from('rfqs') + .select('*') + .eq('buyer_id', user.id) + .order('created_at', { ascending: false }) + .limit(5); + if (recentErr) throw recentErr; + setRecentItems(recent || []); + } else { + // Supplier + const { data: allRecipients, error: recErr } = await supabase + .from('rfq_recipients') + .select('id, rfqs!inner(id, status)') + .eq('supplier_id', user.id); + if (recErr) throw recErr; + + let assignedOpen = 0; + allRecipients?.forEach((r: any) => { + if (r.rfqs && r.rfqs.status === 'open') assignedOpen++; + }); + + const { data: myQuotes, error: qErr } = await supabase + .from('quotations') + .select('id, status') + .eq('supplier_id', user.id); + if (qErr) throw qErr; + + let accepted = 0; + myQuotes?.forEach((q) => { + if (q.status === 'accepted') accepted++; + }); + setSupplierSummary({ + assignedOpen, + myQuotes: myQuotes?.length || 0, + accepted, + }); + + const { data: recent, error: recentErr } = await supabase + .from('rfq_recipients') + .select('id, rfqs!inner(*)') + .eq('supplier_id', user.id) + .order('created_at', { ascending: false }) + .limit(5); + if (recentErr) throw recentErr; + + // Map joined data + const mapped = (recent || []).map((r: any) => r.rfqs); + setRecentItems(mapped); + } + } catch (err: any) { + console.error(err); + setError('Failed to load dashboard data.'); + } finally { + setLoading(false); + } + }; + + const handlePrimaryAction = () => { + if (profile?.role === 'buyer') { + history.push('/rfq/new'); + } else { + history.push('/requests'); + } + }; + + const handleRecentItemTap = (item: RfqRow) => { + history.push(`/rfq/${item.id}`); + }; + + if (!profile) return null; + + return ( + + +
+
+
+ QuoteLink +
+
+ Procurement made simpler +
+
+
history.push('/profile')} + style={{ + width: '40px', + height: '40px', + borderRadius: '999px', + background: 'var(--color-brand-medium)', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + cursor: 'pointer', + color: 'var(--color-brand)', + fontSize: '16px', + fontWeight: '700', + textTransform: 'uppercase', + flexShrink: 0, + }} + > + {profile.full_name.charAt(0)} +
+
+ +
+
+ Good to see you,{' '} + + {profile.full_name.split(' ')[0]} + +
+
+ {profile.role === 'buyer' + ? 'Track requests, review supplier pricing, and keep decisions moving.' + : 'Review assigned RFQs, send pricing fast, and stay on top of wins.'} +
+
+ + {error && ( +
+ {error} +
+ )} + +
+
+
+ + {profile.role === 'buyer' ? 'Active Requests' : 'Assigned RFQs'} + + + {profile.role === 'buyer' + ? rfqSummary.open + rfqSummary.quoted + : supplierSummary.assignedOpen} + +
+
+ +
+
+
+ {profile.role === 'buyer' + ? 'Create new request →' + : 'Browse requests →'} +
+
+ +
+ {profile.role === 'buyer' ? ( + <> + + + + ) : ( + <> + + + + )} +
+ +
+
+ Recent Activity +
+
history.push('/requests')} + style={{ + fontSize: '13px', + fontWeight: '600', + color: 'var(--color-brand)', + cursor: 'pointer', + }} + > + See all +
+
+ + {loading ? ( +
+ +
+ ) : recentItems.length > 0 ? ( + recentItems.map((item) => ( + handleRecentItemTap(item)} + /> + )) + ) : ( +
+ +
+ No recent activity yet. +
+ {profile.role === 'buyer' && ( + + )} +
+ )} +
+
+ ); +}; + +export default Home; diff --git a/src/pages/NewRfq.tsx b/src/pages/NewRfq.tsx new file mode 100644 index 0000000..a0bb1dd --- /dev/null +++ b/src/pages/NewRfq.tsx @@ -0,0 +1,491 @@ +import React, { useState, useEffect } from 'react'; +import { useHistory } from 'react-router-dom'; +import { + IonPage, + IonHeader, + IonToolbar, + IonButtons, + IonButton, + IonIcon, + IonTitle, + IonContent, + IonSpinner, +} from '@ionic/react'; +import { chevronBackOutline, cameraOutline, closeCircle } from 'ionicons/icons'; +import { supabase } from '../supabase'; +import { useAuth } from '../contexts/AuthContext'; +import SupplierPickerRow, { + SupplierOption, +} from '../components/SupplierPickerRow'; + +const NewRfq: React.FC = () => { + const history = useHistory(); + const { user } = useAuth(); + + const [title, setTitle] = useState(''); + const [requestText, setRequestText] = useState(''); + + const [supplierOptions, setSupplierOptions] = useState([]); + const [selectedSupplierIds, setSelectedSupplierIds] = useState([]); + const [loadingSuppliers, setLoadingSuppliers] = useState(true); + + const [imageFile, setImageFile] = useState(null); + const [imagePreviewUrl, setImagePreviewUrl] = useState(null); + + const [loading, setLoading] = useState(false); + const [error, setError] = useState(''); + + useEffect(() => { + loadSuppliers(); + return () => { + cleanupPreview(); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + const loadSuppliers = async () => { + setLoadingSuppliers(true); + const { data, error: err } = await supabase + .from('profiles') + .select('id, full_name, company_name, city') + .eq('role', 'supplier') + .order('company_name', { ascending: true }) + .order('full_name', { ascending: true }); + + if (!err && data) { + setSupplierOptions(data); + } + setLoadingSuppliers(false); + }; + + const cleanupPreview = () => { + if (imagePreviewUrl) { + URL.revokeObjectURL(imagePreviewUrl); + } + }; + + const handleFileChange = (e: React.ChangeEvent) => { + if (e.target.files && e.target.files.length > 0) { + const file = e.target.files[0]; + setImageFile(file); + cleanupPreview(); + setImagePreviewUrl(URL.createObjectURL(file)); + } + }; + + const toggleSupplier = (id: string) => { + if (selectedSupplierIds.includes(id)) { + setSelectedSupplierIds(selectedSupplierIds.filter((s) => s !== id)); + } else { + if (selectedSupplierIds.length >= 5) { + showError('Select up to 5 suppliers'); + } else { + setSelectedSupplierIds([...selectedSupplierIds, id]); + } + } + }; + + const showError = (msg: string) => { + setError(msg); + setTimeout(() => setError(''), 4000); + }; + + const handleCreateRfq = async (e: React.FormEvent) => { + e.preventDefault(); + if (!user) return; + if (!requestText.trim()) { + showError('Please describe your request.'); + return; + } + if (selectedSupplierIds.length === 0) { + showError('Please select at least 1 supplier.'); + return; + } + + setLoading(true); + setError(''); + + try { + // 1. Get Reference Number + const { data: refData, error: refError } = + await supabase.functions.invoke('create-rfq-reference', { + body: {}, + }); + if (refError || !refData?.referenceNumber) { + throw new Error('Failed to generate reference number.'); + } + + const referenceNumber = refData.referenceNumber; + const derivedTitle = + title.trim() || requestText.trim().substring(0, 30) + '...'; + + // 2. Insert RFQ + const { data: rfq, error: rfqError } = await supabase + .from('rfqs') + .insert({ + buyer_id: user.id, + reference_number: referenceNumber, + title: derivedTitle, + request_text: requestText.trim(), + status: 'open', + }) + .select('id') + .single(); + + if (rfqError) throw rfqError; + + // 3. Upload Image if present + if (imageFile) { + const filePath = `${user.id}/${rfq.id}/${Date.now()}-${imageFile.name}`; + const { error: uploadError } = await supabase.storage + .from('rfq-images') + .upload(filePath, imageFile); + + if (uploadError) throw uploadError; + + const { error: imgMetaError } = await supabase + .from('rfq_images') + .insert({ + rfq_id: rfq.id, + owner_id: user.id, + storage_path: filePath, + }); + + if (imgMetaError) throw imgMetaError; + } + + // 4. Insert Recipients + const recipientsToInsert = selectedSupplierIds.map((sid) => ({ + rfq_id: rfq.id, + supplier_id: sid, + })); + const { error: recError } = await supabase + .from('rfq_recipients') + .insert(recipientsToInsert); + + if (recError) throw recError; + + // 5. Navigate + history.replace(`/rfq/${rfq.id}`); + } catch (err: any) { + console.error(err); + showError(err.message || 'Failed to create RFQ.'); + } finally { + setLoading(false); + } + }; + + return ( + + + + + history.goBack()} + style={{ color: '#14532d' }} + > + + + + + New Request + + + + + +
+

+ Request Quote +

+

+ Describe what you need and select suppliers. +

+
+ + {error && ( +
+ {error} +
+ )} + +
+
+ setTitle(e.target.value)} + style={{ + background: '#f4f7f4', + border: 'none', + borderRadius: '12px', + padding: '0 14px', + height: '48px', + fontSize: '15px', + fontWeight: '400', + color: '#0f1720', + width: '100%', + }} + /> +