Compare commits

..

26 commits

Author SHA1 Message Date
3a23f60488 Merge branch 'main' into feature/settings-page 2026-02-07 12:04:11 -05:00
40db6ec877 Merge branch 'feature/settings-page' of https://github.com/Doble-Technologies/ShiftSync-Website into feature/settings-page 2025-12-01 22:55:55 -05:00
941110abc1 Settings add 2025-12-01 22:55:54 -05:00
4ba9e91eee Update 2025-08-09 15:49:15 -04:00
a0bb4bef4a Init API Side 2025-06-23 17:55:42 -04:00
16eb49d41e Merge branch 'main' into feature/settings-page 2025-06-15 22:32:05 -04:00
bb8a672b98 Merge branch 'main' into feature/settings-page 2025-06-12 16:33:18 -04:00
6389eb8d6b Merge branch 'main' into feature/settings-page 2025-06-12 16:25:53 -04:00
4e49222e2b Merge branch 'main' into feature/settings-page 2025-06-12 16:24:08 -04:00
3d274363e7 Merge branch 'main' into feature/settings-page 2025-06-12 16:23:11 -04:00
ec58d344dc Merge branch 'main' into feature/settings-page 2025-06-12 16:19:20 -04:00
e60de19e02 Merge branch 'main' into feature/settings-page 2025-06-12 16:18:22 -04:00
6806cdabfb Merge branch 'main' into feature/settings-page 2025-06-12 16:16:04 -04:00
79c3acb6be Merge branch 'main' into feature/settings-page 2025-06-12 16:12:27 -04:00
0010ba3a4f Merge branch 'main' into feature/settings-page 2025-06-12 16:09:27 -04:00
1b7d1e54e2 Merge branch 'main' into feature/settings-page 2025-06-12 16:07:48 -04:00
1d00dd528f Remove Echo 2025-06-12 15:44:30 -04:00
b0670cc3a3 Update Settings.jsx 2025-06-12 15:41:28 -04:00
f4766ed7e1 Merge branch 'main' into feature/settings-page 2025-06-12 15:41:24 -04:00
bdfe409891 Integrity 1 2025-06-11 10:53:22 -04:00
20c088e9e7 Update Dockerfile 2025-06-11 10:42:19 -04:00
375059e3ee Update Dockerfile 2025-06-11 10:39:55 -04:00
21ac649bba Merge branch 'main' into feature/settings-page 2025-06-11 10:22:36 -04:00
3a7a6d3e2c Update package.json 2025-06-11 10:22:31 -04:00
fa56c3a785 Update docker-compose.yaml 2025-06-10 23:17:33 -04:00
49c5e4026c Update docker-compose.yaml 2025-06-10 23:10:05 -04:00
28 changed files with 2822 additions and 4149 deletions

View file

