Compare commits

...

2 Commits

Author SHA1 Message Date
5bfbe6a172 feat: add deployment workflow for application using Docker
Some checks failed
Deploy Application / deploy (push) Failing after 1m26s
Test runner / check-runner (push) Successful in 3s
2026-01-06 21:28:18 +01:00
356c1b3295 fix: update attendance month handling to use lastMonths and correct month indexing 2026-01-06 21:28:18 +01:00
5 changed files with 47 additions and 11 deletions

View File

@@ -0,0 +1,19 @@
name: Deploy Application
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and restart Docker containers
run: |
docker-compose down
docker-compose build
docker-compose up -d

View File

@@ -6,13 +6,13 @@
</button> </button>
<div class="dropdown-content"> <div class="dropdown-content">
<button <button
v-for="option in attendanceStore.lastThreeMonth" v-for="option in attendanceStore.lastMonths"
:key="option" :key="`${option.year}-${option.month}`"
@click="select(option)" @click="select(option)"
> >
<span class="button-text"> <span class="button-text">
<span>{{ utils.getMonthName(option) }}</span> <span>{{ utils.getMonthName(option.month) }}</span>
<span>{{ attendanceStore.year }}</span> <span>{{ option.year }}</span>
</span> </span>
</button> </button>
</div> </div>
@@ -30,15 +30,13 @@ const showMenu = ref(false)
const dropdownRef = ref(null) const dropdownRef = ref(null)
const loading = ref(false) const loading = ref(false)
const select = async (newMonth) => { const select = async (option) => {
// console.log('newMonth: ', newMonth) // console.log('newMonth: ', newMonth)
showMenu.value = false showMenu.value = false
loading.value = true loading.value = true
const year = attendanceStore.year
try { try {
const response = await getData(year, newMonth) // przykładowa data const response = await getData(option.year, option.month) // przykładowa data
attendanceStore.loadFromResponse(response) attendanceStore.loadFromResponse(response)
} catch (error) { } catch (error) {
error.value = 'Błąd pobierania danych.' error.value = 'Błąd pobierania danych.'

View File

@@ -12,7 +12,8 @@ export const useAttendanceStore = defineStore('attendanceStore', () => {
const days = ref([]) const days = ref([])
// const lastThreeMonth = ['lipiec', 'czerwiec', 'maj'] // const lastThreeMonth = ['lipiec', 'czerwiec', 'maj']
const lastThreeMonth = utils.getLastMonths(new Date().getMonth() + 1, 5) // const lastMonths = ref(utils.getLastMonthsWithYear(5))
const lastMonths = utils.getLastMonthsWithYear(5)
const sumOfHours = computed(() => days.value[days.value.length - 1]?.accumulatedHours || 0) const sumOfHours = computed(() => days.value[days.value.length - 1]?.accumulatedHours || 0)
const workedHours = computed(() => sumOfHours.value - holidayHours.value - sickHours.value) const workedHours = computed(() => sumOfHours.value - holidayHours.value - sickHours.value)
const overtimeHours = computed(() => days.value[days.value.length - 1]?.balanceHours || 0) const overtimeHours = computed(() => days.value[days.value.length - 1]?.balanceHours || 0)
@@ -115,7 +116,7 @@ export const useAttendanceStore = defineStore('attendanceStore', () => {
holidayHours, holidayHours,
sickHours, sickHours,
toGoHours, toGoHours,
lastThreeMonth, lastMonths,
// actions // actions
loadFromResponse, loadFromResponse,
updateDay, updateDay,

View File

@@ -253,6 +253,23 @@ function calculateMonthFromDay(startDay, days) {
} }
} }
function getLastMonthsWithYear(count) {
const result = []
const today = new Date()
let year = today.getFullYear()
let month = today.getMonth() // 0-11
for (let i = 0; i < count; i++) {
result.push({ year: year, month: month + 1 })
month--
if (month < 0) {
month = 11
year--
}
}
return result
}
export default { export default {
getDayOfWeek, getDayOfWeek,
extractTimeFromDateString, extractTimeFromDateString,
@@ -267,4 +284,5 @@ export default {
getMonthNumber, getMonthNumber,
getMonthName, getMonthName,
daysOfWeek, daysOfWeek,
getLastMonthsWithYear,
} }

View File

@@ -82,7 +82,7 @@ onMounted(async () => {
loading.value = true loading.value = true
const currentDate = new Date() const currentDate = new Date()
try { try {
const response = await getData(currentDate.getFullYear(), currentDate.getMonth()) const response = await getData(currentDate.getFullYear(), currentDate.getMonth() + 1)
input.value = response input.value = response
attendanceStore.loadFromResponse(response) attendanceStore.loadFromResponse(response)
} catch (err) { } catch (err) {