Compare commits

...

23 Commits

Author SHA1 Message Date
fa5005a76a Merge pull request 'upd: upload link' (#23) from amalia/14-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#23
2025-08-14 17:15:23 +08:00
7015e92366 upd: upload link
Deskripsi:
- tampilan section link pada project dan tugas divisi
- tampilan tambah link pada project dan tugas divisi
- integrasi api tambah data link pada project dan tugas divisi
- integrasi api hapus data link pada project dan tugas divisi

No Issues
2025-08-14 12:13:41 +08:00
acc464bfc8 Merge pull request 'amalia/12-agustus-25' (#22) from amalia/12-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#22
2025-08-12 17:42:40 +08:00
edbeb30ebe fix : tampilan
Deskripsi:
- border bottom komponen width

No Issues
2025-08-12 14:53:28 +08:00
57a4e2fce6 fix : function
Deskripsi:
- function validation edit judul projectt

No Issues
2025-08-12 13:46:08 +08:00
fd1d20bb32 upd: task divisi detail
Deskripsi:
- mengganti caraousel pada list task hari ini pada detail divisi

No Issues
2025-08-12 13:43:19 +08:00
e8e5af7126 upd: ios dan komponen modal
Deskripsi:
- update ios
- komponen modal loading on click backdrop

No Issues
2025-08-12 11:43:53 +08:00
1089afb6aa Merge pull request 'amalia/11-agustus-25' (#21) from amalia/11-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#21
2025-08-11 17:33:44 +08:00
0f5a56c612 upd: login
Deskripsi:
- tinggi view
- toast error kode verification

No Issues
2025-08-11 17:08:55 +08:00
f929791075 fix: list data
Deskripsi:
- perbaikan list data pada jabatan dan group menggunakan virtualized

No Issues
2025-08-11 10:43:50 +08:00
a49d25500a Merge pull request 'fix: pengumuman' (#20) from amalia/08-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#20
2025-08-08 17:37:54 +08:00
fce5465d4b fix: pengumuman
Deskripsi:
- numberof lines text> tambah dan edit pengumuman
- tinggi view list pengumuman

No Issues
2025-08-08 14:28:32 +08:00
5ad055f543 Merge pull request 'amalia/08-agustus-25' (#19) from amalia/08-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#19
2025-08-08 12:18:33 +08:00
3060ea84a5 fix: kalender divisi
Deskripsi:
- on klik tanggal pertama kali > tampil tanggal salah

No Issues
2025-08-08 12:17:29 +08:00
cd16b8ba04 upd: clear warning
Deskripsi:
- update database realtime > clear warning

No Issues
2025-08-08 11:52:29 +08:00
b490b93c00 Merge pull request 'upd: clear warning' (#18) from amalia/08-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#18
2025-08-08 11:27:27 +08:00
602860d9c3 upd: clear warning
Deskripsi:
- update firebase > clear warning

No Issues
2025-08-08 11:26:09 +08:00
3efd44ce70 Merge pull request 'upd: push notification on background' (#17) from amalia/07-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#17
2025-08-07 17:43:02 +08:00
0c8297f785 Merge pull request 'amalia/07-agustus-25' (#16) from amalia/07-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#16
2025-08-07 14:09:10 +08:00
24c07efb97 Merge pull request 'amalia/06-agustus-25' (#15) from amalia/06-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#15
2025-08-06 17:34:43 +08:00
323d31250b Merge pull request 'upd: notifikasi diskusi umum' (#14) from amalia/06-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#14
2025-08-06 12:00:02 +08:00
c119d3e775 Merge pull request 'amalia/05-agustus-25' (#13) from amalia/05-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#13
2025-08-05 17:39:56 +08:00
9a5765f0d0 Merge pull request 'amalia/04-agustus-25' (#12) from amalia/04-agustus-25 into join
Reviewed-on: bip/mobile-darmasaba#12
2025-08-04 17:45:44 +08:00
34 changed files with 631 additions and 219 deletions

View File

@@ -14,7 +14,8 @@ import { pushToPage } from "@/lib/pushToPage";
import store from "@/lib/store";
import { useAuthSession } from "@/providers/AuthProvider";
import AsyncStorage from "@react-native-async-storage/async-storage";
import firebase from '@react-native-firebase/app';
import { getApp } from "@react-native-firebase/app";
import { getMessaging, onMessage } from "@react-native-firebase/messaging";
import { Redirect, router, Stack, usePathname } from "expo-router";
import { StatusBar } from 'expo-status-bar';
import { useEffect } from "react";
@@ -51,16 +52,18 @@ export default function RootLayout() {
}, []);
useEffect(() => {
const unsubscribe = firebase.app().messaging().onMessage(async remoteMessage => {
const mess = getMessaging(getApp());
const unsubscribe = onMessage(mess, async remoteMessage => {
const id = remoteMessage?.data?.id;
const category = remoteMessage?.data?.category;
const content = remoteMessage?.data?.content;
const title = remoteMessage?.notification?.title;
if (remoteMessage.notification != undefined && remoteMessage.notification.title != undefined && remoteMessage.notification.body != undefined) {
if (category == 'discussion-general' && pathname == '/discussion/' + content) {
return null
} else if (pathname != `/${category}/${content}`) {
if (remoteMessage.notification?.title && remoteMessage.notification?.body) {
if (category === 'discussion-general' && pathname === '/discussion/' + content) {
return null;
} else if (pathname !== `/${category}/${content}`) {
Notifier.showNotification({
title: title,
description: remoteMessage.notification?.body,

View File

@@ -149,9 +149,9 @@ export default function CreateAnnouncement() {
<Text style={[Styles.textDefaultSemiBold]}>{item.name}</Text>
{
item.Division.map((division: any, i: any) => (
<View key={i} style={[Styles.rowItemsCenter]}>
<View key={i} style={[Styles.rowItemsCenter, Styles.w90]}>
<Entypo name="dot-single" size={24} color="black" />
<Text style={[Styles.textDefault]}>{division.name}</Text>
<Text style={[Styles.textDefault]} numberOfLines={1} ellipsizeMode='tail'>{division.name}</Text>
</View>
))
}

View File

@@ -193,9 +193,9 @@ export default function EditAnnouncement() {
<Text style={[Styles.textDefaultSemiBold]}>{item.name}</Text>
{
item.Division.map((division: any, i: any) => (
<View key={i} style={[Styles.rowItemsCenter]}>
<View key={i} style={[Styles.rowItemsCenter, Styles.w90]}>
<Entypo name="dot-single" size={24} color="black" />
<Text style={[Styles.textDefault]}>{division.name}</Text>
<Text style={[Styles.textDefault]} numberOfLines={1} ellipsizeMode='tail'>{division.name}</Text>
</View>
))
}

View File

@@ -87,7 +87,7 @@ export default function Announcement() {
<View>
<InputSearch onChange={setSearch} />
</View>
<View style={[{ flex: 2 }, Styles.mb50]}>
<View style={[{ flex: 2 }]}>
{
loading ?
arrSkeleton.map((item, index) => {

View File

@@ -10,14 +10,15 @@ import Text from '@/components/Text';
import { ColorsStatus } from "@/constants/ColorsStatus";
import Styles from "@/constants/Styles";
import { apiGetDiscussionGeneralOne, apiSendDiscussionGeneralCommentar } from "@/lib/api";
import { getDB } from "@/lib/firebaseDatabase";
import { useAuthSession } from "@/providers/AuthProvider";
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import { firebase } from '@react-native-firebase/database';
import { ref } from '@react-native-firebase/database';
import { useHeaderHeight } from '@react-navigation/elements';
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { KeyboardAvoidingView, Platform, Pressable, ScrollView, View } from "react-native";
import { useSelector } from "react-redux";
import { useHeaderHeight } from '@react-navigation/elements';
type Props = {
id: string
@@ -49,7 +50,7 @@ export default function DetailDiscussionGeneral() {
const [loading, setLoading] = useState(true)
const [loadingKomentar, setLoadingKomentar] = useState(true)
const arrSkeleton = Array.from({ length: 3 }, (_, index) => index)
const reference = firebase.app().database('https://mobile-darmasaba-default-rtdb.asia-southeast1.firebasedatabase.app').ref(`/discussion-general/${id}`);
const reference = ref(getDB(), `/discussion-general/${id}`);
const headerHeight = useHeaderHeight();
useEffect(() => {
@@ -145,7 +146,6 @@ export default function DetailDiscussionGeneral() {
:
<BorderBottomItem
descEllipsize={false}
width={55}
borderType="bottom"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
@@ -182,7 +182,6 @@ export default function DetailDiscussionGeneral() {
return (
<BorderBottomItem
key={i}
width={55}
borderType="bottom"
icon={
<ImageUser src={`https://wibu-storage.wibudev.com/api/files/${item.img}`} size="xs" />

View File

@@ -8,7 +8,6 @@ import Styles from "@/constants/Styles";
import { apiGetCalendarByDateDivision, apiGetIndicatorCalendar } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import { Feather } from "@expo/vector-icons";
import dayjs from "dayjs";
import { router, Stack, useLocalSearchParams } from "expo-router";
import 'intl';
import 'intl/locale-data/jsonp/id';
@@ -53,7 +52,7 @@ export default function CalendarDivision() {
const hasil = await decryptToken(String(token?.current));
const response = await apiGetCalendarByDateDivision({
user: hasil,
date: dayjs(selected).format("YYYY-MM-DD"),
date: moment(selected).format("YYYY-MM-DD"),
division: id,
});
setData(response.data);
@@ -71,7 +70,7 @@ export default function CalendarDivision() {
const hasil = await decryptToken(String(token?.current));
const response = await apiGetIndicatorCalendar({
user: hasil,
date: dayjs(newDate).format("YYYY-MM-DD"),
date: moment(newDate).format("YYYY-MM-DD"),
division: id,
});
setDataIndicator(response.data);
@@ -113,6 +112,7 @@ export default function CalendarDivision() {
text={day.text}
isSelected={day.isSelected}
isSign={sign}
onPress={() => setSelected(new Date(today))}
/>
);
},
@@ -156,7 +156,6 @@ export default function CalendarDivision() {
mode="single"
date={selected}
month={month}
onChange={({ date }) => setSelected(date)}
onMonthChange={(month) => setMonth(month)}
styles={{
selected: Styles.selectedDate,

View File

@@ -13,14 +13,15 @@ import {
apiGetDivisionOneFeature,
apiSendDiscussionCommentar,
} from "@/lib/api";
import { getDB } from "@/lib/firebaseDatabase";
import { useAuthSession } from "@/providers/AuthProvider";
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import { firebase } from "@react-native-firebase/database";
import { ref } from "@react-native-firebase/database";
import { useHeaderHeight } from '@react-navigation/elements';
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { KeyboardAvoidingView, Platform, Pressable, RefreshControl, ScrollView, View } from "react-native";
import { useSelector } from "react-redux";
import { useHeaderHeight } from '@react-navigation/elements';
type Props = {
id: string;
@@ -58,7 +59,7 @@ export default function DiscussionDetail() {
const [loading, setLoading] = useState(true)
const [loadingKomentar, setLoadingKomentar] = useState(true)
const arrSkeleton = Array.from({ length: 3 })
const reference = firebase.app().database('https://mobile-darmasaba-default-rtdb.asia-southeast1.firebasedatabase.app').ref(`/discussion-division/${detail}`);
const reference = ref(getDB(), `/discussion-division/${detail}`);
const [refreshing, setRefreshing] = useState(false)
const headerHeight = useHeaderHeight();
@@ -216,7 +217,6 @@ export default function DiscussionDetail() {
:
<BorderBottomItem
descEllipsize={false}
width={55}
borderType="bottom"
icon={
<ImageUser
@@ -264,7 +264,6 @@ export default function DiscussionDetail() {
dataComment.map((item, index) => (
<BorderBottomItem
key={index}
width={55}
borderType="bottom"
icon={
<ImageUser

View File

@@ -138,7 +138,6 @@ export default function DiscussionDivision() {
return (
<BorderBottomItem
key={index}
width={55}
onPress={() => { router.push(`./discussion/${item.id}`) }}
borderType="bottom"
icon={
@@ -174,7 +173,6 @@ export default function DiscussionDivision() {
// data.map((item, index) => (
// <BorderBottomItem
// key={index}
// width={55}
// onPress={() => { router.push(`./discussion/${item.id}`) }}
// borderType="bottom"
// icon={

View File

@@ -3,6 +3,7 @@ import SectionCancel from "@/components/sectionCancel";
import SectionProgress from "@/components/sectionProgress";
import HeaderRightTaskDetail from "@/components/task/headerTaskDetail";
import SectionFileTask from "@/components/task/sectionFileTask";
import SectionLinkTask from "@/components/task/sectionLinkTask";
import SectionMemberTask from "@/components/task/sectionMemberTask";
import SectionTanggalTugasTask from "@/components/task/sectionTanggalTugasTask";
import Styles from "@/constants/Styles";
@@ -90,6 +91,7 @@ export default function DetailTaskDivision() {
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
<SectionTanggalTugasTask refreshing={refreshing}/>
<SectionFileTask refreshing={refreshing}/>
<SectionLinkTask refreshing={refreshing}/>
<SectionMemberTask refreshing={refreshing}/>
</View>
</ScrollView>

View File

@@ -184,7 +184,6 @@ export default function InformationDivision() {
dataMember.map((item, index) => {
return (
<BorderBottomItem
width={55}
key={index}
borderType="bottom"
onPress={() => { dataDetail?.isActive && handleChooseMember(item) }}

View File

@@ -15,7 +15,7 @@ import { setUpdateGroup } from "@/lib/groupSlice";
import { useAuthSession } from "@/providers/AuthProvider";
import { AntDesign, Feather, MaterialCommunityIcons } from "@expo/vector-icons";
import { useEffect, useState } from "react";
import { RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
import { RefreshControl, View, VirtualizedList } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
@@ -116,9 +116,17 @@ export default function Index() {
}
const getItem = (_data: unknown, index: number): Props => ({
id: data[index].id,
name: data[index].name,
isActive: data[index].isActive,
});
return (
<SafeAreaView>
<View style={[Styles.p15]}>
<View style={[Styles.p15, { flex: 1 }]}>
<View>
<View style={[Styles.wrapBtnTab]}>
<ButtonTab
active={status == "false" ? "false" : "true"}
@@ -136,51 +144,53 @@ export default function Index() {
n={2} />
</View>
<InputSearch onChange={setSearch} />
<ScrollView
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
style={[Styles.h100]}
>
<View>
{
loading ?
arrSkeleton.map((item, index) => {
</View>
<View style={{ flex: 2 }}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTwoItem key={index} />
)
})
:
data.length > 0 ?
<VirtualizedList
data={data}
getItemCount={() => data.length}
getItem={getItem}
renderItem={({ item, index }: { item: Props, index: number }) => {
return (
<SkeletonTwoItem key={index} />
<BorderBottomItem
key={index}
onPress={() => {
setIdChoose(item.id)
setActiveChoose(item.isActive)
setTitleChoose(item.name)
setModal(true)
}}
borderType="all"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
<MaterialCommunityIcons name="office-building-outline" size={25} color={'#384288'} />
</View>
}
title={item.name}
/>
)
})
:
data.length > 0 ?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
onPress={() => {
setIdChoose(item.id)
setActiveChoose(item.isActive)
setTitleChoose(item.name)
setModal(true)
}}
borderType="all"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
<MaterialCommunityIcons name="office-building-outline" size={25} color={'#384288'} />
</View>
}
title={item.name}
/>
)
})
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
}
</View>
</ScrollView>
}}
keyExtractor={(item, index) => String(index)}
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
/>
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
}
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={() => setModal(false)} title={titleChoose}>
@@ -228,8 +238,7 @@ export default function Index() {
</View>
</View>
</DrawerBottom>
</View >
</SafeAreaView>
)
}

View File

@@ -136,7 +136,6 @@ export default function Notification() {
return (
<BorderBottomItem
borderType="bottom"
width={55}
icon={
<View style={[Styles.iconContent, item.isRead ? ColorsStatus.secondary : ColorsStatus.primary]}>
<Feather name="bell" size={25} color="white" />

View File

@@ -16,7 +16,7 @@ import { useAuthSession } from "@/providers/AuthProvider";
import { AntDesign, Feather, MaterialCommunityIcons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { RefreshControl, SafeAreaView, ScrollView, View } from "react-native";
import { RefreshControl, View, VirtualizedList } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
@@ -129,9 +129,18 @@ export default function Index() {
setRefreshing(false)
};
const getItem = (_data: unknown, index: number): Props => ({
id: data[index].id,
name: data[index].name,
idGroup: data[index].idGroup,
group: data[index].group,
isActive: data[index].isActive,
});
return (
<SafeAreaView>
<View style={[Styles.p15]}>
<View style={[Styles.p15, { flex: 1 }]}>
<View>
<View style={[Styles.wrapBtnTab]}>
<ButtonTab
active={status == "false" ? "false" : "true"}
@@ -155,47 +164,50 @@ export default function Index() {
<Text>Filter : {nameGroup}</Text>
</View>
}
<ScrollView
style={[Styles.h100]}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}>
<View>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTwoItem key={index} />
)
})
:
data.length > 0 ?
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
onPress={() => { handleChooseData(item.id, item.name, item.isActive, item.idGroup) }}
borderType="all"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
<MaterialCommunityIcons name="account-tie" size={25} color={'#384288'} />
</View>
}
title={item.name}
subtitle={item.group}
/>
)
})
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
}
</View>
</ScrollView>
</View>
<View style={[{ flex: 2 }]}>
{
loading ?
arrSkeleton.map((item, index) => {
return (
<SkeletonTwoItem key={index} />
)
})
:
data.length > 0 ?
<VirtualizedList
data={data}
getItemCount={() => data.length}
getItem={getItem}
renderItem={({ item, index }: { item: Props, index: number }) => {
return (
<BorderBottomItem
key={index}
onPress={() => { handleChooseData(item.id, item.name, item.isActive, item.idGroup) }}
borderType="all"
icon={
<View style={[Styles.iconContent, ColorsStatus.lightGreen]}>
<MaterialCommunityIcons name="account-tie" size={25} color={'#384288'} />
</View>
}
title={item.name}
subtitle={item.group}
/>
)
}}
keyExtractor={(item, index) => String(index)}
showsVerticalScrollIndicator={false}
refreshControl={
<RefreshControl
refreshing={refreshing}
onRefresh={handleRefresh}
/>
}
/>
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada data</Text>
}
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={() => setModal(false)} title={chooseData.name}>
<View style={Styles.rowItemsCenter}>
<MenuItemRow
@@ -243,7 +255,6 @@ export default function Index() {
</View>
</View>
</DrawerBottom>
</SafeAreaView>
</View>
)
}

View File

@@ -43,6 +43,8 @@ export default function EditProject() {
setJudul(val)
if (val == "" || val == "null") {
setError(true)
}else{
setError(false)
}
}

View File

@@ -1,6 +1,7 @@
import ButtonBackHeader from "@/components/buttonBackHeader";
import HeaderRightProjectDetail from "@/components/project/headerProjectDetail";
import SectionFile from "@/components/project/sectionFile";
import SectionLink from "@/components/project/sectionLink";
import SectionMember from "@/components/project/sectionMember";
import SectionTanggalTugasProject from "@/components/project/sectionTanggalTugas";
import SectionCancel from "@/components/sectionCancel";
@@ -111,8 +112,9 @@ export default function DetailProject() {
data?.reason != null && data?.reason != "" && <SectionCancel text={data?.reason} />
}
<SectionProgress text={`Kemajuan Kegiatan ${progress}%`} progress={progress} />
<SectionTanggalTugasProject status={data?.status} member={isMember} refreshing={refreshing}/>
<SectionTanggalTugasProject status={data?.status} member={isMember} refreshing={refreshing} />
<SectionFile status={data?.status} member={isMember} refreshing={refreshing} />
<SectionLink status={data?.status} member={isMember} refreshing={refreshing} />
<SectionMember status={data?.status} refreshing={refreshing} />
</View>
</ScrollView>

View File

@@ -44,7 +44,7 @@ export default function ViewLogin({ onValidate }: Props) {
return (
<SafeAreaView>
<ToastCustom />
<View style={Styles.p20}>
<View style={[Styles.p20, Styles.h100]}>
<View style={{ alignItems: "center", marginVertical: 50 }}>
<Image
source={require("../../assets/images/splash-icon.png")}

View File

@@ -35,7 +35,7 @@ export default function ViewVerification({ phone, otp }: Props) {
if (value === otpFix.toString()) {
login()
} else {
return Toast.show({ type: 'error', text1: 'Kode OTP tidak sesuai' });
return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai' });
}
}

View File

@@ -31,7 +31,7 @@ export default function BorderBottomItem({ title, subtitle, icon, desc, onPress,
<View style={[Styles.rowItemsCenter]}>
{icon}
<View style={[Styles.rowSpaceBetween, width ? { width: lebar } : { width: '88%' }]}>
<View style={[Styles.ml10, rightTopInfo ? { width: lebar } : { width: '90%' },]}>
<View style={[Styles.ml10, rightTopInfo ? { width: '70%' } : { width: '90%' }]}>
<Text style={[titleWeight == 'normal' ? Styles.textDefault : Styles.textDefaultSemiBold, { color: textColorFix }]} numberOfLines={1} ellipsizeMode='tail'>{title}</Text>
{
subtitle &&

View File

@@ -1,21 +1,22 @@
import Styles from "@/constants/Styles";
import { View } from "react-native";
import { Pressable, View } from "react-native";
import Text from "../Text";
type Props = {
text: string;
isSelected: boolean;
isSign: boolean;
onPress?: () => void;
}
export default function ItemDateCalendar({ text, isSelected, isSign }: Props) {
export default function ItemDateCalendar({ text, isSelected, isSign, onPress }: Props) {
return (
<>
<View style={{ alignItems: 'center' }}>
<Pressable style={{ alignItems: 'center' }} onPress={onPress}>
<Text style={[isSelected ? Styles.cWhite : Styles.cBlack]}>{text}</Text>
<View style={[Styles.signDate, { backgroundColor: isSign ? 'red' : 'transparent' }]}></View>
</View>
</Pressable>
</>
)
}

View File

@@ -2,12 +2,12 @@ import Styles from "@/constants/Styles";
import { apiGetDivisionOneFeature } from "@/lib/api";
import { useAuthSession } from "@/providers/AuthProvider";
import { Feather } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { router, useLocalSearchParams } from "expo-router";
import React, { useEffect, useState } from "react";
import { Dimensions, View } from "react-native";
import Text from "../Text";
import Carousel, { ICarouselInstance } from "react-native-reanimated-carousel";
import { Dimensions, Pressable, View } from "react-native";
import { ICarouselInstance } from "react-native-reanimated-carousel";
import Skeleton from "../skeleton";
import Text from "../Text";
type Props = {
id: string
@@ -46,34 +46,42 @@ export default function TaskDivisionDetail() {
return (
<View>
<Text style={[Styles.textDefaultSemiBold, Styles.mb05]}>Tugas Hari Ini</Text>
{
loading ?
<Skeleton width={100} widthType="percent" height={60} borderRadius={10} />
:
data.length > 0 ?
<Carousel
ref={ref}
style={{ width: "100%" }}
width={width * 0.8}
height={100}
data={data}
loop={true}
autoPlay={false}
autoPlayReverse={false}
pagingEnabled={true}
snapEnabled={true}
vertical={false}
renderItem={({ index }) => (
<View style={[Styles.wrapPaper, { width: '95%' }]}>
<Text style={[Styles.textDefaultSemiBold]} numberOfLines={1} ellipsizeMode="tail">{data[index].title} - {data[index].projectTitle}</Text>
<View style={[Styles.rowItemsCenter, Styles.mt10]}>
<Feather name="clock" size={18} color="grey" style={Styles.mr05} />
<Text style={[Styles.textInformation]} numberOfLines={1} ellipsizeMode="tail">{data[index].dateStart} - {data[index].dateEnd}</Text>
</View>
data.map((item, index) => (
<Pressable key={index} style={[Styles.wrapPaper]} onPress={() => { router.push(`/division/${id}/task/${item.idProject}`) }}>
<Text style={[Styles.textDefaultSemiBold]} numberOfLines={1} ellipsizeMode="tail">{item.title} - {item.projectTitle}</Text>
<View style={[Styles.rowItemsCenter, Styles.mt10]}>
<Feather name="clock" size={18} color="grey" style={Styles.mr05} />
<Text style={[Styles.textInformation]} numberOfLines={1} ellipsizeMode="tail">{item.dateStart} - {item.dateEnd}</Text>
</View>
)}
/>
</Pressable>
))
// <Carousel
// ref={ref}
// style={{ width: "100%" }}
// width={width * 0.8}
// height={100}
// data={data}
// loop={true}
// autoPlay={false}
// autoPlayReverse={false}
// pagingEnabled={true}
// snapEnabled={true}
// vertical={false}
// renderItem={({ index }) => (
// <View style={[Styles.wrapPaper, { width: '95%' }]}>
// <Text style={[Styles.textDefaultSemiBold]} numberOfLines={1} ellipsizeMode="tail">{data[index].title} - {data[index].projectTitle}</Text>
// <View style={[Styles.rowItemsCenter, Styles.mt10]}>
// <Feather name="clock" size={18} color="grey" style={Styles.mr05} />
// <Text style={[Styles.textInformation]} numberOfLines={1} ellipsizeMode="tail">{data[index].dateStart} - {data[index].dateEnd}</Text>
// </View>
// </View>
// )}
// />
:
<Text style={[Styles.textDefault, Styles.cGray, { textAlign: 'center' }]}>Tidak ada tugas</Text>
}

View File

@@ -13,7 +13,9 @@ export default function ModalLoading({ isVisible, setVisible }: Props) {
animationOut={"slideOutDown"}
isVisible={isVisible}
hideModalContentWhileAnimating={true}
onBackdropPress={() => { setVisible(false) }}
onBackdropPress={() => {
// setVisible(false)
}}
>
<ActivityIndicator size="large" />
</Modal>

View File

@@ -1,8 +1,8 @@
import Styles from "@/constants/Styles"
import { apiDeleteProject } from "@/lib/api"
import { apiAddLinkProject, apiDeleteProject } from "@/lib/api"
import { setUpdateProject } from "@/lib/projectUpdate"
import { useAuthSession } from "@/providers/AuthProvider"
import { AntDesign, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
import { AntDesign, Feather, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
import { router } from "expo-router"
import { useState } from "react"
import { View } from "react-native"
@@ -11,7 +11,9 @@ import { useDispatch, useSelector } from "react-redux"
import AlertKonfirmasi from "../alertKonfirmasi"
import ButtonMenuHeader from "../buttonMenuHeader"
import DrawerBottom from "../drawerBottom"
import { InputForm } from "../inputForm"
import MenuItemRow from "../menuItemRow"
import ModalFloat from "../modalFloat"
type Props = {
id: string | string[]
@@ -24,6 +26,8 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
const [isVisible, setVisible] = useState(false)
const dispatch = useDispatch()
const update = useSelector((state: any) => state.projectUpdate)
const [isAddLink, setAddLink] = useState(false)
const [link, setLink] = useState("")
async function handleDelete() {
try {
@@ -43,6 +47,23 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
}
}
async function handleAddLink() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiAddLinkProject({ user: hasil, link }, String(id))
if (response.success) {
dispatch(setUpdateProject({ ...update, link: !update.link }))
Toast.show({ type: 'small', text1: 'Berhasil menambahkan link', })
} else {
Toast.show({ type: 'small', text1: 'Gagal menambahkan link', })
}
} catch (error) {
console.error(error)
} finally {
setAddLink(false)
}
}
return (
<>
<ButtonMenuHeader onPress={() => { setVisible(true) }} />
@@ -68,8 +89,22 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
}}
disabled={status == 3}
/>
{
entityUser.role != "user" && entityUser.role != "coadmin" &&
<MenuItemRow
icon={<Feather name="link" color="black" size={25} />}
title="Tambah Link"
onPress={() => {
if (status == 3) return
setVisible(false)
setTimeout(() => {
setAddLink(true)
}, 600)
}}
disabled={status == 3}
/>
</View>
{
entityUser.role != "user" && entityUser.role != "coadmin" &&
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
<MenuItemRow
icon={<MaterialIcons name="groups" color="black" size={25} />}
title="Tambah Anggota"
@@ -80,11 +115,6 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
}}
disabled={status == 3}
/>
}
</View>
{
entityUser.role != "user" && entityUser.role != "coadmin" &&
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
<MenuItemRow
icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
title="Edit"
@@ -123,6 +153,23 @@ export default function HeaderRightProjectDetail({ id, status }: Props) {
</View>
}
</DrawerBottom>
<ModalFloat
title="Tambah Link"
isVisible={isAddLink}
setVisible={() => { setAddLink(false) }}
onSubmit={() => { handleAddLink() }}
disableSubmit={link == ""}
>
<View>
<InputForm
type="default"
placeholder="Masukkan link"
value={link}
onChange={(text) => { setLink(text) }}
/>
</View>
</ModalFloat>
</>
)
}

View File

@@ -0,0 +1,140 @@
import Styles from "@/constants/Styles";
import { apiDeleteLinkProject, apiGetProjectOne } from "@/lib/api";
import { urlCompleted } from "@/lib/fun_urlCompleted";
import { setUpdateProject } from "@/lib/projectUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { Feather, Ionicons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Linking, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import AlertKonfirmasi from "../alertKonfirmasi";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import Text from "../Text";
type Props = {
id: string
link: string
}
export default function SectionLink({ status, member, refreshing }: { status: number | undefined, member: boolean, refreshing?: boolean }) {
const entityUser = useSelector((state: any) => state.user)
const [isModal, setModal] = useState(false)
const { token, decryptToken } = useAuthSession();
const { id } = useLocalSearchParams<{ id: string }>();
const [data, setData] = useState<Props[]>([]);
const update = useSelector((state: any) => state.projectUpdate)
const dispatch = useDispatch()
const [selectLink, setSelectLink] = useState<Props | null>(null)
async function handleLoad() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiGetProjectOne({
user: hasil,
cat: "link",
id: id,
});
setData(response.data);
} catch (error) {
console.error(error);
}
}
useEffect(() => {
handleLoad();
}, [update.link]);
useEffect(() => {
if (refreshing)
handleLoad();
}, [refreshing]);
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteLinkProject({ user: hasil, idLink: String(selectLink?.id) }, String(id));
if (response.success) {
Toast.show({ type: 'small', text1: 'Berhasil menghapus link', })
dispatch(setUpdateProject({ ...update, link: !update.link }))
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error) {
console.error(error);
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setModal(false)
}
}
return (
<>
{
data.length > 0 &&
<>
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
<View style={[Styles.wrapPaper]}>
{
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<Feather name="link" size={25} color="black" />}
title={item.link}
titleWeight="normal"
onPress={() => { setSelectLink(item); setModal(true) }}
width={65}
/>
)
})
}
</View>
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Feather name="external-link" color="black" size={25} />}
title="Buka Link"
onPress={() => {
Linking.openURL(urlCompleted(String(selectLink?.link)))
}}
/>
{
!member && (entityUser.role == "user" || entityUser.role == "coadmin") ? <></>
:
<MenuItemRow
icon={<Ionicons name="trash" color="black" size={25} />}
title="Hapus"
disabled={status == 3}
onPress={() => {
if (status == 3) return
setModal(false)
AlertKonfirmasi({
title: 'Konfirmasi',
desc: 'Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan',
onPress: () => {
handleDelete()
}
})
}}
/>
}
</View>
</DrawerBottom>
</>
}
</>
)
}

View File

@@ -1,8 +1,8 @@
import Styles from "@/constants/Styles"
import { apiDeleteTask, apiGetDivisionOneFeature } from "@/lib/api"
import { apiAddLinkTask, apiDeleteTask, apiGetDivisionOneFeature } from "@/lib/api"
import { setUpdateTask } from "@/lib/taskUpdate"
import { useAuthSession } from "@/providers/AuthProvider"
import { AntDesign, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
import { AntDesign, Feather, Ionicons, MaterialCommunityIcons, MaterialIcons } from "@expo/vector-icons"
import { router } from "expo-router"
import { useEffect, useState } from "react"
import { View } from "react-native"
@@ -11,7 +11,9 @@ import { useDispatch, useSelector } from "react-redux"
import AlertKonfirmasi from "../alertKonfirmasi"
import ButtonMenuHeader from "../buttonMenuHeader"
import DrawerBottom from "../drawerBottom"
import { InputForm } from "../inputForm"
import MenuItemRow from "../menuItemRow"
import ModalFloat from "../modalFloat"
type Props = {
id: string | string[]
@@ -27,6 +29,8 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) {
const [isAdminDivision, setIsAdminDivision] = useState(false);
const dispatch = useDispatch()
const update = useSelector((state: any) => state.taskUpdate)
const [isAddLink, setAddLink] = useState(false)
const [link, setLink] = useState("")
async function handleCheckMember() {
try {
@@ -72,6 +76,23 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) {
}
}
async function handleAddLink() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiAddLinkTask({ user: hasil, link, idDivision: division }, String(id))
if (response.success) {
dispatch(setUpdateTask({ ...update, link: !update.link }))
Toast.show({ type: 'small', text1: 'Berhasil menambahkan link', })
} else {
Toast.show({ type: 'small', text1: 'Gagal menambahkan link', })
}
} catch (error) {
console.error(error)
} finally {
setAddLink(false)
}
}
return (
<>
{
@@ -102,9 +123,25 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) {
}}
disabled={status == 3}
/>
{
((entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision)
&&
<MenuItemRow
icon={<Feather name="link" color="black" size={25} />}
title="Tambah Link"
onPress={() => {
if (status == 3) return
setVisible(false)
setTimeout(() => {
setAddLink(true)
}, 600)
}}
disabled={status == 3}
/>
</View>
{
((entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision)
&&
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
<MenuItemRow
icon={<MaterialIcons name="groups" color="black" size={25} />}
title="Tambah Anggota"
@@ -115,15 +152,6 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) {
}}
disabled={status == 3}
/>
}
</View>
{
((entityUser.role != "user" && entityUser.role != "coadmin") || isAdminDivision)
&&
<View style={[Styles.rowItemsCenter, Styles.mt15]}>
<MenuItemRow
icon={<MaterialCommunityIcons name="pencil-outline" color="black" size={25} />}
title="Edit"
@@ -163,6 +191,23 @@ export default function HeaderRightTaskDetail({ id, division, status }: Props) {
</View>
}
</DrawerBottom>
<ModalFloat
title="Tambah Link"
isVisible={isAddLink}
setVisible={() => { setAddLink(false) }}
onSubmit={() => { handleAddLink() }}
disableSubmit={link == ""}
>
<View>
<InputForm
type="default"
placeholder="Masukkan link"
value={link}
onChange={(text) => { setLink(text) }}
/>
</View>
</ModalFloat>
</>
)
}

View File

@@ -0,0 +1,122 @@
import Styles from "@/constants/Styles";
import { apiDeleteLinkTask, apiGetTaskOne } from "@/lib/api";
import { urlCompleted } from "@/lib/fun_urlCompleted";
import { setUpdateTask } from "@/lib/taskUpdate";
import { useAuthSession } from "@/providers/AuthProvider";
import { Feather, Ionicons } from "@expo/vector-icons";
import { useLocalSearchParams } from "expo-router";
import { useEffect, useState } from "react";
import { Linking, View } from "react-native";
import Toast from "react-native-toast-message";
import { useDispatch, useSelector } from "react-redux";
import AlertKonfirmasi from "../alertKonfirmasi";
import BorderBottomItem from "../borderBottomItem";
import DrawerBottom from "../drawerBottom";
import MenuItemRow from "../menuItemRow";
import Text from "../Text";
type Props = {
id: string
link: string
}
export default function SectionLinkTask({ refreshing }: { refreshing: boolean }) {
const [isModal, setModal] = useState(false)
const { token, decryptToken } = useAuthSession()
const { detail } = useLocalSearchParams<{ detail: string }>()
const [data, setData] = useState<Props[]>([])
const update = useSelector((state: any) => state.taskUpdate)
const dispatch = useDispatch()
const [selectLink, setSelectLink] = useState<Props | null>(null)
async function handleLoad() {
try {
const hasil = await decryptToken(String(token?.current))
const response = await apiGetTaskOne({ id: detail, user: hasil, cat: 'link' })
setData(response.data)
} catch (error) {
console.error(error)
}
}
useEffect(() => {
handleLoad()
}, [update.link])
useEffect(() => {
if (refreshing)
handleLoad();
}, [refreshing]);
async function handleDelete() {
try {
const hasil = await decryptToken(String(token?.current));
const response = await apiDeleteLinkTask({ user: hasil, idLink: String(selectLink?.id) }, String(detail));
if (response.success) {
Toast.show({ type: 'small', text1: 'Berhasil menghapus link', })
dispatch(setUpdateTask({ ...update, link: !update.link }))
} else {
Toast.show({ type: 'small', text1: response.message, })
}
} catch (error) {
console.error(error);
Toast.show({ type: 'small', text1: 'Terjadi kesalahan', })
} finally {
setModal(false)
}
}
return (
<>
{
data.length > 0 &&
<>
<View style={[Styles.mb15]}>
<Text style={[Styles.textDefaultSemiBold, Styles.mv05]}>Link</Text>
<View style={[Styles.wrapPaper]}>
{
data.map((item, index) => {
return (
<BorderBottomItem
key={index}
borderType="all"
icon={<Feather name="link" size={25} color="black" />}
title={item.link}
titleWeight="normal"
onPress={() => { setSelectLink(item); setModal(true) }}
width={65}
/>
)
})
}
</View>
</View>
<DrawerBottom animation="slide" isVisible={isModal} setVisible={setModal} title="Menu">
<View style={Styles.rowItemsCenter}>
<MenuItemRow
icon={<Feather name="external-link" color="black" size={25} />}
title="Buka Link"
onPress={() => {
Linking.openURL(urlCompleted(String(selectLink?.link)))
}}
/>
<MenuItemRow
icon={<Ionicons name="trash" color="black" size={25} />}
title="Hapus"
onPress={() => {
setModal(false)
AlertKonfirmasi({
title: 'Konfirmasi',
desc: 'Apakah Anda yakin ingin menghapus link ini? Link yang dihapus tidak dapat dikembalikan',
onPress: () => { handleDelete() }
})
}}
/>
</View>
</DrawerBottom>
</>
}
</>
)
}

View File

@@ -1,12 +1,15 @@
// index.js
import 'expo-router/entry'; // ⬅️ wajib ada agar expo-router tetap bekerja
import messaging from '@react-native-firebase/messaging';
import { getApp } from '@react-native-firebase/app';
import { getMessaging, setBackgroundMessageHandler } from '@react-native-firebase/messaging';
import AsyncStorage from '@react-native-async-storage/async-storage';
// ✅ Firebase background handler — wajib diletakkan DI SINI
messaging().setBackgroundMessageHandler(async remoteMessage => {
// ✅ Ambil instance messaging modular
const mess = getMessaging(getApp());
// ✅ Firebase background handler — wajib diletakkan DI SINI
setBackgroundMessageHandler(mess, async remoteMessage => {
const screen = remoteMessage?.data?.category;
const content = remoteMessage?.data?.content;

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@ import axios from 'axios';
const api = axios.create({
// baseURL: 'http://10.0.2.2:3000/api',
// baseURL: 'https://stg-darmasaba.wibudev.com/api',
baseURL: 'http://192.168.1.89:3000/api',
baseURL: 'http://192.168.1.110:3000/api',
});
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
@@ -150,7 +150,7 @@ export const apiGetUser = async ({ user, active, search, group, page }: { user:
};
export const apiCreateUser = async ({data}: {data: FormData}) => {
export const apiCreateUser = async ({ data }: { data: FormData }) => {
const response = await api.post('/mobile/user', data, {
headers: {
'Content-Type': 'multipart/form-data',
@@ -264,7 +264,7 @@ export const apiGetProject = async ({ user, status, search, group, kategori, pag
return response.data;
};
export const apiGetProjectOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member', id: string }) => {
export const apiGetProjectOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member' | 'link', id: string }) => {
const response = await api.get(`mobile/project/${id}?user=${user}&cat=${cat}`);
return response.data;
};
@@ -329,6 +329,11 @@ export const apiDeleteProject = async (data: { user: string }, id: string) => {
return response.data;
};
export const apiAddLinkProject = async (data: { user: string, link: string }, id: string) => {
const response = await api.post(`/mobile/project/${id}/link`, data)
return response.data;
};
export const apiAddFileProject = async ({ data, id }: { data: FormData, id: string }) => {
const response = await api.post(`/mobile/project/file/${id}`, data,
{
@@ -356,6 +361,11 @@ export const apiDeleteFileProject = async (data: { user: string }, id: string) =
return response.data;
};
export const apiDeleteLinkProject = async (data: { idLink: string, user: string }, id: string) => {
const response = await api.delete(`/mobile/project/${id}/link`, { data })
return response.data;
};
export const apiGetDivision = async ({ user, search, group, kategori, active, page }: { user: string, search: string, group?: string, kategori?: string, active?: string, page?: number }) => {
const response = await api.get(`mobile/division?user=${user}&active=${active}&group=${group}&search=${search}&cat=${kategori}&page=${page}`);
return response.data;
@@ -502,7 +512,7 @@ export const apiGetTask = async ({ user, status, search, division, page }: { use
return response.data;
};
export const apiGetTaskOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member', id: string }) => {
export const apiGetTaskOne = async ({ user, cat, id }: { user: string, cat: 'data' | 'progress' | 'task' | 'file' | 'member' | 'link', id: string }) => {
const response = await api.get(`mobile/task/${id}?user=${user}&cat=${cat}`);
return response.data;
};
@@ -532,6 +542,11 @@ export const apiDeleteFileTask = async (data: { user: string }, id: string) => {
return response.data;
};
export const apiDeleteLinkTask = async (data: { user: string, idLink: string }, id: string) => {
const response = await api.delete(`/mobile/task/${id}/link`, { data })
return response.data;
};
export const apiDeleteTaskMember = async (data: { user: string, idUser: string }, id: string) => {
const response = await api.delete(`mobile/task/${id}/member`, { data })
return response.data
@@ -593,6 +608,11 @@ export const apiDeleteTask = async (data: { user: string }, id: string) => {
return response.data;
};
export const apiAddLinkTask = async (data: { user: string, link: string, idDivision: string }, id: string) => {
const response = await api.post(`/mobile/task/${id}/link`, data)
return response.data;
};
export const apiGetDocument = async ({ user, path, division, category }: { user: string, path: string, division: string, category: 'all' | 'folder' }) => {
const response = await api.get(`mobile/document?user=${user}&path=${path}&division=${division}&category=${category}`);
return response.data;

9
lib/firebaseDatabase.ts Normal file
View File

@@ -0,0 +1,9 @@
import { getApp } from '@react-native-firebase/app';
import { getDatabase } from '@react-native-firebase/database';
// Ganti URL sesuai punya kamu
const DATABASE_URL = 'https://mobile-darmasaba-default-rtdb.asia-southeast1.firebasedatabase.app';
export function getDB() {
return getDatabase(getApp(), DATABASE_URL);
}

4
lib/fun_urlCompleted.ts Normal file
View File

@@ -0,0 +1,4 @@
export function urlCompleted(url: string) {
if (url.startsWith('http://') || url.startsWith('https://')) return url
return 'https://' + url
}

View File

@@ -7,7 +7,8 @@ const projectUpdate = createSlice({
progress: false,
task: false,
file: false,
member: false
member: false,
link: false,
},
reducers: {
setUpdateProject: (state, action) => {

View File

@@ -7,7 +7,8 @@ const taskUpdate = createSlice({
progress: false,
task: false,
file: false,
member: false
member: false,
link: false,
},
reducers: {
setUpdateTask: (state, action) => {

View File

@@ -1,6 +1,6 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { getApp, getApps, initializeApp } from '@react-native-firebase/app';
import messaging, { getMessaging } from '@react-native-firebase/messaging';
import { getMessaging, registerDeviceForRemoteMessages, setAutoInitEnabled } from '@react-native-firebase/messaging';
import * as Notifications from 'expo-notifications';
import { useEffect } from 'react';
import { PermissionsAndroid, Platform } from 'react-native';
@@ -20,20 +20,8 @@ const initializeFirebase = async () => {
try {
const app = getApps().length ? getApp() : initializeApp(RNfirebaseConfig);
const mess = getMessaging(app);
await messaging().registerDeviceForRemoteMessages();
// Set auto initialization and background message handler
mess.setAutoInitEnabled(true);
// mess.setBackgroundMessageHandler(async remoteMessage => {
// const screen = remoteMessage?.data?.category;
// const content = remoteMessage?.data?.content;
// if (screen && content) {
// await AsyncStorage.setItem('navigateOnOpen', JSON.stringify({ screen, content }));
// }
// });
await registerDeviceForRemoteMessages(mess);
setAutoInitEnabled(mess, true);
return mess
} catch (error) {
console.error('Failed to initialize Firebase:', error);
@@ -53,8 +41,10 @@ export const requestPermission = async () => {
}
return false
}
} else if (Platform.OS === 'ios') {
const { status } = await Notifications.requestPermissionsAsync();
return status === 'granted';
}
return true
} catch (err) {
console.warn('Error requesting notification permissions:', err);
}
@@ -62,8 +52,8 @@ export const requestPermission = async () => {
export const getToken = async () => {
try {
await initializeFirebase();
const token = await messaging().getToken();
const mess = await initializeFirebase();
const token = await mess?.getToken();
return token;
} catch (error) {
console.error("Error getting token:", error);
@@ -74,8 +64,6 @@ export const useNotification = () => {
useEffect(() => {
const initializeAndSetup = async () => {
try {
// await initializeFirebase();
// await requestPermission();
await getToken();
} catch (error) {
console.error('Failed to setup notifications:', error);

View File

@@ -56,6 +56,7 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
const permission = await requestPermission()
if (permission) {
try {
// COMING SOON
if (Platform.OS === 'android') {
const tokenDevice = await getToken()
const register = await apiRegisteredToken({ user: hasil, token: String(tokenDevice) })
@@ -78,8 +79,9 @@ export default function AuthProvider({ children }: { children: ReactNode }): Rea
const signOut = useCallback(async () => {
try {
const hasil = await decryptToken(String(tokenRef.current))
const token = await getToken()
// COMING SOON
if (Platform.OS === 'android') {
const token = await getToken()
const response = await apiUnregisteredToken({ user: hasil, token: String(token) })
}
} catch (error) {