@ -9,8 +9,6 @@ on:
- reopened
- synchronize
- ready_for_review
paths:
- api/**
push:
branches:
- main
@ -68,10 +66,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }}
TEAMCITY_API_ID: ${{ secrets.TEAMCITY_API_ID }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }}
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
permissions:
contents: read
packages: write
@ -92,10 +88,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }}
TEAMCITY_API_ID: ${{ secrets.TEAMCITY_API_ID }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }}
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
permissions:
contents: read
packages: write

View file

@ -22,10 +22,8 @@ on:
DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {}
TEST: {}
TEAMCITY_API_ID: {}
TEAMCITY_URL: {}
TEAMCITY_USERNAME: {}
TEAMCITY_PASSWORD: {}
COOLIFY_WEBHOOK_API: {}
COOLIFY_TOKEN: {}
jobs:
check-inputs:
runs-on: 'ubuntu-latest'
@ -33,29 +31,17 @@ jobs:
steps:
- name: Check secrets present
run: |
if [[ -z "${{ secrets.TEAMCITY_API_ID }}" ]]; then
echo "TEAMCITY_API_ID secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then
echo "COOLIFY_WEBHOOK_API secret is empty or missing"
exit 1
else
echo "TEAMCITY_API_ID secret is set"
echo "COOLIFY_WEBHOOK_API secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then
echo "TEAMCITY_URL secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "COOLIFY_TOKEN secret is empty or missing"
exit 1
else
echo "TEAMCITY_URL secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then
echo "TEAMCITY_USERNAME secret is empty or missing"
exit 1
else
echo "TEAMCITY_USERNAME secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then
echo "TEAMCITY_PASSWORD secret is empty or missing"
exit 1
else
echo "TEAMCITY_PASSWORD secret is set"
echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing"
@ -102,12 +88,7 @@ jobs:
contents: read
packages: write
steps:
- name: Deploy to Team City
- name: Deploy to Coolify
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_API_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null
curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

View file

@ -22,10 +22,8 @@ on:
DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {}
TEST: {}
TEAMCITY_API_ID: {}
TEAMCITY_URL: {}
TEAMCITY_USERNAME: {}
TEAMCITY_PASSWORD: {}
COOLIFY_WEBHOOK_API: {}
COOLIFY_TOKEN: {}
jobs:
check-inputs:
runs-on: 'ubuntu-latest'
@ -33,29 +31,17 @@ jobs:
steps:
- name: Check secrets present
run: |
if [[ -z "${{ secrets.TEAMCITY_API_ID }}" ]]; then
echo "TEAMCITY_API_ID secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then
echo "COOLIFY_WEBHOOK_API secret is empty or missing"
exit 1
else
echo "TEAMCITY_API_ID secret is set"
echo "COOLIFY_WEBHOOK_API secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then
echo "TEAMCITY_URL secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "COOLIFY_TOKEN secret is empty or missing"
exit 1
else
echo "TEAMCITY_URL secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then
echo "TEAMCITY_USERNAME secret is empty or missing"
exit 1
else
echo "TEAMCITY_USERNAME secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then
echo "TEAMCITY_PASSWORD secret is empty or missing"
exit 1
else
echo "TEAMCITY_PASSWORD secret is set"
echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing"
@ -102,10 +88,7 @@ jobs:
contents: read
packages: write
steps:
- name: Deploy to Team City
- name: Deploy to Coolify
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_API_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null
curl '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

View file

@ -11,7 +11,7 @@ jobs:
permissions:
contents: read
pull-requests: write
runs-on: 'ubuntu-latest'
runs-on: ['self-hosted', 'pi']
steps:
- uses: TimonVS/pr-labeler-action@v5
with:

View file

@ -9,8 +9,6 @@ on:
- reopened
- synchronize
- ready_for_review
paths:
- web/**
push:
branches:
- main
@ -18,7 +16,7 @@ on:
- web/**
jobs:
determine-workflow:
runs-on: 'ubuntu-latest'
runs-on: ['self-hosted','pi']
outputs:
workflow_type: ${{ steps.workflow.outputs.workflow_type }}
workflow_envs: ${{ steps.workflow.outputs.workflow_envs }}
@ -68,10 +66,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }}
TEAMCITY_WEB_ID: ${{ secrets.TEAMCITY_WEB_ID }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }}
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
permissions:
contents: read
packages: write
@ -92,10 +88,8 @@ jobs:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
TEST: ${{ secrets.TEST }}
TEAMCITY_WEB_ID: ${{ secrets.TEAMCITY_WEB_ID }}
TEAMCITY_URL: ${{ secrets.TEAMCITY_URL }}
TEAMCITY_USERNAME: ${{ secrets.TEAMCITY_USERNAME }}
TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }}
COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }}
COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }}
permissions:
contents: read
packages: write

View file

@ -22,10 +22,8 @@ on:
DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {}
TEST: {}
TEAMCITY_WEB_ID: {}
TEAMCITY_URL: {}
TEAMCITY_USERNAME: {}
TEAMCITY_PASSWORD: {}
COOLIFY_WEBHOOK_WEB: {}
COOLIFY_TOKEN: {}
jobs:
check-inputs:
runs-on: 'ubuntu-latest'
@ -33,29 +31,17 @@ jobs:
steps:
- name: Check secrets present
run: |
if [[ -z "${{ secrets.TEAMCITY_WEB_ID }}" ]]; then
echo "TEAMCITY_WEB_ID secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then
echo "COOLIFY_WEBHOOK_WEB secret is empty or missing"
exit 1
else
echo "TEAMCITY_WEB_ID secret is set"
echo "COOLIFY_WEBHOOK_WEB secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then
echo "TEAMCITY_URL secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "COOLIFY_TOKEN secret is empty or missing"
exit 1
else
echo "TEAMCITY_URL secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then
echo "TEAMCITY_USERNAME secret is empty or missing"
exit 1
else
echo "TEAMCITY_USERNAME secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then
echo "TEAMCITY_PASSWORD secret is empty or missing"
exit 1
else
echo "TEAMCITY_PASSWORD secret is set"
echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing"
@ -102,10 +88,7 @@ jobs:
contents: read
packages: write
steps:
- name: Deploy to Team City
- name: Deploy to Coolify
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_WEB_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null
curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

View file

@ -22,10 +22,8 @@ on:
DOCKERHUB_USER: {}
DOCKERHUB_TOKEN: {}
TEST: {}
TEAMCITY_WEB_ID: {}
TEAMCITY_URL: {}
TEAMCITY_USERNAME: {}
TEAMCITY_PASSWORD: {}
COOLIFY_WEBHOOK_WEB: {}
COOLIFY_TOKEN: {}
jobs:
check-inputs:
runs-on: 'ubuntu-latest'
@ -33,29 +31,17 @@ jobs:
steps:
- name: Check secrets present
run: |
if [[ -z "${{ secrets.TEAMCITY_WEB_ID }}" ]]; then
echo "TEAMCITY_WEB_ID secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then
echo "COOLIFY_WEBHOOK_WEB secret is empty or missing"
exit 1
else
echo "TEAMCITY_WEB_ID secret is set"
echo "COOLIFY_WEBHOOK_WEB secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_URL }}" ]]; then
echo "TEAMCITY_URL secret is empty or missing"
if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then
echo "COOLIFY_TOKEN secret is empty or missing"
exit 1
else
echo "TEAMCITY_URL secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_USERNAME }}" ]]; then
echo "TEAMCITY_USERNAME secret is empty or missing"
exit 1
else
echo "TEAMCITY_USERNAME secret is set"
fi
if [[ -z "${{ secrets.TEAMCITY_PASSWORD }}" ]]; then
echo "TEAMCITY_PASSWORD secret is empty or missing"
exit 1
else
echo "TEAMCITY_PASSWORD secret is set"
echo "COOLIFY_TOKEN secret is set"
fi
if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then
echo "DOCKERHUB_USER secret is empty or missing"
@ -102,10 +88,7 @@ jobs:
contents: read
packages: write
steps:
- name: Deploy to Team City
- name: Deploy to Coolify
run: |
curl -u ${{ secrets.TEAMCITY_USERNAME }}:${{ secrets.TEAMCITY_PASSWORD }} \
-X POST \
-H "Content-Type: application/json" \
-d '{"buildType": {"id": "${{ secrets.TEAMCITY_WEB_ID }}"}}' \
"${{ secrets.TEAMCITY_URL }}/httpAuth/app/rest/buildQueue" > /dev/null
curl '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'

View file

@ -4,7 +4,7 @@ WORKDIR /app
COPY ./package*.json ./
RUN npm ci
RUN npm cache clean --force && npm install --no-audit --no-fund
COPY . ./

1403
api/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "shiftsync-website-api",
"version": "1.0.11",
"version": "1.0.1",
"private": true,
"type": "module",
"scripts": {

6
api/router/rest/index.js Normal file
View file

@ -0,0 +1,6 @@
import express from 'express';
import { userDataRouter } from './userData/index.js';
export const restRouter = express.Router();
restRouter.use('/userData', userDataRouter);

View file

@ -0,0 +1,17 @@
import express from 'express';
import { databaseServices } from '../../../services/index.js';
export const userDataRouter = express.Router();
userDataRouter.get('/', async (req, res) => {
let data;
try {
data = await databaseServices.getUsers(req.query);
res.status(200);
} catch (err) {
data = { Error: err?.message };
res.status(500);
} finally {
res.send(data);
}
})

6
api/router/routes.js Normal file
View file

@ -0,0 +1,6 @@
import express from 'express';
import { restRouter } from './rest/index.js';
export const routes = express.Router();
routes.use('/rest', restRouter);

View file

@ -1,7 +1,6 @@
import express from 'express';
import cors from 'cors';
import dotenv from 'dotenv';
import fs from 'fs/promises';
import { medicationRouter } from './services/medications/index.js';
import { shiftsRouter } from './services/shifts/index.js';
import { shiftRunQuery } from './services/shiftConnection.js';
@ -46,12 +45,9 @@ app.get('/api/db-health', async (req, res) => {
res.status(500).json({ connected: false, error: err.message });
}
});
app.get('/api/version', async (req, res) => {
try {
const packageData = await fs.readFile('./package.json', 'utf8');
const pkg = JSON.parse(packageData);
res.json(pkg.version);
res.json('1.0.1');
} catch (err) {
console.error(err);
res.status(500).json({ connected: false, error: err.message });

View file

@ -0,0 +1,27 @@
import { Pool } from 'pg';
import 'dotenv/config';
const poolCreds = {
host: process.env.POSTGRES_HOST,
database: process.env.POSTGRES_DB,
port: process.env.POSTGRES_PORT,
user: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
ssl:
process.env.APP_ENV === 'local'
? null
: { require: true, rejectUnauthorized }
};
const pool = new Pool(poolCreds);
export const runQuery = async (query, params = []) => {
const client = await pool.connect();
try {
const pgQueryResponse = await client.query(query, params);
return pgQueryResponse?.rows || [];
} finally {
client.release();
}
}

View file

@ -0,0 +1,14 @@
import express from 'express';
const router = express.Router();
// GET /api/departments
router.get('/', (req, res) => {
res.json([{ id: 1, name: 'Fire Department' }]);
});
// POST /api/departments
router.post('/', (req, res) => {
res.status(201).json({ message: 'Department created' });
});
export default router;

View file

@ -0,0 +1,15 @@
import { runQuery } from '../connection.js';
const getUsers = async (args) => {
try {
const dataResp = await runQuery('SELECT * FROM users');
return dataResp;
} catch (err) {
console.log('GET USERS ERROR: ', err);
throw err;
}
};
export const userDataOperations = {
getUsers
}

View file

@ -0,0 +1,16 @@
import express from 'express';
const router = express.Router();
// GET /api/users
router.get('/', (req, res) => {
res.json([{ id: 1, name: 'John Doe' }]);
});
// POST /api/users
router.post('/', (req, res) => {
res.status(201).json({ message: 'User created' });
});
// Add more routes like PUT, DELETE here later
export default router;

150
package-lock.json generated
View file

@ -90,9 +90,9 @@
}
},
"node_modules/body-parser": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",
"integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz",
"integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
@ -101,7 +101,7 @@
"http-errors": "^2.0.0",
"iconv-lite": "^0.7.0",
"on-finished": "^2.4.1",
"qs": "^6.14.1",
"qs": "^6.14.0",
"raw-body": "^3.0.1",
"type-is": "^2.0.1"
},
@ -273,18 +273,19 @@
"license": "MIT"
},
"node_modules/concurrently": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz",
"integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==",
"version": "9.1.2",
"resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.1.2.tgz",
"integrity": "sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"chalk": "4.1.2",
"rxjs": "7.8.2",
"shell-quote": "1.8.3",
"supports-color": "8.1.1",
"tree-kill": "1.2.2",
"yargs": "17.7.2"
"chalk": "^4.1.2",
"lodash": "^4.17.21",
"rxjs": "^7.8.1",
"shell-quote": "^1.8.1",
"supports-color": "^8.1.1",
"tree-kill": "^1.2.2",
"yargs": "^17.7.2"
},
"bin": {
"conc": "dist/bin/concurrently.js",
@ -298,16 +299,15 @@
}
},
"node_modules/content-disposition": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz",
"integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.0.tgz",
"integrity": "sha512-Au9nRL8VNUut/XSzbQA38+M78dzP4D+eqg3gfJHMIHHYa3bg067xj1KxMUWj+VULbiZMowKngFFbKczUrNJ1mg==",
"license": "MIT",
"engines": {
"node": ">=18"
"dependencies": {
"safe-buffer": "5.2.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
"engines": {
"node": ">= 0.6"
}
},
"node_modules/content-type": {
@ -524,9 +524,9 @@
}
},
"node_modules/finalhandler": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
"integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.0.tgz",
"integrity": "sha512-/t88Ty3d5JWQbWYgaOGCCYfXRwV1+be02WqYYlL6h0lEiUAMPM8o8qKGO01YIkOHzka2up08wvgYD0mDiI+q3Q==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.0",
@ -537,11 +537,7 @@
"statuses": "^2.0.1"
},
"engines": {
"node": ">= 18.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
"node": ">= 0.8"
}
},
"node_modules/forwarded": {
@ -713,9 +709,9 @@
}
},
"node_modules/iconv-lite": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz",
"integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==",
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.0.tgz",
"integrity": "sha512-cf6L2Ds3h57VVmkZe+Pn+5APsT7FpqJtEhhieDCvrE2MK5Qk9MyffgQyuxQTm6BChfeZNtcOLHp9IcWRVcIcBQ==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
@ -812,6 +808,13 @@
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
"license": "MIT"
},
"node_modules/lodash": {
"version": "4.17.23",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
"dev": true,
"license": "MIT"
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
@ -852,19 +855,15 @@
}
},
"node_modules/mime-types": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
"integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz",
"integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==",
"license": "MIT",
"dependencies": {
"mime-db": "^1.54.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
@ -896,9 +895,9 @@
}
},
"node_modules/nodemon": {
"version": "3.1.11",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.11.tgz",
"integrity": "sha512-is96t8F/1//UHAjNPHpbsNY46ELPpftGUoSVNXwUfMk/qdjSylYrWSu1XavVTBOn526kFiOR733ATgNBCQyH0g==",
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
"integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -1009,13 +1008,12 @@
}
},
"node_modules/path-to-regexp": {
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz",
"integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==",
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz",
"integrity": "sha512-TdrF7fW9Rphjq4RjrW0Kp2AW0Ahwu9sRGTkS6bvDi0SCwZlEZYmcfDbEsTz8RVk0EHIS/Vd1bv3JhG+1xZuAyQ==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
"engines": {
"node": ">=16"
}
},
"node_modules/picomatch": {
@ -1139,6 +1137,26 @@
"tslib": "^2.1.0"
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
@ -1146,9 +1164,9 @@
"license": "MIT"
},
"node_modules/semver": {
"version": "7.7.3",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"dev": true,
"license": "ISC",
"bin": {
@ -1159,35 +1177,31 @@
}
},
"node_modules/send": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
"integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz",
"integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.3",
"debug": "^4.3.5",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"fresh": "^2.0.0",
"http-errors": "^2.0.1",
"mime-types": "^3.0.2",
"http-errors": "^2.0.0",
"mime-types": "^3.0.1",
"ms": "^2.1.3",
"on-finished": "^2.4.1",
"range-parser": "^1.2.1",
"statuses": "^2.0.2"
"statuses": "^2.0.1"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/serve-static": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",
"integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz",
"integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==",
"license": "MIT",
"dependencies": {
"encodeurl": "^2.0.0",
@ -1197,10 +1211,6 @@
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/setprototypeof": {

View file

@ -4,7 +4,7 @@ WORKDIR /app
COPY ./package*.json ./
RUN npm ci
RUN npm cache clean --force && npm install --no-audit --no-fund
COPY . ./

View file

@ -194,7 +194,8 @@ export const TransferBox = ({ fields, leftGroup, rightGroup, onSave, user={} })
</CenterButton>
<CenterButton
onClick={() => {
return onSave(rightItems?.map((item) => { return item?.id }))
onSave(rightItems?.map((item) => { return item?.id }));
setItemSelected({});
}}
color='#00B33C'
buttonEnabled={hasChanges}

View file

@ -5,4 +5,6 @@ export const useLocalStore = create((set) => ({
setUser: (user) => set({ user }),
department: null,
setDepartment: (department) => set({ department }),
access: null,
setAccess: (access) => set({ access }),
}));

93
web/package-lock.json generated
View file

@ -1,18 +1,18 @@
{
"name": "shiftsync-website-web",
"version": "1.0.8",
"version": "1.0.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "shiftsync-website-web",
"version": "1.0.8",
"version": "1.0.5",
"dependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@mui/icons-material": "^7.1.0",
"@mui/material": "^7.1.0",
"axios": "^1.13.2",
"axios": "^1.10.0",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router-dom": "^7.6.0",
@ -28,7 +28,7 @@
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"vite": "^6.4.1"
"vite": "^6.3.5"
}
},
"node_modules/@ampproject/remapping": {
@ -1045,13 +1045,13 @@
}
},
"node_modules/@eslint/plugin-kit": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz",
"integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==",
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.2.tgz",
"integrity": "sha512-4SaFZCNfJqvk/kenHpI8xvN42DMaoycy4PzKc5otHxRswww1kAt82OlBuwRVLofCACCTZEcla2Ydxv8scMXaTg==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
"@eslint/core": "^0.15.2",
"@eslint/core": "^0.15.0",
"levn": "^0.4.1"
},
"engines": {
@ -1059,9 +1059,9 @@
}
},
"node_modules/@eslint/plugin-kit/node_modules/@eslint/core": {
"version": "0.15.2",
"resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz",
"integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==",
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.0.tgz",
"integrity": "sha512-b7ePw78tEWWkpgZCDYkbqDOP8dmM6qe+AOC6iuJqlq1R/0ahMAeH3qynpnqKFGkMltrp44ohV4ubGyvLX28tzw==",
"dev": true,
"license": "Apache-2.0",
"dependencies": {
@ -1905,13 +1905,13 @@
"license": "MIT"
},
"node_modules/axios": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz",
"integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==",
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
"integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.4",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
@ -2096,16 +2096,12 @@
"license": "MIT"
},
"node_modules/cookie": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/cosmiconfig": {
@ -2627,9 +2623,9 @@
}
},
"node_modules/form-data": {
"version": "4.0.5",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
"integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==",
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz",
"integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==",
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
@ -2909,9 +2905,9 @@
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -3383,9 +3379,9 @@
}
},
"node_modules/react-router": {
"version": "7.12.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.12.0.tgz",
"integrity": "sha512-kTPDYPFzDVGIIGNLS5VJykK0HfHLY5MF3b+xj0/tTyNYL1gF1qs7u67Z9jEhQk2sQ98SUaHxlG31g1JtF7IfVw==",
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.6.2.tgz",
"integrity": "sha512-U7Nv3y+bMimgWjhlT5CRdzHPu2/KVmqPwKUCChW8en5P3znxUqwlYFlbmyj8Rgp1SF6zs5X4+77kBVknkg6a0w==",
"license": "MIT",
"dependencies": {
"cookie": "^1.0.1",
@ -3405,12 +3401,12 @@
}
},
"node_modules/react-router-dom": {
"version": "7.12.0",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.12.0.tgz",
"integrity": "sha512-pfO9fiBcpEfX4Tx+iTYKDtPbrSLLCbwJ5EqP+SPYQu1VYCXdy79GSj0wttR0U4cikVdlImZuEZ/9ZNCgoaxwBA==",
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.6.2.tgz",
"integrity": "sha512-Q8zb6VlTbdYKK5JJBLQEN06oTUa/RAbG/oQS1auK1I0TbJOXktqm+QENEVJU6QvWynlXPRBXI3fiOQcSEA78rA==",
"license": "MIT",
"dependencies": {
"react-router": "7.12.0"
"react-router": "7.6.2"
},
"engines": {
"node": ">=20.0.0"
@ -3529,9 +3525,9 @@
}
},
"node_modules/set-cookie-parser": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
"integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==",
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz",
"integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==",
"license": "MIT"
},
"node_modules/shebang-command": {
@ -3692,9 +3688,9 @@
}
},
"node_modules/vite": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.4.1.tgz",
"integrity": "sha512-+Oxm7q9hDoLMyJOYfUYBuHQo+dkAloi33apOPP56pzj+vsdJDzr+j1NISE5pyaAuKL4A3UD34qd0lx5+kfKp2g==",
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -3799,6 +3795,21 @@
"dev": true,
"license": "ISC"
},
"node_modules/yaml": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz",
"integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==",
"dev": true,
"license": "ISC",
"optional": true,
"peer": true,
"bin": {
"yaml": "bin.mjs"
},
"engines": {
"node": ">= 14.6"
}
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

View file

@ -1,7 +1,7 @@
{
"name": "shiftsync-website-web",
"version": "1.0.10",
"private": true,
"version": "1.0.5",
"type": "module",
"scripts": {
"local": "vite",

View file

@ -18,7 +18,6 @@ export const Home = () => {
<h1>Home Page</h1>
<Link to="/settings">Go to Settings</Link>
<p>Version: {pkg.version}</p>
<p>This site does nothing</p>
</div>
);
};

View file

@ -136,6 +136,7 @@ const InnerCardRowLabel = styled('label')`
width: 60%;
padding-right: 10px;
font-size: 14px;
align-items: center;
`;
const InnerCardRowInput = styled('input')`
@ -152,6 +153,7 @@ const InnerCardRadioInput = styled('input')`
const InnerCardRadioLabel = styled('label')`
font-size: 14px;
padding-left: 5px;
align-items: center;
`;
const InnerCardRowRadioDiv = styled('div')`
@ -451,7 +453,9 @@ export const Settings = () => {
fields={field}
leftGroup={department[field?.origList]}
rightGroup={department[field?.id]}
onSave={(t) => console.log(t)}
onSave={(t) => {
return onSubmit({ [field.id]: t });
}}
/>
}
return field?.type !== 'header' && (

View file

@ -3,7 +3,7 @@ import { Routes, Route } from 'react-router-dom';
import { Home, Profile, Schedule, Settings } from '@src/pages';
import { Shell } from '@components';
import { useLocalStore } from '@components';
import axios from "axios";
import { fetchAPI } from './axios.js';
const dept = {
id: 1,
@ -31,6 +31,7 @@ const users = [
first_name: 'ShiftSync-Administrator',
last_name: 'Test-User',
email: 'testuserA@shift-sync.com',
accessLevel: 150,
is_ss_admin: false
},
{
@ -38,6 +39,7 @@ const users = [
first_name: 'ShiftSync-Manager',
last_name: 'Test-User',
email: 'testuserM@shift-sync.com',
accessLevel: 100,
is_ss_admin: false
},
{
@ -45,6 +47,7 @@ const users = [
first_name: 'ShiftSync-Scheduler',
last_name: 'Test-User',
email: 'testuserS@shift-sync.com',
accessLevel: 50,
is_ss_admin: false
},
{
@ -52,65 +55,66 @@ const users = [
first_name: 'ShiftSync-User',
last_name: 'Test-User',
email: 'testuserU@shift-sync.com',
accessLevel: 1,
is_ss_admin: false
},
]
];
const AppRouter = () => {
const { user, setUser, setDepartment } = useLocalStore();
const [userChanged, setUserChanged] = useState(false);
const isDev = true; // change for it.
const fetchAPI = async () => {
const location = window.location;
const uri = `${location?.protocol}//${location.hostname}/api`;
const response = await axios.get(uri);
console.log(response.data.fruits);
};
useEffect(() => {
const init = async () => {
const localVersion = localStorage.getItem("APP_VERSION");
const currentVersion = window.APP_VERSION;
if (localVersion && localVersion !== currentVersion) {
console.log("Version changed, forcing reload");
localStorage.setItem("APP_VERSION", currentVersion);
window.location.reload(true); // force full page reload
window.location.reload(true);
return;
} else {
localStorage.setItem("APP_VERSION", currentVersion);
}
fetchAPI();
// await call for getting the count of employees and any other calls to db.
const data = await fetchAPI('userData', 'get');
console.log('data:', data);
// TODO: Replace this with real data from your API
// const users = data?.users || []; // Example fix
// const dept = data?.dept || {}; // Example fix
const employee_count = 1;
const subs_expiration = '10/22/2025';
setUser({
...users[0],
scheduler: dept?.schedulers?.includes(1),
manager: dept?.managers?.includes(1),
administrator: dept?.administrators?.includes(1)
});
const newAdministrators = dept?.administrators?.map((admin) => {
const user = users?.find((user) => {
return user?.id === admin;
});
const user = users?.find((user) => user?.id === admin);
return { id: user?.id, value: `${user?.last_name}, ${user?.first_name}` };
});
const newManagers = dept?.managers?.map((manager) => {
const user = users?.find((user) => {
return user?.id === manager;
});
const user = users?.find((user) => user?.id === manager);
return { id: user?.id, value: `${user?.last_name}, ${user?.first_name}` };
});
const newSchedulers = dept?.schedulers?.map((scheduler) => {
const user = users?.find((user) => {
return user?.id === scheduler;
});
return { id: user?.id, value: `${user?.last_name}, ${user?.first_name}` };
});
const newUsers = users?.map((user) => {
const user = users?.find((user) => user?.id === scheduler);
return { id: user?.id, value: `${user?.last_name}, ${user?.first_name}` };
});
const newUsers = users?.map((user) => ({
id: user?.id,
value: `${user?.last_name}, ${user?.first_name}`
}));
setDepartment({
...dept,
users: newUsers,
@ -120,6 +124,9 @@ const AppRouter = () => {
employee_count,
subs_expiration
});
};
init();
}, []);
useEffect(() => {

27
web/src/router/axios.js Normal file
View file

@ -0,0 +1,27 @@
import axios from 'axios';
export const fetchAPI = async (endpoint, type, body = null) => {
const location = window.location;
const url = `${location?.protocol}//${location.hostname}${location?.hostname === 'localhost' ? ':5172' : ''}/api/rest/${endpoint}`;
const requestOptions = {
headers: {
'Content-Type': 'application/json'
}
};
try {
let response;
if (type === 'post') {
response = await axios.post(url, body, requestOptions);
} else if (type === 'get') {
response = await axios.get(url, requestOptions);
} else {
console.warn('No proper type given: ', type);
return;
}
return response.data;
} catch (err) {
console.error('PG Rest Query Error: ', err);
}
};