diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 8a7a2a4..ff05c53 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -4,7 +4,7 @@ on: push: branches: - main - + pull_request: branches: - main @@ -22,15 +22,10 @@ jobs: id-token: write runs-on: ubuntu-latest steps: - - name: Calculate and Export Target IP - run: | - # 1. Lấy IP hiện tại và tính toán IP đích (đổi octet cuối thành .1) - RUNNER_IP=$(hostname -I | awk '{print $1}') - CALCULATED_IP=$(echo $RUNNER_IP | cut -d'.' -f1-3).1 - - # 2. Đưa vào biến môi trường toàn cục của Job - echo "TARGET_IP=${CALCULATED_IP}" >> $GITHUB_ENV - + - uses: gerlero/apt-install@v1 + with: + packages: docker.io zip + - name: Setup SSH Key run: | mkdir -p ~/.ssh @@ -38,33 +33,17 @@ jobs: echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -p 222 -t ed25519 $TARGET_IP >> ~/.ssh/known_hosts + ssh-keyscan -t ed25519 vps.demonkernel.io.vn >> ~/.ssh/known_hosts - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-node@v6 - with: - node-version: latest - - uses: pnpm/action-setup@v3 with: version: latest run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/package.json') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + cache: true - name: Update dependencies run: pnpm update @@ -80,7 +59,7 @@ jobs: GITEA_USER: ${{ github.actor }} GITEA_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: pnpm release - + - name: Set Version Output id: set_output run: | @@ -92,7 +71,7 @@ jobs: if: gitea.ref == 'refs/heads/main' uses: docker/login-action@v3 with: - registry: git.demonkernel.io.vn + registry: vps.demonkernel.io.vn username: ${{ github.actor }} password: ${{ secrets.ACCESS_TOKEN }} @@ -102,10 +81,10 @@ jobs: run: | # Lowercase Repository REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') - + RAW_VERSION="${{ steps.set_output.outputs.version }}" VERSION_LOWER=$(echo "$RAW_VERSION" | tr '[:upper:]' '[:lower:]') - + echo "repo=$REPO_LOWER" >> $GITHUB_OUTPUT echo "version=$VERSION_LOWER" >> $GITHUB_OUTPUT @@ -116,19 +95,18 @@ jobs: context: . push: true tags: | - git.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:latest - git.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }} + vps.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:latest + vps.demonkernel.io.vn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.version }} - name: Commit & Push Changes - if: gitea.ref == 'refs/heads/main' run: | - if [ -n "$(git status --porcelain)" ]; then + if [ -n "$(git status --porcelain)" ]&& [ "${{ github.ref_name }}" = "main" ]; then git config --global user.name "gitea-actions" git config --global user.email "actions-user@noreply.git.demonkernel.io.vn" REPO_NAME="${{ gitea.repository }}" - git remote set-url origin ssh://git@$TARGET_IP:222/${REPO_NAME}.git + git remote set-url origin ssh://git@vps.demonkernel.io.vn/${REPO_NAME}.git git rm -r --cached . git add . @@ -136,4 +114,3 @@ jobs: git push fi - diff --git a/app/(staff)/staff/schedule/page.tsx b/app/(staff)/staff/schedule/page.tsx index 1cb09da..7fa8850 100644 --- a/app/(staff)/staff/schedule/page.tsx +++ b/app/(staff)/staff/schedule/page.tsx @@ -12,9 +12,18 @@ import Link from "next/link"; import { useState } from "react"; const MONTH_NAMES = [ - "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", - "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", - "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12", + "Tháng 1", + "Tháng 2", + "Tháng 3", + "Tháng 4", + "Tháng 5", + "Tháng 6", + "Tháng 7", + "Tháng 8", + "Tháng 9", + "Tháng 10", + "Tháng 11", + "Tháng 12", ]; function getMonday(d: Date): Date { @@ -172,7 +181,9 @@ export default function StaffSchedulePage() {
- +

