feat(crowd): add automated historical webcam collection and dataset integration

This commit is contained in:
dasemu committed 2026-03-13 10:41:57 +01:00
1 parent e952cea417
commit b4c6041eea
91 files changed
+7957 -40

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+101
View File
@@ -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
+2
View File
@@ -0,0 +1,2 @@
/build/*
!/build/.npmkeep
+54
View File
@@ -0,0 +1,54 @@
apply plugin: 'com.android.application'
android {
namespace = "es.dariosevilla.skipredictor"
compileSdk = rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "es.dariosevilla.skipredictor"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
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")
}
+21
View File
@@ -0,0 +1,21 @@
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
}
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
implementation project(':capacitor-app')
implementation project(':capacitor-local-notifications')
implementation project(':capacitor-preferences')
}
if (hasProperty('postBuildExtras')) {
postBuildExtras()
}
+21
View File
@@ -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
@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation|density"
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:theme="@style/AppTheme.NoActionBarLaunch"
android:launchMode="singleTask"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"></meta-data>
</provider>
</application>
<!-- Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
@@ -0,0 +1,5 @@
package es.dariosevilla.skipredictor;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8" />
</vector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">Ski Predictor</string>
<string name="title_activity_main">Ski Predictor</string>
<string name="package_name">es.dariosevilla.skipredictor</string>
<string name="custom_url_scheme">es.dariosevilla.skipredictor</string>
</resources>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:background">@null</item>
</style>
<style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
<item name="android:background">@drawable/splash</item>
</style>
</resources>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="." />
<cache-path name="my_cache_images" path="." />
</paths>
@@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
+29
View File
@@ -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
}
+12
View File
@@ -0,0 +1,12 @@
// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')
include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')
include ':capacitor-local-notifications'
project(':capacitor-local-notifications').projectDir = new File('../node_modules/@capacitor/local-notifications/android')
include ':capacitor-preferences'
project(':capacitor-preferences').projectDir = new File('../node_modules/@capacitor/preferences/android')
+22
View File
@@ -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
Binary file not shown.
@@ -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
Vendored Executable
+251
View File
@@ -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" "$@"
+94
View File
@@ -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
+5
View File
@@ -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'
+16
View File
@@ -0,0 +1,16 @@
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'
}
+13
View File
@@ -0,0 +1,13 @@
import type { CapacitorConfig } from '@capacitor/cli'
const config: CapacitorConfig = {
appId: 'es.dariosevilla.skipredictor',
appName: 'Ski Predictor',
webDir: 'dist',
server: {
androidScheme: 'https',
cleartext: true,
},
}
export default config
+23
View File
@@ -0,0 +1,23 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0, viewport-fit=cover" name="viewport" />
<meta content="#173038" name="theme-color" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<title>Ski Predictor</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+3967
View File
File diff suppressed because it is too large. Load diff
+39
View File
@@ -0,0 +1,39 @@
{
"name": "skipredictor-mobile",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview",
"cap:sync": "npm run build && npx cap sync",
"cap:android": "npm run build && npx cap sync android && npx cap open android"
},
"dependencies": {
"@capacitor/android": "^8.2.0",
"@capacitor/app": "^8.0.1",
"@capacitor/cli": "^8.2.0",
"@capacitor/core": "^8.2.0",
"@capacitor/local-notifications": "^8.0.2",
"@capacitor/preferences": "^8.0.1",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-router-dom": "^7.13.1"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@types/node": "^24.12.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.0",
"eslint": "^9.39.4",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
"typescript": "~5.9.3",
"typescript-eslint": "^8.56.1",
"vite": "^8.0.0"
}
}
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="46" fill="none" viewBox="0 0 48 46"><path fill="#863bff" d="M25.946 44.938c-.664.845-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.287c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.497 0-3.578-1.842-3.578H1.237c-.92 0-1.456-1.04-.92-1.788L10.013.474c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.579 1.842 3.579h11.377c.943 0 1.473 1.088.89 1.83L25.947 44.94z" style="fill:#863bff;fill:color(display-p3 .5252 .23 1);fill-opacity:1"/><mask id="a" width="48" height="46" x="0" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M25.842 44.938c-.664.844-2.021.375-2.021-.698V33.937a2.26 2.26 0 0 0-2.262-2.262H10.183c-.92 0-1.456-1.04-.92-1.788l7.48-10.471c1.07-1.498 0-3.579-1.842-3.579H1.133c-.92 0-1.456-1.04-.92-1.787L9.91.473c.214-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.471c-1.07 1.498 0 3.578 1.842 3.578h11.377c.943 0 1.473 1.088.89 1.832L25.843 44.94z" style="fill:#000;fill-opacity:1"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#ede6ff" rx="5.508" ry="14.704" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -4.47 31.516)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#ede6ff" rx="10.399" ry="29.851" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -39.328 7.883)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#7e14ff" rx="5.508" ry="30.487" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -25.913 -14.639)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.814 -32.644 -3.334)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#7e14ff" rx="5.508" ry="30.599" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="matrix(.00324 1 1 -.00324 -34.34 30.47)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#ede6ff" rx="14.072" ry="22.078" style="fill:#ede6ff;fill:color(display-p3 .9275 .9033 1);fill-opacity:1" transform="rotate(93.35 24.506 48.493)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#7e14ff" rx="3.47" ry="21.501" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(89.009 28.708 47.59)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx=".387" cy="8.972" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(39.51 .387 8.972)"/></g><g filter="url(#k)"><ellipse cx="47.523" cy="-6.092" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 47.523 -6.092)"/></g><g filter="url(#l)"><ellipse cx="41.412" cy="6.333" fill="#47bfff" rx="5.971" ry="9.665" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 41.412 6.333)"/></g><g filter="url(#m)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#n)"><ellipse cx="-1.879" cy="38.332" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 -1.88 38.332)"/></g><g filter="url(#o)"><ellipse cx="35.651" cy="29.907" fill="#7e14ff" rx="4.407" ry="29.108" style="fill:#7e14ff;fill:color(display-p3 .4922 .0767 1);fill-opacity:1" transform="rotate(37.892 35.651 29.907)"/></g><g filter="url(#p)"><ellipse cx="38.418" cy="32.4" fill="#47bfff" rx="5.971" ry="15.297" style="fill:#47bfff;fill:color(display-p3 .2799 .748 1);fill-opacity:1" transform="rotate(37.892 38.418 32.4)"/></g></g><defs><filter id="b" width="60.045" height="41.654" x="-19.77" y="16.149" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-54.613" y="-7.533" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17158" stdDeviation="7.659"/></filtLine truncated

After

Width:  |  Height:  |  Size: 9.3 KiB

+24
View File
@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="bluesky-icon" viewBox="0 0 16 17">
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
</symbol>
<symbol id="discord-icon" viewBox="0 0 20 19">
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
</symbol>
<symbol id="documentation-icon" viewBox="0 0 21 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
</symbol>
<symbol id="github-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
</symbol>
<symbol id="social-icon" viewBox="0 0 20 20">
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
</symbol>
<symbol id="x-icon" viewBox="0 0 19 19">
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
</symbol>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+49
View File
@@ -0,0 +1,49 @@
import { HashRouter, Navigate, Route, Routes } from 'react-router-dom'
import { AppProvider } from './app/AppContext'
import { useAppContext } from './app/useAppContext'
import { AppShell } from './components/AppShell'
import { SplashScreen } from './components/StateViews'
import { AuthPage } from './pages/AuthPage'
import { PredictionsPage } from './pages/PredictionsPage'
import { SettingsPage } from './pages/SettingsPage'
import { StationPage } from './pages/StationPage'
import { StationsPage } from './pages/StationsPage'
function AppRoutes() {
const { isAuthenticated, isBooting } = useAppContext()
if (isBooting) {
return <SplashScreen />
}
if (!isAuthenticated) {
return <AuthPage />
}
return (
<HashRouter>
<Routes>
<Route element={<AppShell />}>
<Route index element={<Navigate to="/stations" replace />} />
<Route path="/stations" element={<StationsPage />} />
<Route path="/stations/:stationId" element={<StationPage />} />
<Route path="/predictions" element={<PredictionsPage />} />
<Route path="/predictions/:date" element={<PredictionsPage />} />
<Route path="/settings" element={<SettingsPage />} />
<Route path="*" element={<Navigate to="/stations" replace />} />
</Route>
</Routes>
</HashRouter>
)
}
function App() {
return (
<AppProvider>
<AppRoutes />
</AppProvider>
)
}
export default App
+258
View File
@@ -0,0 +1,258 @@
import type { PropsWithChildren } from 'react'
import {
startTransition,
useCallback,
useEffect,
useState,
} from 'react'
import { App } from '@capacitor/app'
import {
fetchForecastAll,
fetchStations,
getDefaultApiBaseUrl,
loginUser,
normalizeBaseUrl,
registerUser,
ApiError,
} from '../lib/api'
import { syncPredictionAlerts } from '../lib/alerts'
import {
clearSession,
loadPreferences,
loadSession,
savePreferences,
saveSession,
} from '../lib/storage'
import type {
AlertSettings,
AppPreferences,
ForecastAllResponse,
Session,
StationInfo,
} from '../types'
import { DEFAULT_ALERT_SETTINGS } from '../types'
import { AppContext, type AppContextValue } from './appContextValue'
const defaultPreferences: AppPreferences = {
apiBaseUrl: getDefaultApiBaseUrl(),
alertSettings: DEFAULT_ALERT_SETTINGS,
}
function getErrorMessage(error: unknown): string {
if (error instanceof ApiError) {
return error.message
}
if (error instanceof Error) {
return error.message
}
return 'Se ha producido un error inesperado.'
}
export function AppProvider({ children }: PropsWithChildren) {
const [isBooting, setIsBooting] = useState(true)
const [session, setSession] = useState<Session | null>(null)
const [preferences, setPreferences] = useState<AppPreferences>(defaultPreferences)
const [stations, setStations] = useState<StationInfo[]>([])
const [forecastAll, setForecastAll] = useState<ForecastAllResponse | null>(null)
const [isRefreshing, setIsRefreshing] = useState(false)
const [dataError, setDataError] = useState<string | null>(null)
const apiBaseUrl = preferences.apiBaseUrl || getDefaultApiBaseUrl()
useEffect(() => {
let active = true
void Promise.all([loadSession(), loadPreferences()]).then(
([savedSession, savedPreferences]) => {
if (!active) {
return
}
startTransition(() => {
setSession(savedSession)
setPreferences(savedPreferences ?? defaultPreferences)
setIsBooting(false)
})
},
)
return () => {
active = false
}
}, [])
const refreshData = useCallback(async () => {
if (!session) {
return
}
setIsRefreshing(true)
try {
const [stationsResponse, nextForecastAll] = await Promise.all([
fetchStations(apiBaseUrl, session.token),
fetchForecastAll(apiBaseUrl, session.token),
])
startTransition(() => {
setStations(stationsResponse.stations)
setForecastAll(nextForecastAll)
setDataError(null)
})
await syncPredictionAlerts(preferences.alertSettings, nextForecastAll, false)
} catch (error) {
if (error instanceof ApiError && error.status === 401) {
await clearSession()
startTransition(() => {
setSession(null)
setStations([])
setForecastAll(null)
setDataError('La sesión ha caducado. Vuelve a iniciar sesión.')
})
} else {
startTransition(() => {
setDataError(getErrorMessage(error))
})
}
} finally {
setIsRefreshing(false)
}
}, [apiBaseUrl, preferences.alertSettings, session])
useEffect(() => {
if (!session) {
startTransition(() => {
setStations([])
setForecastAll(null)
})
return
}
void refreshData()
}, [refreshData, session])
useEffect(() => {
if (!session) {
return
}
let removed = false
let listener: { remove: () => Promise<void> } | undefined
void App.addListener('appStateChange', ({ isActive }) => {
if (isActive) {
void refreshData()
}
}).then((handle) => {
if (removed) {
void handle.remove()
return
}
listener = handle
})
return () => {
removed = true
if (listener) {
void listener.remove()
}
}
}, [refreshData, session])
async function persistPreferences(nextPreferences: AppPreferences) {
startTransition(() => {
setPreferences(nextPreferences)
})
await savePreferences(nextPreferences)
}
async function saveApiBaseUrl(baseUrl: string) {
const nextPreferences: AppPreferences = {
...preferences,
apiBaseUrl: normalizeBaseUrl(baseUrl) || getDefaultApiBaseUrl(),
}
await persistPreferences(nextPreferences)
}
async function login(email: string, password: string, baseUrl?: string) {
const nextBaseUrl =
normalizeBaseUrl(baseUrl ?? apiBaseUrl) || getDefaultApiBaseUrl()
const token = await loginUser(nextBaseUrl, email, password)
const nextSession: Session = {
email,
token: token.access_token,
}
const nextPreferences: AppPreferences = {
...preferences,
apiBaseUrl: nextBaseUrl,
}
await Promise.all([saveSession(nextSession), savePreferences(nextPreferences)])
startTransition(() => {
setSession(nextSession)
setPreferences(nextPreferences)
setDataError(null)
})
}
async function register(email: string, password: string, baseUrl?: string) {
const nextBaseUrl =
normalizeBaseUrl(baseUrl ?? apiBaseUrl) || getDefaultApiBaseUrl()
await registerUser(nextBaseUrl, email, password)
await login(email, password, nextBaseUrl)
}
async function logout() {
await clearSession()
startTransition(() => {
setSession(null)
setStations([])
setForecastAll(null)
setDataError(null)
})
}
async function saveAlertSettings(settings: AlertSettings) {
const nextPreferences: AppPreferences = {
...preferences,
alertSettings: {
...settings,
specificDates: [...settings.specificDates].sort(),
},
}
await persistPreferences(nextPreferences)
return syncPredictionAlerts(
nextPreferences.alertSettings,
forecastAll,
true,
)
}
const value: AppContextValue = {
apiBaseUrl,
alertSettings: preferences.alertSettings,
dataError,
forecastAll,
isAuthenticated: session !== null,
isBooting,
isRefreshing,
refreshData,
saveAlertSettings,
saveApiBaseUrl,
session,
stations,
login,
logout,
register,
}
return <AppContext.Provider value={value}>{children}</AppContext.Provider>
}
+29
View File
@@ -0,0 +1,29 @@
import { createContext } from 'react'
import type {
AlertSettings,
AlertSyncResult,
ForecastAllResponse,
Session,
StationInfo,
} from '../types'
export interface AppContextValue {
apiBaseUrl: string
alertSettings: AlertSettings
dataError: string | null
forecastAll: ForecastAllResponse | null
isAuthenticated: boolean
isBooting: boolean
isRefreshing: boolean
refreshData: () => Promise<void>
saveAlertSettings: (settings: AlertSettings) => Promise<AlertSyncResult>
saveApiBaseUrl: (baseUrl: string) => Promise<void>
session: Session | null
stations: StationInfo[]
login: (email: string, password: string, baseUrl?: string) => Promise<void>
logout: () => Promise<void>
register: (email: string, password: string, baseUrl?: string) => Promise<void>
}
export const AppContext = createContext<AppContextValue | null>(null)
+11
View File
@@ -0,0 +1,11 @@
import { useContext } from 'react'
import { AppContext } from './appContextValue'
export function useAppContext() {
const context = useContext(AppContext)
if (!context) {
throw new Error('useAppContext must be used within AppProvider')
}
return context
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="usLine truncated

After

Width:  |  Height:  |  Size: 8.5 KiB

+56
View File
@@ -0,0 +1,56 @@
import { Outlet, NavLink } from 'react-router-dom'
import { useAppContext } from '../app/useAppContext'
import { formatDateTime } from '../lib/date'
const navigationItems = [
{ to: '/stations', label: 'Estaciones' },
{ to: '/predictions', label: 'Predicciones' },
{ to: '/settings', label: 'Ajustes' },
]
export function AppShell() {
const { forecastAll, isRefreshing, refreshData, session } = useAppContext()
return (
<div className="app-shell">
<header className="topbar">
<div>
<p className="eyebrow">Ski Predictor</p>
<h1 className="topbar__title">Condiciones de montaña</h1>
<p className="topbar__meta">
{session?.email} · Actualizado {formatDateTime(forecastAll?.generated_at ?? null)}
</p>
</div>
<button
className="ghost-button"
disabled={isRefreshing}
onClick={() => {
void refreshData()
}}
type="button"
>
{isRefreshing ? 'Sincronizando…' : 'Actualizar'}
</button>
</header>
<main className="page-container">
<Outlet />
</main>
<nav className="tabbar" aria-label="Navegación principal">
{navigationItems.map((item) => (
<NavLink
key={item.to}
className={({ isActive }) =>
isActive ? 'tabbar__item tabbar__item--active' : 'tabbar__item'
}
to={item.to}
>
{item.label}
</NavLink>
))}
</nav>
</div>
)
}
+68
View File
@@ -0,0 +1,68 @@
import type { DayForecast } from '../types'
import {
crowdLabel,
formatKilometers,
formatLongDate,
formatProbability,
} from '../lib/date'
interface ForecastCardProps {
day: DayForecast
heading: string
kicker?: string
}
export function ForecastCard({ day, heading, kicker }: ForecastCardProps) {
const probabilityValue =
day.open_probability === null ? 0 : Math.max(0, Math.min(100, day.open_probability * 100))
return (
<article className="forecast-card">
<div className="forecast-card__header">
<div>
<p className="forecast-card__kicker">{kicker ?? formatLongDate(day.date)}</p>
<h3>{heading}</h3>
</div>
<span className="status-pill">{day.open_label ?? 'Sin parte'}</span>
</div>
<div className="forecast-card__probability">
<div>
<p className="metric-label">Probabilidad de apertura</p>
<strong>{formatProbability(day.open_probability)}</strong>
</div>
<div className="progress-track" aria-hidden="true">
<span className="progress-fill" style={{ width: `${probabilityValue}%` }} />
</div>
</div>
<div className="forecast-card__grid">
<div className="metric-box">
<span className="metric-label">Km esquiables</span>
<strong>{formatKilometers(day.km_open, day.max_km)}</strong>
</div>
<div className="metric-box">
<span className="metric-label">Afluencia</span>
<strong>{crowdLabel(day.crowd_level)}</strong>
</div>
<div className="metric-box">
<span className="metric-label">Modelo</span>
<strong>{day.prediction_source ?? 'Sin dato'}</strong>
</div>
</div>
<div className="weather-callout">
<span className="metric-label">Meteo</span>
<p>{day.weather_summary ?? 'Sin resumen meteorológico disponible.'}</p>
</div>
{day.rule_notes.length > 0 ? (
<ul className="rule-list">
{day.rule_notes.map((note) => (
<li key={note}>{note}</li>
))}
</ul>
) : null}
</article>
)
}
+20
View File
@@ -0,0 +1,20 @@
import type { ReactNode } from 'react'
interface PageHeaderProps {
title: string
subtitle: string
actions?: ReactNode
}
export function PageHeader({ title, subtitle, actions }: PageHeaderProps) {
return (
<div className="page-header">
<div>
<p className="eyebrow">Explorar</p>
<h2>{title}</h2>
<p className="page-header__subtitle">{subtitle}</p>
</div>
{actions ? <div className="page-header__actions">{actions}</div> : null}
</div>
)
}
+49
View File
@@ -0,0 +1,49 @@
import type { ReactNode } from 'react'
interface BlockProps {
title: string
message: string
action?: ReactNode
}
export function SplashScreen() {
return (
<section className="auth-shell auth-shell--splash">
<div className="auth-card">
<p className="eyebrow">Ski Predictor</p>
<h1>Preparando la app</h1>
<p className="auth-card__hint">
Cargando sesión, preferencias y últimas predicciones.
</p>
</div>
</section>
)
}
export function LoadingBlock({ title, message }: BlockProps) {
return (
<section className="state-block">
<div className="loader" aria-hidden="true" />
<h3>{title}</h3>
<p>{message}</p>
</section>
)
}
export function EmptyBlock({ title, message, action }: BlockProps) {
return (
<section className="state-block">
<h3>{title}</h3>
<p>{message}</p>
{action}
</section>
)
}
export function ErrorBanner({ message }: { message: string }) {
return <div className="notice-banner notice-banner--error">{message}</div>
}
export function InfoBanner({ message }: { message: string }) {
return <div className="notice-banner notice-banner--info">{message}</div>
}
+595
View File
@@ -0,0 +1,595 @@
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Source+Serif+4:opsz,wght@8..60,600&display=swap');
:root {
--bg: #f3efe7;
--surface: rgba(255, 251, 245, 0.82);
--surface-strong: rgba(255, 248, 239, 0.95);
--surface-deep: #1a2d2f;
--line: rgba(28, 52, 57, 0.12);
--ink: #173038;
--muted: #577177;
--accent: #f2683c;
--accent-soft: rgba(242, 104, 60, 0.16);
--accent-strong: #ca4d23;
--success: #2f7d63;
--danger: #b5443c;
--shadow: 0 18px 40px rgba(23, 48, 56, 0.12);
--radius: 28px;
--radius-sm: 18px;
--page-width: 100%;
font-family: 'Space Grotesk', 'Avenir Next', sans-serif;
color: var(--ink);
background:
radial-gradient(circle at top left, rgba(242, 104, 60, 0.18), transparent 28%),
radial-gradient(circle at top right, rgba(35, 110, 140, 0.22), transparent 24%),
linear-gradient(180deg, #fffcf7 0%, #edf1ef 48%, #e6eeeb 100%);
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
line-height: 1.45;
}
* {
box-sizing: border-box;
}
html,
body,
#root {
min-height: 100%;
}
body {
margin: 0;
min-height: 100svh;
}
a {
color: inherit;
text-decoration: none;
}
button,
input {
font: inherit;
}
button {
cursor: pointer;
}
code {
font-family: 'IBM Plex Mono', 'Cascadia Code', monospace;
background: rgba(23, 48, 56, 0.08);
padding: 0.1rem 0.35rem;
border-radius: 0.5rem;
}
#root {
width: 100%;
}
h1,
h2,
h3 {
margin: 0;
color: var(--ink);
}
h1,
h2 {
font-family: 'Source Serif 4', Georgia, serif;
line-height: 1.02;
}
p {
margin: 0;
}
.auth-shell,
.app-shell {
width: min(100%, 540px);
margin: 0 auto;
min-height: 100svh;
padding: 1.1rem 1rem 6.5rem;
}
.auth-shell--splash {
display: grid;
place-items: center;
}
.auth-card,
.settings-panel,
.forecast-card,
.station-card,
.hero-panel,
.preview-card,
.topbar,
.tabbar,
.notice-banner,
.state-block {
border: 1px solid var(--line);
box-shadow: var(--shadow);
background: var(--surface);
backdrop-filter: blur(18px);
}
.auth-card {
margin-top: 1.5rem;
padding: 1.5rem;
border-radius: var(--radius);
display: grid;
gap: 1rem;
}
.auth-card h1 {
font-size: clamp(2.5rem, 6vw, 4rem);
}
.auth-card__hint,
.auth-card__footer,
.page-header__subtitle,
.topbar__meta,
.metric-label,
.settings-caption,
.state-block p,
.station-card__summary {
color: var(--muted);
}
.auth-card__footer {
display: grid;
gap: 0.35rem;
font-size: 0.92rem;
}
.segmented-control {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.5rem;
padding: 0.35rem;
border-radius: 999px;
background: rgba(23, 48, 56, 0.06);
}
.segment,
.primary-button,
.ghost-button,
.date-chip,
.weekday-chip,
.selection-pill,
.tabbar__item {
border-radius: 999px;
border: 1px solid transparent;
transition:
transform 180ms ease,
background-color 180ms ease,
border-color 180ms ease,
color 180ms ease;
}
.segment {
padding: 0.8rem 1rem;
background: transparent;
color: var(--muted);
}
.segment--active {
background: var(--surface-strong);
color: var(--ink);
border-color: rgba(23, 48, 56, 0.08);
}
.auth-form,
.page-stack,
.forecast-list {
display: grid;
gap: 1rem;
}
.field {
display: grid;
gap: 0.45rem;
}
.field span {
font-size: 0.92rem;
color: var(--muted);
}
.field input {
width: 100%;
border: 1px solid rgba(23, 48, 56, 0.12);
border-radius: 1rem;
padding: 0.95rem 1rem;
background: rgba(255, 255, 255, 0.7);
color: var(--ink);
}
.field--compact {
flex: 1;
}
.button-row {
display: flex;
gap: 0.75rem;
flex-wrap: wrap;
}
.primary-button,
.ghost-button,
.primary-button--link,
.ghost-button--link {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 3rem;
padding: 0.8rem 1.2rem;
}
.primary-button,
.primary-button--link {
background: linear-gradient(135deg, var(--accent) 0%, #ff9b61 100%);
color: #fff8f2;
}
.ghost-button,
.ghost-button--link {
background: rgba(255, 255, 255, 0.5);
color: var(--ink);
border-color: rgba(23, 48, 56, 0.12);
}
.primary-button:hover,
.ghost-button:hover,
.date-chip:hover,
.weekday-chip:hover,
.selection-pill:hover,
.tabbar__item:hover {
transform: translateY(-1px);
}
.primary-button:disabled,
.ghost-button:disabled {
opacity: 0.7;
cursor: default;
transform: none;
}
.eyebrow {
text-transform: uppercase;
letter-spacing: 0.18em;
font-size: 0.76rem;
font-weight: 700;
color: var(--accent-strong);
}
.topbar {
position: sticky;
top: 1rem;
z-index: 10;
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
padding: 1.25rem;
border-radius: var(--radius);
margin-top: 0.6rem;
}
.topbar__title {
font-size: clamp(1.6rem, 5vw, 2.4rem);
}
.page-container {
padding-top: 1rem;
}
.page-header {
display: flex;
justify-content: space-between;
gap: 1rem;
align-items: flex-start;
}
.page-header h2 {
font-size: clamp(2rem, 5vw, 2.8rem);
}
.page-header__actions {
display: flex;
align-items: center;
}
.notice-banner {
padding: 0.9rem 1rem;
border-radius: 1.1rem;
}
.notice-banner--error {
border-color: rgba(181, 68, 60, 0.22);
color: var(--danger);
background: rgba(181, 68, 60, 0.08);
}
.notice-banner--info {
border-color: rgba(47, 125, 99, 0.18);
color: var(--success);
background: rgba(47, 125, 99, 0.08);
}
.station-grid,
.forecast-list {
display: grid;
gap: 1rem;
}
.station-card,
.forecast-card,
.settings-panel {
padding: 1.15rem;
border-radius: var(--radius);
}
.station-card {
display: grid;
gap: 0.9rem;
}
.station-card__top,
.station-card__footer,
.settings-panel__header,
.forecast-card__header,
.forecast-card__probability,
.date-adder,
.toggle {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 0.75rem;
}
.station-card__label {
color: var(--accent-strong);
text-transform: uppercase;
letter-spacing: 0.16em;
font-size: 0.72rem;
}
.station-card__stats,
.forecast-card__grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
}
.topography-pill,
.hero-panel__chip,
.status-pill {
padding: 0.5rem 0.85rem;
border-radius: 999px;
background: rgba(23, 48, 56, 0.08);
color: var(--ink);
font-size: 0.82rem;
}
.station-card__footer {
color: var(--muted);
font-size: 0.82rem;
flex-wrap: wrap;
}
.metric-box {
padding: 0.85rem;
border-radius: 1.1rem;
background: rgba(255, 255, 255, 0.45);
border: 1px solid rgba(23, 48, 56, 0.08);
}
.metric-box strong,
.forecast-card__probability strong,
.station-card__stats strong {
display: block;
margin-top: 0.25rem;
font-size: 1rem;
}
.forecast-card__probability {
align-items: center;
}
.progress-track {
flex: 1;
min-width: 110px;
height: 0.8rem;
border-radius: 999px;
background: rgba(23, 48, 56, 0.08);
overflow: hidden;
}
.progress-fill {
display: block;
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #ffd07e 0%, var(--accent) 60%, var(--accent-strong) 100%);
}
.weather-callout {
padding: 0.95rem 1rem;
border-radius: 1.15rem;
background: rgba(23, 48, 56, 0.05);
}
.rule-list,
.preview-list {
margin: 0;
padding-left: 1rem;
display: grid;
gap: 0.45rem;
}
.hero-panel {
display: flex;
flex-wrap: wrap;
gap: 0.65rem;
padding: 1rem;
border-radius: var(--radius);
}
.date-selector {
display: grid;
grid-auto-flow: column;
grid-auto-columns: minmax(11rem, 1fr);
gap: 0.75rem;
overflow-x: auto;
padding-bottom: 0.15rem;
}
.date-chip {
padding: 0.95rem 1rem;
text-align: left;
background: rgba(255, 255, 255, 0.52);
border-color: rgba(23, 48, 56, 0.1);
color: var(--muted);
}
.date-chip strong {
display: block;
color: var(--ink);
font-size: 0.98rem;
}
.date-chip--active {
background: linear-gradient(135deg, rgba(242, 104, 60, 0.2), rgba(35, 110, 140, 0.18));
border-color: rgba(242, 104, 60, 0.28);
color: var(--ink);
}
.weekday-grid,
.selection-list {
display: flex;
gap: 0.6rem;
flex-wrap: wrap;
}
.weekday-chip,
.selection-pill {
background: rgba(255, 255, 255, 0.56);
border-color: rgba(23, 48, 56, 0.1);
padding: 0.75rem 1rem;
color: var(--ink);
}
.weekday-chip--active {
background: var(--accent-soft);
border-color: rgba(242, 104, 60, 0.25);
}
.preview-card {
border-radius: var(--radius-sm);
padding: 1rem;
}
.preview-list li {
display: flex;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
}
.settings-panel {
display: grid;
gap: 1rem;
}
.toggle {
align-items: center;
font-weight: 500;
}
.toggle input {
width: 1.15rem;
height: 1.15rem;
}
.state-block {
min-height: 40svh;
border-radius: var(--radius);
display: grid;
place-items: center;
text-align: center;
gap: 0.75rem;
padding: 2rem;
}
.loader {
width: 3rem;
height: 3rem;
border-radius: 999px;
border: 4px solid rgba(23, 48, 56, 0.12);
border-top-color: var(--accent);
animation: spin 1s linear infinite;
}
.tabbar {
position: fixed;
left: 50%;
bottom: 1rem;
transform: translateX(-50%);
width: min(calc(100% - 1.5rem), 520px);
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.5rem;
padding: 0.5rem;
border-radius: 999px;
}
.tabbar__item {
min-height: 3rem;
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--muted);
}
.tabbar__item--active {
color: var(--ink);
background: rgba(255, 255, 255, 0.76);
border-color: rgba(23, 48, 56, 0.1);
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@media (max-width: 520px) {
.auth-shell,
.app-shell {
padding-inline: 0.75rem;
}
.topbar,
.page-header,
.station-card__top,
.settings-panel__header,
.forecast-card__header,
.forecast-card__probability,
.date-adder {
flex-direction: column;
}
.station-card__stats,
.forecast-card__grid {
grid-template-columns: 1fr;
}
.tabbar {
width: calc(100% - 1rem);
bottom: 0.5rem;
}
}
+191
View File
@@ -0,0 +1,191 @@
import { Capacitor } from '@capacitor/core'
import { LocalNotifications } from '@capacitor/local-notifications'
import type {
AlertSettings,
AlertSyncResult,
ForecastAllResponse,
NotificationPlanItem,
} from '../types'
import { formatShortDate, parseLocalDate, toIsoDate } from './date'
const ALERT_HOUR = 20
const ALERT_MINUTE = 15
const WEEKDAY_HORIZON_DAYS = 112
function buildNotificationId(targetDate: string): number {
return Number(targetDate.replaceAll('-', ''))
}
function buildNotifyDate(targetDate: string): Date {
const date = parseLocalDate(targetDate)
return new Date(
date.getFullYear(),
date.getMonth(),
date.getDate() - 1,
ALERT_HOUR,
ALERT_MINUTE,
0,
0,
)
}
function addDays(base: Date, days: number): Date {
return new Date(
base.getFullYear(),
base.getMonth(),
base.getDate() + days,
base.getHours(),
base.getMinutes(),
base.getSeconds(),
base.getMilliseconds(),
)
}
export function buildAlertPlan(
settings: AlertSettings,
now = new Date(),
): NotificationPlanItem[] {
if (!settings.enabled) {
return []
}
const plan = new Map<string, NotificationPlanItem>()
for (const targetDate of settings.specificDates) {
const notifyAt = buildNotifyDate(targetDate)
if (notifyAt > now) {
plan.set(targetDate, {
id: buildNotificationId(targetDate),
targetDate,
notifyAt,
})
}
}
for (let offset = 1; offset <= WEEKDAY_HORIZON_DAYS; offset += 1) {
const target = addDays(now, offset)
const targetDate = toIsoDate(target)
if (!settings.weekdayTargets.includes(target.getDay())) {
continue
}
const notifyAt = buildNotifyDate(targetDate)
if (notifyAt > now) {
plan.set(targetDate, {
id: buildNotificationId(targetDate),
targetDate,
notifyAt,
})
}
}
return Array.from(plan.values()).sort(
(left, right) => left.notifyAt.getTime() - right.notifyAt.getTime(),
)
}
function shortStationName(name: string): string {
return name
.replace('Valgrande-', '')
.replace(' de Invierno', '')
.trim()
}
function buildNotificationBody(
targetDate: string,
forecastAll: ForecastAllResponse | null,
): string {
if (!forecastAll) {
return 'Consulta la predicción de mañana para las tres estaciones.'
}
const stationSummaries = Object.values(forecastAll.stations)
.map((station) => {
const day = station.days.find((entry) => entry.date === targetDate)
if (!day || day.open_probability === null) {
return null
}
return `${shortStationName(station.name)} ${Math.round(day.open_probability * 100)}%`
})
.filter((entry): entry is string => entry !== null)
if (stationSummaries.length === 0) {
return 'Consulta la predicción de mañana para las tres estaciones.'
}
return `${stationSummaries.join(' · ')}. Abre la app para ver km y afluencia.`
}
async function clearPendingNotifications() {
const pending = await LocalNotifications.getPending()
if (pending.notifications.length === 0) {
return
}
await LocalNotifications.cancel({
notifications: pending.notifications.map((notification) => ({
id: notification.id,
})),
})
}
export async function syncPredictionAlerts(
settings: AlertSettings,
forecastAll: ForecastAllResponse | null,
requestPermission: boolean,
): Promise<AlertSyncResult> {
const plan = buildAlertPlan(settings)
if (!Capacitor.isNativePlatform()) {
return {
nativeSupport: false,
permissionGranted: false,
plan,
}
}
await clearPendingNotifications()
if (!settings.enabled || plan.length === 0) {
return {
nativeSupport: true,
permissionGranted: true,
plan,
}
}
const permissions = requestPermission
? await LocalNotifications.requestPermissions()
: await LocalNotifications.checkPermissions()
if (permissions.display !== 'granted') {
return {
nativeSupport: true,
permissionGranted: false,
plan,
}
}
await LocalNotifications.schedule({
notifications: plan.map((item) => ({
id: item.id,
title: `Predicción para ${formatShortDate(item.targetDate)}`,
body: buildNotificationBody(item.targetDate, forecastAll),
schedule: {
at: item.notifyAt,
allowWhileIdle: true,
},
extra: {
targetDate: item.targetDate,
},
})),
})
return {
nativeSupport: true,
permissionGranted: true,
plan,
}
}
+128
View File
@@ -0,0 +1,128 @@
import { CapacitorHttp, type HttpOptions } from '@capacitor/core'
import type {
ForecastAllResponse,
ForecastStationResponse,
StationsResponse,
TokenResponse,
UserResponse,
} from '../types'
const API_PREFIX = '/api/v1'
const RAW_DEFAULT_BASE_URL = import.meta.env.VITE_API_BASE_URL?.trim()
export class ApiError extends Error {
status: number
constructor(status: number, detail: string) {
super(detail)
this.name = 'ApiError'
this.status = status
}
}
function parseErrorDetail(payload: unknown): string {
if (typeof payload === 'string' && payload.trim()) {
return payload
}
if (payload && typeof payload === 'object' && 'detail' in payload) {
const detail = Reflect.get(payload, 'detail')
if (typeof detail === 'string' && detail.trim()) {
return detail
}
}
return 'No se pudo completar la petición.'
}
export function normalizeBaseUrl(rawUrl: string): string {
return rawUrl.trim().replace(/\/+$/, '').replace(/\/api\/v1$/, '')
}
export function getDefaultApiBaseUrl(): string {
return normalizeBaseUrl(RAW_DEFAULT_BASE_URL || 'http://10.0.2.2:8000')
}
function buildApiUrl(baseUrl: string, path: string): string {
const normalized = normalizeBaseUrl(baseUrl)
if (!normalized) {
throw new ApiError(0, 'Configura la URL del backend antes de iniciar sesión.')
}
return `${normalized}${API_PREFIX}${path}`
}
async function request<T>(
baseUrl: string,
path: string,
init: {
method?: HttpOptions['method']
token?: string
headers?: Record<string, string>
data?: unknown
} = {},
): Promise<T> {
const { method = 'GET', token, headers = {}, data } = init
const response = await CapacitorHttp.request({
url: buildApiUrl(baseUrl, path),
method,
headers: {
Accept: 'application/json',
...(token ? { Authorization: `Bearer ${token}` } : {}),
...headers,
},
data,
})
if (response.status >= 400) {
throw new ApiError(response.status, parseErrorDetail(response.data))
}
return response.data as T
}
export function getHealth(baseUrl: string) {
return request<{ status: string; timestamp: string }>(baseUrl, '/health')
}
export function registerUser(baseUrl: string, email: string, password: string) {
return request<UserResponse>(baseUrl, '/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: { email, password },
})
}
export function loginUser(baseUrl: string, email: string, password: string) {
return request<TokenResponse>(baseUrl, '/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: new URLSearchParams({
username: email,
password,
}).toString(),
})
}
export function fetchStations(baseUrl: string, token: string) {
return request<StationsResponse>(baseUrl, '/stations', { token })
}
export function fetchForecastAll(baseUrl: string, token: string) {
return request<ForecastAllResponse>(baseUrl, '/forecast', { token })
}
export function fetchForecastStation(
baseUrl: string,
token: string,
stationId: string,
) {
return request<ForecastStationResponse>(baseUrl, `/forecast/${stationId}`, {
token,
})
}
+93
View File
@@ -0,0 +1,93 @@
const LONG_DATE_FORMATTER = new Intl.DateTimeFormat('es-ES', {
weekday: 'long',
day: 'numeric',
month: 'long',
})
const SHORT_DATE_FORMATTER = new Intl.DateTimeFormat('es-ES', {
day: 'numeric',
month: 'short',
})
const DATE_TIME_FORMATTER = new Intl.DateTimeFormat('es-ES', {
day: '2-digit',
month: '2-digit',
hour: '2-digit',
minute: '2-digit',
})
export function parseLocalDate(dateString: string): Date {
const [year, month, day] = dateString.split('-').map(Number)
return new Date(year, month - 1, day, 12, 0, 0, 0)
}
export function toIsoDate(date: Date): string {
const year = date.getFullYear()
const month = `${date.getMonth() + 1}`.padStart(2, '0')
const day = `${date.getDate()}`.padStart(2, '0')
return `${year}-${month}-${day}`
}
export function formatLongDate(dateString: string): string {
return LONG_DATE_FORMATTER.format(parseLocalDate(dateString))
}
export function formatShortDate(dateString: string): string {
return SHORT_DATE_FORMATTER.format(parseLocalDate(dateString))
}
export function formatDateTime(timestamp: string | null): string {
if (!timestamp) {
return 'Sin sincronizar'
}
return DATE_TIME_FORMATTER.format(new Date(timestamp))
}
export function formatProbability(probability: number | null): string {
if (probability === null || Number.isNaN(probability)) {
return '--'
}
return `${Math.round(probability * 100)}%`
}
export function formatKilometers(km: number | null, maxKm: number | null): string {
if (km === null || Number.isNaN(km)) {
return '--'
}
if (maxKm === null || Number.isNaN(maxKm) || maxKm <= 0) {
return `${km.toFixed(1)} km`
}
return `${km.toFixed(1)} / ${maxKm.toFixed(1)} km`
}
export function crowdLabel(level: string | null): string {
if (!level) {
return 'Sin dato'
}
return (
{
low: 'Baja',
medium: 'Media',
high: 'Alta',
}[level] ?? level
)
}
export function weekdayLabel(weekday: number): string {
return (
{
0: 'Domingo',
1: 'Lunes',
2: 'Martes',
3: 'Miércoles',
4: 'Jueves',
5: 'Viernes',
6: 'Sábado',
}[weekday] ?? 'Desconocido'
)
}
+46
View File
@@ -0,0 +1,46 @@
import { Preferences } from '@capacitor/preferences'
import type { AppPreferences, Session } from '../types'
const SESSION_KEY = 'skipredictor.session'
const PREFERENCES_KEY = 'skipredictor.preferences'
async function readJson<T>(key: string): Promise<T | null> {
const { value } = await Preferences.get({ key })
if (!value) {
return null
}
try {
return JSON.parse(value) as T
} catch {
return null
}
}
async function writeJson<T>(key: string, payload: T) {
await Preferences.set({
key,
value: JSON.stringify(payload),
})
}
export function loadSession() {
return readJson<Session>(SESSION_KEY)
}
export async function saveSession(session: Session) {
await writeJson(SESSION_KEY, session)
}
export async function clearSession() {
await Preferences.remove({ key: SESSION_KEY })
}
export function loadPreferences() {
return readJson<AppPreferences>(PREFERENCES_KEY)
}
export async function savePreferences(preferences: AppPreferences) {
await writeJson(PREFERENCES_KEY, preferences)
}
+10
View File
@@ -0,0 +1,10 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
+153
View File
@@ -0,0 +1,153 @@
import { useState } from 'react'
import { useAppContext } from '../app/useAppContext'
import { getHealth } from '../lib/api'
type AuthMode = 'login' | 'register'
export function AuthPage() {
const { apiBaseUrl, login, register } = useAppContext()
const [mode, setMode] = useState<AuthMode>('login')
const [apiInput, setApiInput] = useState(apiBaseUrl)
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [isSubmitting, setIsSubmitting] = useState(false)
const [feedback, setFeedback] = useState<string | null>(null)
const [checkingHealth, setCheckingHealth] = useState(false)
async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
setFeedback(null)
setIsSubmitting(true)
try {
if (mode === 'login') {
await login(email, password, apiInput)
} else {
await register(email, password, apiInput)
}
} catch (error) {
setFeedback(error instanceof Error ? error.message : 'No se pudo iniciar sesión.')
} finally {
setIsSubmitting(false)
}
}
async function handleHealthCheck() {
setCheckingHealth(true)
setFeedback(null)
try {
const health = await getHealth(apiInput)
setFeedback(`Backend operativo. Estado: ${health.status}.`)
} catch (error) {
setFeedback(
error instanceof Error
? error.message
: 'No se ha podido contactar con el backend.',
)
} finally {
setCheckingHealth(false)
}
}
return (
<section className="auth-shell">
<div className="auth-card">
<p className="eyebrow">Android + JWT</p>
<h1>Parte de estaciones en el móvil</h1>
<p className="auth-card__hint">
La API real exige JWT bearer para todas las rutas salvo <code>/health</code>.
Esta app usa registro y login contra el backend FastAPI.
</p>
<div className="segmented-control" role="tablist" aria-label="Modo de acceso">
<button
className={mode === 'login' ? 'segment segment--active' : 'segment'}
onClick={() => setMode('login')}
type="button"
>
Entrar
</button>
<button
className={mode === 'register' ? 'segment segment--active' : 'segment'}
onClick={() => setMode('register')}
type="button"
>
Crear cuenta
</button>
</div>
<form className="auth-form" onSubmit={handleSubmit}>
<label className="field">
<span>Backend</span>
<input
autoCapitalize="none"
autoComplete="url"
inputMode="url"
onChange={(event) => setApiInput(event.target.value)}
placeholder="https://tu-backend.example.com"
type="url"
value={apiInput}
/>
</label>
<label className="field">
<span>Email</span>
<input
autoCapitalize="none"
autoComplete="email"
onChange={(event) => setEmail(event.target.value)}
placeholder="usuario@dominio.com"
type="email"
value={email}
/>
</label>
<label className="field">
<span>Contraseña</span>
<input
autoComplete={
mode === 'login' ? 'current-password' : 'new-password'
}
minLength={8}
onChange={(event) => setPassword(event.target.value)}
placeholder="Mínimo 8 caracteres"
type="password"
value={password}
/>
</label>
<div className="button-row">
<button className="primary-button" disabled={isSubmitting} type="submit">
{isSubmitting
? 'Procesando…'
: mode === 'login'
? 'Entrar con JWT'
: 'Crear cuenta y entrar'}
</button>
<button
className="ghost-button"
disabled={checkingHealth}
onClick={handleHealthCheck}
type="button"
>
{checkingHealth ? 'Comprobando…' : 'Probar conexión'}
</button>
</div>
</form>
{feedback ? <div className="notice-banner notice-banner--info">{feedback}</div> : null}
<div className="auth-card__footer">
<p>Emulador Android: usa por defecto <code>http://10.0.2.2:8000</code>.</p>
<p>
En navegador puede hacer falta CORS o proxy; en Android se usa HTTP nativo
de Capacitor.
</p>
</div>
</div>
</section>
)
}
+108
View File
@@ -0,0 +1,108 @@
import { useEffect } from 'react'
import { useNavigate, useParams } from 'react-router-dom'
import { useAppContext } from '../app/useAppContext'
import { ForecastCard } from '../components/ForecastCard'
import { PageHeader } from '../components/PageHeader'
import {
EmptyBlock,
ErrorBanner,
LoadingBlock,
} from '../components/StateViews'
import { formatLongDate, formatShortDate } from '../lib/date'
export function PredictionsPage() {
const navigate = useNavigate()
const { date } = useParams()
const { dataError, forecastAll, isRefreshing, refreshData } = useAppContext()
const stations = forecastAll ? Object.values(forecastAll.stations) : []
const availableDates = Array.from(
new Set(
stations.flatMap((station) => station.days.map((day) => day.date)),
),
).sort()
const selectedDate = date && availableDates.includes(date) ? date : availableDates[0]
useEffect(() => {
if (!selectedDate) {
return
}
if (date !== selectedDate) {
navigate(`/predictions/${selectedDate}`, { replace: true })
}
}, [date, navigate, selectedDate])
if (!forecastAll && isRefreshing) {
return (
<LoadingBlock
title="Cargando predicciones"
message="Pidiendo el forecast conjunto de las tres estaciones."
/>
)
}
if (!forecastAll || availableDates.length === 0 || !selectedDate) {
return (
<EmptyBlock
action={
<button
className="primary-button"
onClick={() => {
void refreshData()
}}
type="button"
>
Reintentar
</button>
}
message="El backend todavía no ha publicado el forecast agregado."
title="Sin predicciones"
/>
)
}
return (
<section className="page-stack">
<PageHeader
subtitle="Un día por vista con la comparación entre las tres estaciones."
title="Predicciones"
/>
{dataError ? <ErrorBanner message={dataError} /> : null}
<div className="date-selector" role="tablist" aria-label="Días disponibles">
{availableDates.map((item) => (
<button
className={item === selectedDate ? 'date-chip date-chip--active' : 'date-chip'}
key={item}
onClick={() => navigate(`/predictions/${item}`)}
type="button"
>
<span>{formatShortDate(item)}</span>
<strong>{formatLongDate(item)}</strong>
</button>
))}
</div>
<div className="forecast-list">
{stations.map((station) => {
const day = station.days.find((entry) => entry.date === selectedDate)
if (!day) {
return null
}
return (
<ForecastCard
day={day}
heading={station.name}
key={station.station_id}
kicker={formatLongDate(selectedDate)}
/>
)
})}
</div>
</section>
)
}
+283
View File
@@ -0,0 +1,283 @@
import { Capacitor } from '@capacitor/core'
import { useEffect, useState } from 'react'
import { useAppContext } from '../app/useAppContext'
import { PageHeader } from '../components/PageHeader'
import { InfoBanner } from '../components/StateViews'
import { buildAlertPlan } from '../lib/alerts'
import { formatDateTime, formatLongDate, weekdayLabel } from '../lib/date'
import type { AlertSettings } from '../types'
function sortUnique(values: string[]) {
return Array.from(new Set(values)).sort()
}
export function SettingsPage() {
const {
alertSettings,
apiBaseUrl,
forecastAll,
logout,
saveAlertSettings,
saveApiBaseUrl,
session,
} = useAppContext()
const [apiInput, setApiInput] = useState(apiBaseUrl)
const [draft, setDraft] = useState<AlertSettings>(alertSettings)
const [dateInput, setDateInput] = useState('')
const [feedback, setFeedback] = useState<string | null>(null)
const [isSavingApi, setIsSavingApi] = useState(false)
const [isSavingAlerts, setIsSavingAlerts] = useState(false)
useEffect(() => {
setApiInput(apiBaseUrl)
setDraft(alertSettings)
}, [alertSettings, apiBaseUrl])
const preview = buildAlertPlan(draft).slice(0, 6)
function toggleWeekday(weekday: number) {
setDraft((current) => ({
...current,
weekdayTargets: current.weekdayTargets.includes(weekday)
? current.weekdayTargets.filter((entry) => entry !== weekday)
: [...current.weekdayTargets, weekday].sort((left, right) => left - right),
}))
}
function addSpecificDate() {
if (!dateInput) {
return
}
setDraft((current) => ({
...current,
specificDates: sortUnique([...current.specificDates, dateInput]),
}))
setDateInput('')
}
async function handleSaveApi() {
setIsSavingApi(true)
setFeedback(null)
try {
await saveApiBaseUrl(apiInput)
setFeedback('Backend guardado. La próxima sincronización usará esa URL.')
} catch (error) {
setFeedback(error instanceof Error ? error.message : 'No se pudo guardar la URL.')
} finally {
setIsSavingApi(false)
}
}
async function handleSaveAlerts() {
if (
draft.enabled &&
draft.weekdayTargets.length === 0 &&
draft.specificDates.length === 0
) {
setFeedback('Selecciona al menos un día de la semana o una fecha concreta.')
return
}
setIsSavingAlerts(true)
setFeedback(null)
try {
const result = await saveAlertSettings(draft)
if (!result.nativeSupport) {
setFeedback(
`Configuración guardada. Vista web sin notificaciones nativas; Android programará ${result.plan.length} avisos.`,
)
} else if (!result.permissionGranted) {
setFeedback(
'Configuración guardada, pero Android no concedió permisos de notificación.',
)
} else if (!draft.enabled) {
setFeedback('Alertas desactivadas.')
} else {
setFeedback(`Alertas programadas: ${result.plan.length}.`)
}
} catch (error) {
setFeedback(
error instanceof Error
? error.message
: 'No se pudieron programar las alertas.',
)
} finally {
setIsSavingAlerts(false)
}
}
return (
<section className="page-stack">
<PageHeader
subtitle="Backend, sesión y alertas Android a las 20:15 del día anterior."
title="Ajustes"
/>
{feedback ? <InfoBanner message={feedback} /> : null}
<section className="settings-panel">
<div className="settings-panel__header">
<div>
<h3>API del backend</h3>
<p>La app usa las rutas reales protegidas con JWT del FastAPI.</p>
</div>
</div>
<label className="field">
<span>Base URL</span>
<input
autoCapitalize="none"
onChange={(event) => setApiInput(event.target.value)}
placeholder="https://tu-backend.example.com"
type="url"
value={apiInput}
/>
</label>
<button
className="ghost-button"
disabled={isSavingApi}
onClick={handleSaveApi}
type="button"
>
{isSavingApi ? 'Guardando…' : 'Guardar backend'}
</button>
</section>
<section className="settings-panel">
<div className="settings-panel__header">
<div>
<h3>Alertas de predicción</h3>
<p>
Si eliges sábado, el aviso salta el viernes a las 20:15. Puedes
combinar patrón semanal y fechas sueltas.
</p>
</div>
<label className="toggle">
<input
checked={draft.enabled}
onChange={(event) =>
setDraft((current) => ({
...current,
enabled: event.target.checked,
}))
}
type="checkbox"
/>
<span>Activar</span>
</label>
</div>
<div className="weekday-grid">
{[1, 2, 3, 4, 5, 6, 0].map((weekday) => (
<button
className={
draft.weekdayTargets.includes(weekday)
? 'weekday-chip weekday-chip--active'
: 'weekday-chip'
}
key={weekday}
onClick={() => toggleWeekday(weekday)}
type="button"
>
{weekdayLabel(weekday)}
</button>
))}
</div>
<div className="date-adder">
<label className="field field--compact">
<span>Día concreto</span>
<input
min={new Date().toISOString().slice(0, 10)}
onChange={(event) => setDateInput(event.target.value)}
type="date"
value={dateInput}
/>
</label>
<button className="ghost-button" onClick={addSpecificDate} type="button">
Añadir
</button>
</div>
{draft.specificDates.length > 0 ? (
<div className="selection-list">
{draft.specificDates.map((item) => (
<button
className="selection-pill"
key={item}
onClick={() =>
setDraft((current) => ({
...current,
specificDates: current.specificDates.filter(
(entry) => entry !== item,
),
}))
}
type="button"
>
{formatLongDate(item)} ×
</button>
))}
</div>
) : null}
<button
className="primary-button"
disabled={isSavingAlerts}
onClick={handleSaveAlerts}
type="button"
>
{isSavingAlerts ? 'Programando…' : 'Guardar alertas'}
</button>
<div className="preview-card">
<p className="metric-label">Próximos avisos</p>
{preview.length > 0 ? (
<ul className="preview-list">
{preview.map((item) => (
<li key={item.id}>
<strong>{formatLongDate(item.targetDate)}</strong>
<span>{formatDateTime(item.notifyAt.toISOString())}</span>
</li>
))}
</ul>
) : (
<p>No hay avisos programables con la selección actual.</p>
)}
</div>
<p className="settings-caption">
{Capacitor.isNativePlatform()
? 'Android programará notificaciones locales exactas.'
: 'En navegador solo se muestra la previsualización; la programación real ocurre en Android.'}
</p>
</section>
<section className="settings-panel">
<div className="settings-panel__header">
<div>
<h3>Sesión</h3>
<p>{session?.email}</p>
</div>
<button
className="ghost-button"
onClick={() => {
void logout()
}}
type="button"
>
Cerrar sesión
</button>
</div>
<p className="settings-caption">
Último forecast en memoria: {formatDateTime(forecastAll?.generated_at ?? null)}
</p>
</section>
</section>
)
}
+134
View File
@@ -0,0 +1,134 @@
import { startTransition, useEffect, useState } from 'react'
import { Link, Navigate, useParams } from 'react-router-dom'
import { useAppContext } from '../app/useAppContext'
import { ForecastCard } from '../components/ForecastCard'
import { PageHeader } from '../components/PageHeader'
import {
EmptyBlock,
ErrorBanner,
LoadingBlock,
} from '../components/StateViews'
import { fetchForecastStation } from '../lib/api'
import { formatDateTime, formatLongDate } from '../lib/date'
import type { ForecastStationResponse } from '../types'
function getMessage(error: unknown): string {
return error instanceof Error ? error.message : 'No se pudo cargar la estación.'
}
export function StationPage() {
const { stationId } = useParams()
const { apiBaseUrl, session, stations } = useAppContext()
const [forecast, setForecast] = useState<ForecastStationResponse | null>(null)
const [loadedStationId, setLoadedStationId] = useState<string | null>(null)
const [error, setError] = useState<string | null>(null)
const stationMeta = stations.find((station) => station.station_id === stationId)
const currentError = loadedStationId === stationId ? error : null
const isLoading = loadedStationId !== stationId && currentError === null
useEffect(() => {
if (!session || !stationId) {
return
}
let active = true
void fetchForecastStation(apiBaseUrl, session.token, stationId)
.then((nextForecast) => {
if (!active) {
return
}
startTransition(() => {
setForecast(nextForecast)
setLoadedStationId(stationId)
setError(null)
})
})
.catch((nextError) => {
if (!active) {
return
}
startTransition(() => {
setLoadedStationId(stationId)
setError(getMessage(nextError))
})
})
return () => {
active = false
}
}, [apiBaseUrl, session, stationId])
if (!stationId) {
return <Navigate replace to="/stations" />
}
if (isLoading) {
return (
<LoadingBlock
title="Cargando estación"
message="Recuperando el forecast específico de esta estación."
/>
)
}
if (!forecast) {
return (
<EmptyBlock
action={
<Link className="primary-button primary-button--link" to="/stations">
Volver a estaciones
</Link>
}
message="No hay datos disponibles para esta estación."
title="Sin forecast"
/>
)
}
return (
<section className="page-stack">
<PageHeader
actions={
<Link className="ghost-button ghost-button--link" to="/stations">
Volver
</Link>
}
subtitle={`Generado ${formatDateTime(forecast.generated_at)} · Run ${
forecast.run_hour ?? '--'
}:00`}
title={forecast.name}
/>
{currentError ? <ErrorBanner message={currentError} /> : null}
{stationMeta ? (
<div className="hero-panel">
<div className="hero-panel__chip">Altitud {stationMeta.altitude} m</div>
<div className="hero-panel__chip">Máx. {stationMeta.max_km.toFixed(1)} km</div>
<div className="hero-panel__chip">
Cierre viento {stationMeta.wind_closure_threshold_kmh} km/h
</div>
<div className="hero-panel__chip">
Nieve mínima {stationMeta.min_snow_depth_cm} cm
</div>
</div>
) : null}
<div className="forecast-list">
{forecast.days.map((day) => (
<ForecastCard
day={day}
heading={formatLongDate(day.date)}
key={day.date}
kicker={day.open_label ?? 'Predicción'}
/>
))}
</div>
</section>
)
}
+126
View File
@@ -0,0 +1,126 @@
import { Link } from 'react-router-dom'
import { useAppContext } from '../app/useAppContext'
import { PageHeader } from '../components/PageHeader'
import {
EmptyBlock,
ErrorBanner,
InfoBanner,
LoadingBlock,
} from '../components/StateViews'
import {
crowdLabel,
formatKilometers,
formatProbability,
formatShortDate,
} from '../lib/date'
export function StationsPage() {
const { dataError, forecastAll, isRefreshing, refreshData, stations } = useAppContext()
if (!forecastAll && isRefreshing) {
return (
<LoadingBlock
title="Cargando estaciones"
message="Recuperando metadatos y predicciones actuales."
/>
)
}
if (stations.length === 0) {
return (
<EmptyBlock
action={
<button
className="primary-button"
onClick={() => {
void refreshData()
}}
type="button"
>
Reintentar
</button>
}
message="La API todavía no ha devuelto ninguna estación."
title="No hay estaciones disponibles"
/>
)
}
return (
<section className="page-stack">
<PageHeader
actions={
<button
className="ghost-button"
onClick={() => {
void refreshData()
}}
type="button"
>
Refrescar
</button>
}
subtitle="Un acceso por estación con parte actual y previsión a 7 días."
title="Estaciones"
/>
{dataError ? <ErrorBanner message={dataError} /> : null}
{forecastAll?.run_hour !== null ? (
<InfoBanner
message={`Última corrida del backend: ${forecastAll?.run_hour}:00.`}
/>
) : null}
<div className="station-grid">
{stations.map((station) => {
const headline = forecastAll?.stations[station.station_id]?.days[0] ?? null
return (
<Link
className="station-card"
key={station.station_id}
to={`/stations/${station.station_id}`}
>
<div className="station-card__top">
<div>
<p className="station-card__label">{station.station_id}</p>
<h3>{station.name}</h3>
</div>
<span className="topography-pill">{station.altitude} m</span>
</div>
<div className="station-card__stats">
<div>
<span className="metric-label">Apertura</span>
<strong>{formatProbability(headline?.open_probability ?? null)}</strong>
</div>
<div>
<span className="metric-label">Km</span>
<strong>
{formatKilometers(headline?.km_open ?? null, station.max_km)}
</strong>
</div>
<div>
<span className="metric-label">Afluencia</span>
<strong>{crowdLabel(headline?.crowd_level ?? null)}</strong>
</div>
</div>
<p className="station-card__summary">
{headline
? `${formatShortDate(headline.date)} · ${headline.weather_summary ?? 'Sin resumen meteo'}`
: 'Sin predicción disponible todavía.'}
</p>
<div className="station-card__footer">
<span>Viento cierre {station.wind_closure_threshold_kmh} km/h</span>
<span>Nieve mínima {station.min_snow_depth_cm} cm</span>
</div>
</Link>
)
})}
</div>
</section>
)
}
+90
View File
@@ -0,0 +1,90 @@
export interface StationInfo {
station_id: string
name: string
max_km: number
latitude: number
longitude: number
altitude: number
wind_closure_threshold_kmh: number
min_snow_depth_cm: number
}
export interface StationsResponse {
stations: StationInfo[]
}
export interface DayForecast {
date: string
open_probability: number | null
open_label: string | null
km_open: number | null
max_km: number | null
crowd_level: string | null
weather_summary: string | null
rule_notes: string[]
prediction_source: string | null
}
export interface StationForecast {
station_id: string
name: string
days: DayForecast[]
}
export interface ForecastAllResponse {
generated_at: string | null
run_hour: number | null
stations: Record<string, StationForecast>
}
export interface ForecastStationResponse {
generated_at: string | null
run_hour: number | null
station_id: string
name: string
days: DayForecast[]
}
export interface TokenResponse {
access_token: string
token_type: string
}
export interface UserResponse {
id: number
email: string
}
export interface Session {
email: string
token: string
}
export interface AlertSettings {
enabled: boolean
weekdayTargets: number[]
specificDates: string[]
}
export interface AppPreferences {
apiBaseUrl: string
alertSettings: AlertSettings
}
export interface NotificationPlanItem {
id: number
targetDate: string
notifyAt: Date
}
export interface AlertSyncResult {
nativeSupport: boolean
permissionGranted: boolean
plan: NotificationPlanItem[]
}
export const DEFAULT_ALERT_SETTINGS: AlertSettings = {
enabled: false,
weekdayTargets: [],
specificDates: [],
}
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2023",
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})