Add schedule and requests screens with workdays fetching and navigation
This commit is contained in:
@@ -20,6 +20,7 @@ export default function Index() {
|
|||||||
(async () => {
|
(async () => {
|
||||||
const savedEmail = await SecureStore.getItemAsync('email');
|
const savedEmail = await SecureStore.getItemAsync('email');
|
||||||
const savedPassword = await SecureStore.getItemAsync('password');
|
const savedPassword = await SecureStore.getItemAsync('password');
|
||||||
|
console.log('Mentett email:', savedEmail, 'Mentett password:', savedPassword);
|
||||||
if (savedEmail && savedPassword) {
|
if (savedEmail && savedPassword) {
|
||||||
setUsername(savedEmail);
|
setUsername(savedEmail);
|
||||||
setPassword(savedPassword);
|
setPassword(savedPassword);
|
||||||
@@ -69,7 +70,7 @@ export default function Index() {
|
|||||||
ToastAndroid.show('Sikeres automatikus bejelentkezés', ToastAndroid.SHORT);
|
ToastAndroid.show('Sikeres automatikus bejelentkezés', ToastAndroid.SHORT);
|
||||||
} else {
|
} else {
|
||||||
// iOS: custom toast helyett Alert
|
// iOS: custom toast helyett Alert
|
||||||
Alert.alert('Sikeres automatikus bejelentkezés');
|
console.log('Sikeres automatikus bejelentkezés');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
router.replace('/profile');
|
router.replace('/profile');
|
||||||
|
115
app/profile.tsx
115
app/profile.tsx
@@ -1,8 +1,10 @@
|
|||||||
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from '@expo/vector-icons';
|
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from '@expo/vector-icons';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { addDays, addMonths, endOfMonth, endOfWeek, format, getMonth, getYear, isSameDay, startOfMonth, startOfWeek, subMonths } from 'date-fns';
|
||||||
import { useRouter } from 'expo-router';
|
import { useRouter } from 'expo-router';
|
||||||
import * as SecureStore from 'expo-secure-store';
|
import * as SecureStore from 'expo-secure-store';
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||||
|
|
||||||
const PRIMARY = '#A24BFA';
|
const PRIMARY = '#A24BFA';
|
||||||
const BG = '#0c0a0a';
|
const BG = '#0c0a0a';
|
||||||
@@ -17,6 +19,9 @@ export default function Profile() {
|
|||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [userId, setUserId] = useState('');
|
const [userId, setUserId] = useState('');
|
||||||
const [activeTab, setActiveTab] = useState('profile');
|
const [activeTab, setActiveTab] = useState('profile');
|
||||||
|
const [currentMonth, setCurrentMonth] = useState(new Date());
|
||||||
|
const [workdays, setWorkdays] = useState<any[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -30,6 +35,38 @@ export default function Profile() {
|
|||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeTab === 'schedule') {
|
||||||
|
fetchWorkdays();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line
|
||||||
|
}, [currentMonth, activeTab]);
|
||||||
|
|
||||||
|
async function fetchWorkdays() {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const userCookie = await SecureStore.getItemAsync('cookie');
|
||||||
|
const year = getYear(currentMonth);
|
||||||
|
const month = getMonth(currentMonth) + 1;
|
||||||
|
const response = await axios.post(
|
||||||
|
'https://mymenu.mcdonalds.hu/api/UserDataApi/GetWorkDayMonthList',
|
||||||
|
{ Data: { Year: year, Month: month } },
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'cookie': userCookie,
|
||||||
|
'origin': 'https://mymenu.mcdonalds.hu',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setWorkdays(response.data.data.Data || []);
|
||||||
|
} catch (e) {
|
||||||
|
setWorkdays([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
await SecureStore.deleteItemAsync('cookie');
|
await SecureStore.deleteItemAsync('cookie');
|
||||||
await SecureStore.deleteItemAsync('userId');
|
await SecureStore.deleteItemAsync('userId');
|
||||||
@@ -39,6 +76,73 @@ export default function Profile() {
|
|||||||
router.replace('/');
|
router.replace('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderCalendar() {
|
||||||
|
const monthStart = startOfMonth(currentMonth);
|
||||||
|
const monthEnd = endOfMonth(monthStart);
|
||||||
|
const startDate = startOfWeek(monthStart, { weekStartsOn: 1 });
|
||||||
|
const endDate = endOfWeek(monthEnd, { weekStartsOn: 1 });
|
||||||
|
const today = new Date();
|
||||||
|
const rows = [];
|
||||||
|
let days = [];
|
||||||
|
let day = startDate;
|
||||||
|
let formattedDate = '';
|
||||||
|
while (day <= endDate) {
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
formattedDate = format(day, 'yyyy-MM-dd');
|
||||||
|
const wd = workdays.find(w => w.WorkDay?.slice(0, 10) === formattedDate);
|
||||||
|
let bg = 'rgba(24,20,28,0.7)';
|
||||||
|
let color = '#fff';
|
||||||
|
let borderWidth = 0;
|
||||||
|
if (isSameDay(day, today)) {
|
||||||
|
borderWidth = 2;
|
||||||
|
color = PRIMARY;
|
||||||
|
}
|
||||||
|
if (wd) {
|
||||||
|
bg = wd.color || 'deepskyblue';
|
||||||
|
color = '#222';
|
||||||
|
}
|
||||||
|
days.push(
|
||||||
|
<View key={day.toString()} style={{ flex: 1, aspectRatio: 1, margin: 2 }}>
|
||||||
|
<View style={{
|
||||||
|
backgroundColor: bg,
|
||||||
|
borderRadius: 8,
|
||||||
|
borderWidth,
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flex: 1,
|
||||||
|
}}>
|
||||||
|
<Text style={{ color, fontWeight: isSameDay(day, today) ? 'bold' : 'normal' }}>{format(day, 'd')}</Text>
|
||||||
|
{wd && <Text style={{ color, fontSize: 10 }}>{wd.text}</Text>}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
day = addDays(day, 1);
|
||||||
|
}
|
||||||
|
rows.push(<View key={day.toString()} style={{ flexDirection: 'row' }}>{days}</View>);
|
||||||
|
days = [];
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||||
|
<TouchableOpacity onPress={() => setCurrentMonth(subMonths(currentMonth, 1))}><Ionicons name="chevron-back" size={28} color="#fff" /></TouchableOpacity>
|
||||||
|
<Text style={{ color: '#fff', fontSize: 18, fontWeight: 'bold' }}>{format(currentMonth, 'yyyy. MMMM')}</Text>
|
||||||
|
<TouchableOpacity onPress={() => setCurrentMonth(addMonths(currentMonth, 1))}><Ionicons name="chevron-forward" size={28} color="#fff" /></TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
<View style={{ flexDirection: 'row', marginBottom: 4 }}>
|
||||||
|
{["H", "K", "Sz", "Cs", "P", "Szo", "V"].map(d => (
|
||||||
|
<Text key={d} style={{ flex: 1, color: '#bdbdbd', textAlign: 'center', fontWeight: 'bold' }}>{d}</Text>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
{loading ? (
|
||||||
|
<Text style={{ color: '#fff', textAlign: 'center', marginTop: 24 }}>Betöltés…</Text>
|
||||||
|
) : (
|
||||||
|
<View>{rows}</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function renderContent() {
|
function renderContent() {
|
||||||
if (activeTab === 'profile') {
|
if (activeTab === 'profile') {
|
||||||
return (
|
return (
|
||||||
@@ -56,9 +160,12 @@ export default function Profile() {
|
|||||||
);
|
);
|
||||||
} else if (activeTab === 'schedule') {
|
} else if (activeTab === 'schedule') {
|
||||||
return (
|
return (
|
||||||
<View style={styles.card}>
|
<ScrollView style={{ width: '100%' }} contentContainerStyle={{ alignItems: 'center' }}>
|
||||||
<Text style={styles.value}>Beosztás funkció hamarosan…</Text>
|
<View style={styles.card}>
|
||||||
</View>
|
<Text style={styles.label}>Beosztás naptár</Text>
|
||||||
|
{renderCalendar()}
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
);
|
);
|
||||||
} else if (activeTab === 'requests') {
|
} else if (activeTab === 'requests') {
|
||||||
return (
|
return (
|
||||||
|
98
app/requests.tsx
Normal file
98
app/requests.tsx
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from '@expo/vector-icons';
|
||||||
|
import { useRouter } from 'expo-router';
|
||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||||
|
|
||||||
|
const PRIMARY = '#A24BFA';
|
||||||
|
const BG = '#0c0a0a';
|
||||||
|
|
||||||
|
export default function Requests() {
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('Requests oldal betöltve');
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<View style={styles.card}>
|
||||||
|
<Text style={styles.label}>Kérelmek funkció hamarosan…</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.navBar}>
|
||||||
|
<NavBar activeTab="requests" />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavBar({ activeTab }: { activeTab: string }) {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<View style={styles.navBar}>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.replace('/profile')}>
|
||||||
|
<MaterialIcons name="person" size={28} color={activeTab === 'profile' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'profile' ? PRIMARY : '#bdbdbd' }]}>Profilom</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.replace('/schedule')}>
|
||||||
|
<MaterialCommunityIcons name="calendar-month" size={28} color={activeTab === 'schedule' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'schedule' ? PRIMARY : '#bdbdbd' }]}>Beosztás</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.replace('/requests')}>
|
||||||
|
<Ionicons name="mail" size={28} color={activeTab === 'requests' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'requests' ? PRIMARY : '#bdbdbd' }]}>Kérelmek</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: BG,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
paddingBottom: 64,
|
||||||
|
},
|
||||||
|
card: {
|
||||||
|
backgroundColor: 'rgba(24, 20, 28, 0.95)',
|
||||||
|
borderRadius: 24,
|
||||||
|
padding: 32,
|
||||||
|
width: '90%',
|
||||||
|
maxWidth: 400,
|
||||||
|
shadowColor: '#000',
|
||||||
|
shadowOpacity: 0.3,
|
||||||
|
shadowRadius: 24,
|
||||||
|
shadowOffset: { width: 0, height: 8 },
|
||||||
|
elevation: 8,
|
||||||
|
marginBottom: 32,
|
||||||
|
marginTop: 32,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
color: '#bdbdbd',
|
||||||
|
fontSize: 16,
|
||||||
|
marginBottom: 16,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
navBar: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-around',
|
||||||
|
alignItems: 'center',
|
||||||
|
backgroundColor: 'rgba(24, 20, 28, 0.98)',
|
||||||
|
borderTopWidth: 1,
|
||||||
|
borderTopColor: '#222',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: 64,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
},
|
||||||
|
navItem: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
navLabel: {
|
||||||
|
fontSize: 13,
|
||||||
|
marginTop: 2,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
|
});
|
239
app/schedule.tsx
Normal file
239
app/schedule.tsx
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
// Csak a név=érték részt tartjuk meg a cookie stringből
|
||||||
|
function extractCookie(cookieStr: string) {
|
||||||
|
return cookieStr.split(';')[0];
|
||||||
|
}
|
||||||
|
import { Ionicons, MaterialCommunityIcons, MaterialIcons } from '@expo/vector-icons';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { addDays, addMonths, endOfMonth, endOfWeek, format, getMonth, getYear, isSameDay, startOfMonth, startOfWeek, subMonths } from 'date-fns';
|
||||||
|
import { useRouter } from 'expo-router';
|
||||||
|
import * as SecureStore from 'expo-secure-store';
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
||||||
|
|
||||||
|
const PRIMARY = '#A24BFA';
|
||||||
|
const BG = '#0c0a0a';
|
||||||
|
|
||||||
|
export default function Schedule() {
|
||||||
|
const [currentMonth, setCurrentMonth] = useState(new Date());
|
||||||
|
const [workdays, setWorkdays] = useState<any[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchWorkdays();
|
||||||
|
}, [currentMonth]);
|
||||||
|
|
||||||
|
async function fetchWorkdays() {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const userCookie = await SecureStore.getItemAsync('cookie');
|
||||||
|
const year = getYear(currentMonth);
|
||||||
|
const month = getMonth(currentMonth) + 1;
|
||||||
|
console.log('Lekérdezett hónap:', year, month);
|
||||||
|
console.log('Cookie:', userCookie);
|
||||||
|
if (!userCookie) {
|
||||||
|
console.log('Nincs elmentett cookie, nem vagy bejelentkezve!');
|
||||||
|
setWorkdays([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const response = await axios.post(
|
||||||
|
'https://mymenu.mcdonalds.hu/api/UserDataApi/GetWorkDayMonthList',
|
||||||
|
{ Data: { Year: year, Month: month } },
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'cookie': userCookie,
|
||||||
|
'origin': 'https://mymenu.mcdonalds.hu',
|
||||||
|
},
|
||||||
|
// Axios v1: get full response
|
||||||
|
withCredentials: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// Cookie frissítés, ha van új set-cookie header
|
||||||
|
const setCookieHeader = response.headers && (response.headers['set-cookie'] || response.headers['Set-Cookie']);
|
||||||
|
if (setCookieHeader) {
|
||||||
|
let cookieString = '';
|
||||||
|
if (Array.isArray(setCookieHeader)) {
|
||||||
|
// Ha van .ASPXAUTH, azt mentsük el, különben az elsőt
|
||||||
|
const authCookie = setCookieHeader.find(c => c.startsWith('.ASPXAUTH='));
|
||||||
|
if (authCookie) {
|
||||||
|
cookieString = extractCookie(authCookie);
|
||||||
|
} else {
|
||||||
|
cookieString = extractCookie(setCookieHeader[0]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cookieString = extractCookie(setCookieHeader);
|
||||||
|
}
|
||||||
|
console.log('Frissített cookie:', cookieString);
|
||||||
|
await SecureStore.setItemAsync('cookie', cookieString);
|
||||||
|
}
|
||||||
|
console.log('API teljes válasz:', response.data);
|
||||||
|
if (!response.data || !response.data.data || !response.data.data.Data) {
|
||||||
|
console.log('Nincs beosztás adat a válaszban!');
|
||||||
|
setWorkdays([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setWorkdays(response.data.data.Data);
|
||||||
|
} catch (e) {
|
||||||
|
console.log('Beosztás API hiba:', e);
|
||||||
|
setWorkdays([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderCalendar() {
|
||||||
|
const monthStart = startOfMonth(currentMonth);
|
||||||
|
const monthEnd = endOfMonth(monthStart);
|
||||||
|
const startDate = startOfWeek(monthStart, { weekStartsOn: 1 });
|
||||||
|
const endDate = endOfWeek(monthEnd, { weekStartsOn: 1 });
|
||||||
|
const today = new Date();
|
||||||
|
const rows = [];
|
||||||
|
let days = [];
|
||||||
|
let day = startDate;
|
||||||
|
let formattedDate = '';
|
||||||
|
while (day <= endDate) {
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
formattedDate = format(day, 'yyyy-MM-dd');
|
||||||
|
const wd = workdays.find(w => w.WorkDay?.slice(0, 10) === formattedDate);
|
||||||
|
let bg = 'rgba(24,20,28,0.7)';
|
||||||
|
let color = '#fff';
|
||||||
|
let borderWidth = 0;
|
||||||
|
if (isSameDay(day, today)) {
|
||||||
|
borderWidth = 2;
|
||||||
|
color = PRIMARY;
|
||||||
|
}
|
||||||
|
if (wd) {
|
||||||
|
bg = wd.color || 'deepskyblue';
|
||||||
|
color = '#222';
|
||||||
|
}
|
||||||
|
days.push(
|
||||||
|
<View key={day.toString()} style={{ flex: 1, aspectRatio: 1, margin: 2 }}>
|
||||||
|
<View style={{
|
||||||
|
backgroundColor: bg,
|
||||||
|
borderRadius: 8,
|
||||||
|
borderWidth,
|
||||||
|
borderColor: PRIMARY,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flex: 1,
|
||||||
|
}}>
|
||||||
|
<Text style={{ color, fontWeight: isSameDay(day, today) ? 'bold' : 'normal' }}>{format(day, 'd')}</Text>
|
||||||
|
{wd && <Text style={{ color, fontSize: 10 }}>{wd.text}</Text>}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
day = addDays(day, 1);
|
||||||
|
}
|
||||||
|
rows.push(<View key={day.toString()} style={{ flexDirection: 'row' }}>{days}</View>);
|
||||||
|
days = [];
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
|
||||||
|
<TouchableOpacity onPress={() => setCurrentMonth(subMonths(currentMonth, 1))}><Ionicons name="chevron-back" size={28} color="#fff" /></TouchableOpacity>
|
||||||
|
<Text style={{ color: '#fff', fontSize: 18, fontWeight: 'bold' }}>{format(currentMonth, 'yyyy. MMMM')}</Text>
|
||||||
|
<TouchableOpacity onPress={() => setCurrentMonth(addMonths(currentMonth, 1))}><Ionicons name="chevron-forward" size={28} color="#fff" /></TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
<View style={{ flexDirection: 'row', marginBottom: 4 }}>
|
||||||
|
{["H", "K", "Sz", "Cs", "P", "Szo", "V"].map(d => (
|
||||||
|
<Text key={d} style={{ flex: 1, color: '#bdbdbd', textAlign: 'center', fontWeight: 'bold' }}>{d}</Text>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
{loading ? (
|
||||||
|
<Text style={{ color: '#fff', textAlign: 'center', marginTop: 24 }}>Betöltés…</Text>
|
||||||
|
) : (
|
||||||
|
<View>{rows}</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView style={{ flex: 1, backgroundColor: BG }} contentContainerStyle={{ flexGrow: 1, justifyContent: 'center', alignItems: 'center', minHeight: '100%', paddingBottom: 80 }}>
|
||||||
|
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', width: '100%' }}>
|
||||||
|
<View style={[styles.card, { alignSelf: 'center', marginTop: 48, marginBottom: 48 }]}>
|
||||||
|
<Text style={styles.label}>Beosztás naptár</Text>
|
||||||
|
{/* Hibaüzenet, ha nincs bejelentkezve vagy nincs beosztás */}
|
||||||
|
{(!loading && workdays.length === 0) && (
|
||||||
|
<Text style={{ color: '#ff5252', textAlign: 'center', marginBottom: 12, fontWeight: 'bold' }}>
|
||||||
|
Nincs beosztás vagy nem vagy bejelentkezve!
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
{renderCalendar()}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View style={styles.navBar}>
|
||||||
|
<NavBar activeTab="schedule" />
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function NavBar({ activeTab }: { activeTab: string }) {
|
||||||
|
const router = useRouter();
|
||||||
|
return (
|
||||||
|
<View style={styles.navBar}>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.push('/profile')}>
|
||||||
|
<MaterialIcons name="person" size={28} color={activeTab === 'profile' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'profile' ? PRIMARY : '#bdbdbd' }]}>Profilom</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.push('/schedule')}>
|
||||||
|
<MaterialCommunityIcons name="calendar-month" size={28} color={activeTab === 'schedule' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'schedule' ? PRIMARY : '#bdbdbd' }]}>Beosztás</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={styles.navItem} onPress={() => router.push('/requests')}>
|
||||||
|
<Ionicons name="mail" size={28} color={activeTab === 'requests' ? PRIMARY : '#bdbdbd'} />
|
||||||
|
<Text style={[styles.navLabel, { color: activeTab === 'requests' ? PRIMARY : '#bdbdbd' }]}>Kérelmek</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
card: {
|
||||||
|
backgroundColor: 'rgba(24, 20, 28, 0.95)',
|
||||||
|
borderRadius: 24,
|
||||||
|
padding: 32,
|
||||||
|
width: '90%',
|
||||||
|
maxWidth: 400,
|
||||||
|
shadowColor: '#000',
|
||||||
|
shadowOpacity: 0.3,
|
||||||
|
shadowRadius: 24,
|
||||||
|
shadowOffset: { width: 0, height: 8 },
|
||||||
|
elevation: 8,
|
||||||
|
marginBottom: 32,
|
||||||
|
marginTop: 32,
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
color: '#bdbdbd',
|
||||||
|
fontSize: 16,
|
||||||
|
marginBottom: 16,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
navBar: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-around',
|
||||||
|
alignItems: 'center',
|
||||||
|
backgroundColor: 'rgba(24, 20, 28, 0.98)',
|
||||||
|
borderTopWidth: 1,
|
||||||
|
borderTopColor: '#222',
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 0,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: 64,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
},
|
||||||
|
navItem: {
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
navLabel: {
|
||||||
|
fontSize: 13,
|
||||||
|
marginTop: 2,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
|
});
|
@@ -16,6 +16,7 @@
|
|||||||
"@react-navigation/elements": "^2.3.8",
|
"@react-navigation/elements": "^2.3.8",
|
||||||
"@react-navigation/native": "^7.1.6",
|
"@react-navigation/native": "^7.1.6",
|
||||||
"axios": "^1.11.0",
|
"axios": "^1.11.0",
|
||||||
|
"date-fns": "^4.1.0",
|
||||||
"expo": "~53.0.20",
|
"expo": "~53.0.20",
|
||||||
"expo-blur": "~14.1.5",
|
"expo-blur": "~14.1.5",
|
||||||
"expo-constants": "~17.1.7",
|
"expo-constants": "~17.1.7",
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.25.2",
|
"@babel/core": "^7.25.2",
|
||||||
|
"@types/date-fns": "^2.6.3",
|
||||||
"@types/react": "~19.0.10",
|
"@types/react": "~19.0.10",
|
||||||
"eslint": "^9.25.0",
|
"eslint": "^9.25.0",
|
||||||
"eslint-config-expo": "~9.2.0",
|
"eslint-config-expo": "~9.2.0",
|
||||||
|
19
pnpm-lock.yaml
generated
19
pnpm-lock.yaml
generated
@@ -23,6 +23,9 @@ importers:
|
|||||||
axios:
|
axios:
|
||||||
specifier: ^1.11.0
|
specifier: ^1.11.0
|
||||||
version: 1.11.0
|
version: 1.11.0
|
||||||
|
date-fns:
|
||||||
|
specifier: ^4.1.0
|
||||||
|
version: 4.1.0
|
||||||
expo:
|
expo:
|
||||||
specifier: ~53.0.20
|
specifier: ~53.0.20
|
||||||
version: 53.0.20(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0)))(react-native-webview@13.13.5(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0))(react@19.0.0))(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0))(react@19.0.0)
|
version: 53.0.20(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0)))(react-native-webview@13.13.5(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0))(react@19.0.0))(react-native@0.79.5(@babel/core@7.28.0)(@types/react@19.0.14)(react@19.0.0))(react@19.0.0)
|
||||||
@@ -99,6 +102,9 @@ importers:
|
|||||||
'@babel/core':
|
'@babel/core':
|
||||||
specifier: ^7.25.2
|
specifier: ^7.25.2
|
||||||
version: 7.28.0
|
version: 7.28.0
|
||||||
|
'@types/date-fns':
|
||||||
|
specifier: ^2.6.3
|
||||||
|
version: 2.6.3
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ~19.0.10
|
specifier: ~19.0.10
|
||||||
version: 19.0.14
|
version: 19.0.14
|
||||||
@@ -1011,6 +1017,10 @@ packages:
|
|||||||
'@types/babel__traverse@7.20.7':
|
'@types/babel__traverse@7.20.7':
|
||||||
resolution: {integrity: sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==}
|
resolution: {integrity: sha512-dkO5fhS7+/oos4ciWxyEyjWe48zmG6wbCheo/G2ZnHx4fs3EU6YC6UM8rk56gAjNJ9P3MTH2jo5jb92/K6wbng==}
|
||||||
|
|
||||||
|
'@types/date-fns@2.6.3':
|
||||||
|
resolution: {integrity: sha512-Ke1lw2Ni1t/wMUoLtKFmSNCLozcTBd6vmMqFP4hRzXn6qzkNt97bPAX0x5Y/c15DP43kKvwW1ycStD5+43jVQA==}
|
||||||
|
deprecated: This is a stub types definition. date-fns provides its own type definitions, so you do not need this installed.
|
||||||
|
|
||||||
'@types/estree@1.0.8':
|
'@types/estree@1.0.8':
|
||||||
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
|
||||||
|
|
||||||
@@ -1654,6 +1664,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==}
|
resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
date-fns@4.1.0:
|
||||||
|
resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -5305,6 +5318,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.28.2
|
'@babel/types': 7.28.2
|
||||||
|
|
||||||
|
'@types/date-fns@2.6.3':
|
||||||
|
dependencies:
|
||||||
|
date-fns: 4.1.0
|
||||||
|
|
||||||
'@types/estree@1.0.8': {}
|
'@types/estree@1.0.8': {}
|
||||||
|
|
||||||
'@types/graceful-fs@4.1.9':
|
'@types/graceful-fs@4.1.9':
|
||||||
@@ -6058,6 +6075,8 @@ snapshots:
|
|||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
is-data-view: 1.0.2
|
is-data-view: 1.0.2
|
||||||
|
|
||||||
|
date-fns@4.1.0: {}
|
||||||
|
|
||||||
debug@2.6.9:
|
debug@2.6.9:
|
||||||
dependencies:
|
dependencies:
|
||||||
ms: 2.0.0
|
ms: 2.0.0
|
||||||
|
Reference in New Issue
Block a user