@@ -212,7 +223,9 @@ export default function StaffSchedulePage() { Đăng ký ca làm

- {view === "week" ? weekLabel : `${MONTH_NAMES[currentDate.getMonth()]} ${currentDate.getFullYear()}`} + {view === "week" + ? weekLabel + : `${MONTH_NAMES[currentDate.getMonth()]} ${currentDate.getFullYear()}`}

diff --git a/components/molecules/cards/ShiftCard.tsx b/components/molecules/cards/ShiftCard.tsx index 79466e9..479f726 100644 --- a/components/molecules/cards/ShiftCard.tsx +++ b/components/molecules/cards/ShiftCard.tsx @@ -4,7 +4,10 @@ import type { ShiftSlot } from "@/lib/types"; import type { ShiftCardProps } from "./ShiftCard.types"; -const STATUS_STYLES: Record = { +const STATUS_STYLES: Record< + ShiftSlot["status"], + { bg: string; text: string; label: string } +> = { available: { bg: "bg-blue-50 border-blue-200", text: "text-blue-700", @@ -34,7 +37,11 @@ function formatWage(wage: number): string { return wage.toLocaleString("vi-VN"); } -export default function ShiftCard({ shift, compact = false, onClick }: ShiftCardProps) { +export default function ShiftCard({ + shift, + compact = false, + onClick, +}: ShiftCardProps) { const style = STATUS_STYLES[shift.status]; if (compact) { @@ -86,7 +93,7 @@ export default function ShiftCard({ shift, compact = false, onClick }: ShiftCard {shift.registeredStaff.length > 0 && (
-

+

Nhân viên ({shift.registeredStaff.length}/{shift.maxStaff})

diff --git a/components/organisms/shift-schedule/MobileShiftView.tsx b/components/organisms/shift-schedule/MobileShiftView.tsx index efcb87a..e3b9b44 100644 --- a/components/organisms/shift-schedule/MobileShiftView.tsx +++ b/components/organisms/shift-schedule/MobileShiftView.tsx @@ -26,14 +26,27 @@ function isToday(d: Date): boolean { } const MONTH_NAMES = [ - "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", - "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", - "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12", + "Tháng 1", + "Tháng 2", + "Tháng 3", + "Tháng 4", + "Tháng 5", + "Tháng 6", + "Tháng 7", + "Tháng 8", + "Tháng 9", + "Tháng 10", + "Tháng 11", + "Tháng 12", ]; -export default function MobileShiftView({ onShiftClick }: MobileShiftViewProps) { +export default function MobileShiftView({ + onShiftClick, +}: MobileShiftViewProps) { const { currentDate, shifts, goToNextMonth, goToPrevMonth } = useShift(); - const [selectedDate, setSelectedDate] = useState(formatDateISO(new Date(2026, 3, 10))); + const [selectedDate, setSelectedDate] = useState( + formatDateISO(new Date(2026, 3, 10)), + ); const calendarDays = useMemo(() => { const year = currentDate.getFullYear(); @@ -57,9 +70,12 @@ export default function MobileShiftView({ onShiftClick }: MobileShiftViewProps) const dateStr = formatDateISO(date); const dayShifts = shifts.filter((s) => s.date === dateStr); const dots: string[] = []; - if (dayShifts.some((s) => s.status === "available")) dots.push("bg-amber-400"); - if (dayShifts.some((s) => s.status === "registered")) dots.push("bg-green-500"); - if (dayShifts.some((s) => s.status === "approved_leave")) dots.push("bg-purple-400"); + if (dayShifts.some((s) => s.status === "available")) + dots.push("bg-amber-400"); + if (dayShifts.some((s) => s.status === "registered")) + dots.push("bg-green-500"); + if (dayShifts.some((s) => s.status === "approved_leave")) + dots.push("bg-purple-400"); if (dayShifts.some((s) => s.status === "absent")) dots.push("bg-red-400"); return dots; }; @@ -85,7 +101,7 @@ export default function MobileShiftView({ onShiftClick }: MobileShiftViewProps) > -

+

{MONTH_NAMES[currentDate.getMonth()]} {currentDate.getFullYear()}

- )} + {!isRegistered && + !isFull && + shift.status !== "approved_leave" && + shift.status !== "absent" && ( + + )} {isRegistered && ( @@ -133,19 +160,30 @@ export default function WeeklySchedule({
{DEPARTMENTS.map((dept) => { - const deptShifts = getShiftsForDate(selectedDateStr).filter((s) => s.department === dept.id); + const deptShifts = getShiftsForDate(selectedDateStr).filter( + (s) => s.department === dept.id, + ); if (deptShifts.length === 0 && !onCreateShift) return null; return ( -
+
- + {dept.name}
{deptShifts.map((shift) => ( - + ))} {onCreateShift && (