fix: kalender divisi
Deskripsi: - on klik tanggal pertama kali > tampil tanggal salah No Issues
This commit is contained in:
@@ -8,7 +8,6 @@ import Styles from "@/constants/Styles";
|
|||||||
import { apiGetCalendarByDateDivision, apiGetIndicatorCalendar } from "@/lib/api";
|
import { apiGetCalendarByDateDivision, apiGetIndicatorCalendar } from "@/lib/api";
|
||||||
import { useAuthSession } from "@/providers/AuthProvider";
|
import { useAuthSession } from "@/providers/AuthProvider";
|
||||||
import { Feather } from "@expo/vector-icons";
|
import { Feather } from "@expo/vector-icons";
|
||||||
import dayjs from "dayjs";
|
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import 'intl';
|
import 'intl';
|
||||||
import 'intl/locale-data/jsonp/id';
|
import 'intl/locale-data/jsonp/id';
|
||||||
@@ -53,7 +52,7 @@ export default function CalendarDivision() {
|
|||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiGetCalendarByDateDivision({
|
const response = await apiGetCalendarByDateDivision({
|
||||||
user: hasil,
|
user: hasil,
|
||||||
date: dayjs(selected).format("YYYY-MM-DD"),
|
date: moment(selected).format("YYYY-MM-DD"),
|
||||||
division: id,
|
division: id,
|
||||||
});
|
});
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
@@ -71,7 +70,7 @@ export default function CalendarDivision() {
|
|||||||
const hasil = await decryptToken(String(token?.current));
|
const hasil = await decryptToken(String(token?.current));
|
||||||
const response = await apiGetIndicatorCalendar({
|
const response = await apiGetIndicatorCalendar({
|
||||||
user: hasil,
|
user: hasil,
|
||||||
date: dayjs(newDate).format("YYYY-MM-DD"),
|
date: moment(newDate).format("YYYY-MM-DD"),
|
||||||
division: id,
|
division: id,
|
||||||
});
|
});
|
||||||
setDataIndicator(response.data);
|
setDataIndicator(response.data);
|
||||||
@@ -113,6 +112,7 @@ export default function CalendarDivision() {
|
|||||||
text={day.text}
|
text={day.text}
|
||||||
isSelected={day.isSelected}
|
isSelected={day.isSelected}
|
||||||
isSign={sign}
|
isSign={sign}
|
||||||
|
onPress={() => setSelected(new Date(today))}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -156,7 +156,6 @@ export default function CalendarDivision() {
|
|||||||
mode="single"
|
mode="single"
|
||||||
date={selected}
|
date={selected}
|
||||||
month={month}
|
month={month}
|
||||||
onChange={({ date }) => setSelected(date)}
|
|
||||||
onMonthChange={(month) => setMonth(month)}
|
onMonthChange={(month) => setMonth(month)}
|
||||||
styles={{
|
styles={{
|
||||||
selected: Styles.selectedDate,
|
selected: Styles.selectedDate,
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
import Styles from "@/constants/Styles";
|
import Styles from "@/constants/Styles";
|
||||||
import { View } from "react-native";
|
import { Pressable, View } from "react-native";
|
||||||
import Text from "../Text";
|
import Text from "../Text";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
text: string;
|
text: string;
|
||||||
isSelected: boolean;
|
isSelected: boolean;
|
||||||
isSign: boolean;
|
isSign: boolean;
|
||||||
|
onPress?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export default function ItemDateCalendar({ text, isSelected, isSign }: Props) {
|
export default function ItemDateCalendar({ text, isSelected, isSign, onPress }: Props) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View style={{ alignItems: 'center' }}>
|
<Pressable style={{ alignItems: 'center' }} onPress={onPress}>
|
||||||
<Text style={[isSelected ? Styles.cWhite : Styles.cBlack]}>{text}</Text>
|
<Text style={[isSelected ? Styles.cWhite : Styles.cBlack]}>{text}</Text>
|
||||||
<View style={[Styles.signDate, { backgroundColor: isSign ? 'red' : 'transparent' }]}></View>
|
<View style={[Styles.signDate, { backgroundColor: isSign ? 'red' : 'transparent' }]}></View>
|
||||||
</View>
|
</Pressable>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user