Mobile app (#3)

* Initial Capacitor Config and plugins

* Add Android project files and resources

* Add local notification scheduling for chores

* Add NotificationAccessSnackbar component for handling notification preferences

* Add capacitor-preferences to Android project

* Update notification Snackbar

* Add local notification scheduling for chores

* Add ionic.config.json file for custom project configuration

* chore: Add environment variables for production deployment

* Add Support for IOS, pass notificaiton token(push notifications)

* Add Capacitor Device support and refactor notification handling

* Refactor GoogleAuth client IDs to use environment variables

* Remove google-services.json to enhance security by eliminating sensitive data from the repository

* Remove environment files to enhance security by eliminating sensitive data from the repository

* Rename project from fe-template to Donetick in ionic.config.json

* Remove GoogleService-Info.plist and Info.plist to enhance security by eliminating sensitive data from the repository

---------

Co-authored-by: Mo Tarbin <mohamad@Mos-MacBook-Pro.local>
This commit is contained in:
Mohamad Tarbin 2024-12-26 02:13:47 -05:00 committed by GitHub
parent 1e7b47e783
commit bcd32a8616
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
130 changed files with 6699 additions and 880 deletions

View file

@ -1,21 +1,55 @@
import Cookies from 'js-cookie'
import { API_URL } from '../Config'
import { login, RefreshToken } from './Fetcher'
import { Preferences } from '@capacitor/preferences'
class ApiManager {
constructor(){
this.customServerURL = API_URL
this.initialized = false
}
async init(){
if(this.initialized){
return
}
const { value: serverURL } = await Preferences.get({ key: 'customServerUrl' });
this.customServerURL = serverURL || this.apiURL
this.initialized = true
}
getApiURL(){
return this.customServerURL
}
updateApiURL(url){
this.customServerURL = url
}
}
export const apiManager = new ApiManager();
export function Fetch(url, options) {
if (!isTokenValid()) {
console.log('FETCH: Token is not valid')
console.log(localStorage.getItem('ca_token'))
// store current location in cookie
Cookies.set('ca_redirect', window.location.pathname)
Cookies.set('ca_redirect', window.location.pathname);
// Assuming you have a function isTokenValid() that checks token validity
window.location.href = '/login' // Redirect to login page
window.location.href = '/login'; // Redirect to login page
// return Promise.reject("Token is not valid");
}
if (!options) {
options = {}
options = {};
}
options.headers = { ...options.headers, ...HEADERS() }
options.headers = { ...options.headers, ...HEADERS() };
return fetch(url, options)
const baseURL = apiManager.getApiURL();
const fullURL = `${baseURL}${url}`;
return fetch(fullURL, options);
}
export const HEADERS = () => {
@ -47,10 +81,8 @@ export const isTokenValid = () => {
}
export const refreshAccessToken = () => {
fetch(API_URL + '/auth/refresh', {
method: 'GET',
headers: HEADERS(),
}).then(res => {
RefreshToken()
.then(res => {
if (res.status === 200) {
res.json().then(data => {
localStorage.setItem('ca_token', data.token)