Compare commits
2 Commits
api-voting
...
api/22-sep
| Author | SHA1 | Date | |
|---|---|---|---|
| 821a211f58 | |||
| 333b1d2512 |
@@ -125,7 +125,6 @@ export default function UserLayout() {
|
|||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="collaboration/[id]/edit"
|
name="collaboration/[id]/edit"
|
||||||
options={{
|
options={{
|
||||||
@@ -133,6 +132,13 @@ export default function UserLayout() {
|
|||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="collaboration/[id]/create-pacticipants"
|
||||||
|
options={{
|
||||||
|
title: "Ajukan Partisipasi",
|
||||||
|
headerLeft: () => <BackButton />,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* ========== End Collaboration Section ========= */}
|
{/* ========== End Collaboration Section ========= */}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,37 @@
|
|||||||
import { FloatingButton, ViewWrapper } from "@/components";
|
import {
|
||||||
|
FloatingButton,
|
||||||
|
LoaderCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
import Collaboration_BoxPublishSection from "@/screens/Collaboration/BoxPublishSection";
|
import Collaboration_BoxPublishSection from "@/screens/Collaboration/BoxPublishSection";
|
||||||
import { router } from "expo-router";
|
import { apiCollaborationGetAll } from "@/service/api-client/api-collaboration";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function CollaborationBeranda() {
|
export default function CollaborationBeranda() {
|
||||||
|
const [listData, setListData] = useState<any[]>();
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
const response = await apiCollaborationGetAll();
|
||||||
|
|
||||||
|
setListData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -15,13 +44,19 @@ export default function CollaborationBeranda() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadingGetData ? (
|
||||||
<Collaboration_BoxPublishSection
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
id={index.toString()}
|
<TextCustom align="center">Tidak ada data</TextCustom>
|
||||||
href={`/collaboration/${index}`}
|
) : (
|
||||||
/>
|
listData?.map((item: any, index: number) => (
|
||||||
))}
|
<Collaboration_BoxPublishSection
|
||||||
|
key={index}
|
||||||
|
href={`/collaboration/${item.id}`}
|
||||||
|
data={item}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import {
|
||||||
|
AlertDefaultSystem,
|
||||||
|
ButtonCustom,
|
||||||
|
TextAreaCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiCollaborationCreatePartisipasi } from "@/service/api-client/api-collaboration";
|
||||||
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function CollaborationCreatePartisipans() {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [description, setDescription] = useState("");
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handlerSubmitParticipans = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await apiCollaborationCreatePartisipasi({
|
||||||
|
id: id as string,
|
||||||
|
data: {
|
||||||
|
authorId: user?.id,
|
||||||
|
description,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Data berhasil disimpan",
|
||||||
|
});
|
||||||
|
router.replace(`/collaboration/${id}/list-of-participants`);
|
||||||
|
} else {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal menyimpan data",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ViewWrapper>
|
||||||
|
<TextAreaCustom
|
||||||
|
// label="Deskripsi"
|
||||||
|
placeholder="Masukan deskripsi diri anda .."
|
||||||
|
value={description}
|
||||||
|
onChangeText={setDescription}
|
||||||
|
required
|
||||||
|
showCount
|
||||||
|
maxLength={1000}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ButtonCustom
|
||||||
|
disabled={description.length === 0}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
AlertDefaultSystem({
|
||||||
|
title: "Simpan data deskripsi",
|
||||||
|
message: "Apakah anda sudah yakin ingin menyimpan data ini ?",
|
||||||
|
textLeft: "Batal",
|
||||||
|
textRight: "Simpan",
|
||||||
|
onPressRight: () => {
|
||||||
|
handlerSubmitParticipans();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</ButtonCustom>
|
||||||
|
</ViewWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,22 +1,73 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
|
||||||
BackButton,
|
BackButton,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
TextAreaCustom,
|
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Collaboration_BoxDetailSection from "@/screens/Collaboration/BoxDetailSection";
|
import Collaboration_BoxDetailSection from "@/screens/Collaboration/BoxDetailSection";
|
||||||
|
import {
|
||||||
|
apiCollaborationGetOne,
|
||||||
|
apiCollaborationGetParticipants,
|
||||||
|
} from "@/service/api-client/api-collaboration";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import {
|
||||||
import { useState } from "react";
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function CollaborationDetail() {
|
export default function CollaborationDetail() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawerPartisipasi, setOpenDrawerPartisipasi] = useState(false);
|
const [data, setData] = useState();
|
||||||
const [openDrawerMenu, setOpenDrawerMenu] = useState(false);
|
const [openDrawerMenu, setOpenDrawerMenu] = useState(false);
|
||||||
|
const [isParticipant, setIsParticipant] = useState(false);
|
||||||
|
const [loadingIsParticipant, setLoadingIsParticipant] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
onLoadParticipants();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiCollaborationGetOne({ id: id as string });
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onLoadParticipants = async () => {
|
||||||
|
try {
|
||||||
|
setLoadingIsParticipant(true);
|
||||||
|
const response = await apiCollaborationGetParticipants({
|
||||||
|
category: "check-participant",
|
||||||
|
id: id as string,
|
||||||
|
authorId: user?.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setIsParticipant(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingIsParticipant(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
@@ -29,15 +80,27 @@ export default function CollaborationDetail() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<Collaboration_BoxDetailSection id={id as string} />
|
{!data && !isParticipant ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Collaboration_BoxDetailSection data={data} />
|
||||||
|
|
||||||
<ButtonCustom onPress={() => setOpenDrawerPartisipasi(true)}>
|
<ButtonCustom
|
||||||
Partisipasi
|
disabled={isParticipant || loadingIsParticipant}
|
||||||
</ButtonCustom>
|
onPress={() => {
|
||||||
|
router.push(`/collaboration/${id}/create-pacticipants`);
|
||||||
|
// setOpenDrawerPartisipasi(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isParticipant ? "Anda telah berpartisipasi" : "Partisipasi"}
|
||||||
|
</ButtonCustom>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
{/* Drawer Partisipasi */}
|
{/* Drawer Partisipasi */}
|
||||||
<DrawerCustom
|
{/* <DrawerCustom
|
||||||
isVisible={openDrawerPartisipasi}
|
isVisible={openDrawerPartisipasi}
|
||||||
closeDrawer={() => setOpenDrawerPartisipasi(false)}
|
closeDrawer={() => setOpenDrawerPartisipasi(false)}
|
||||||
height={300}
|
height={300}
|
||||||
@@ -48,6 +111,8 @@ export default function CollaborationDetail() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={500}
|
maxLength={500}
|
||||||
|
value={description}
|
||||||
|
onChangeText={setDescription}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
@@ -58,19 +123,21 @@ export default function CollaborationDetail() {
|
|||||||
message: "Apakah anda sudah yakin ingin menyimpan data ini ?",
|
message: "Apakah anda sudah yakin ingin menyimpan data ini ?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Simpan",
|
textRight: "Simpan",
|
||||||
onPressRight: () => router.replace(`/collaboration/(tabs)/group`),
|
onPressRight: () => {
|
||||||
|
handlerSubmitParticipans();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</DrawerCustom>
|
</DrawerCustom> */}
|
||||||
|
|
||||||
{/* Drawer Menu */}
|
{/* Drawer Menu */}
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
isVisible={openDrawerMenu}
|
isVisible={openDrawerMenu}
|
||||||
closeDrawer={() => setOpenDrawerMenu(false)}
|
closeDrawer={() => setOpenDrawerMenu(false)}
|
||||||
height={250}
|
height={"auto"}
|
||||||
>
|
>
|
||||||
<MenuDrawerDynamicGrid
|
<MenuDrawerDynamicGrid
|
||||||
data={[
|
data={[
|
||||||
|
|||||||
@@ -1,38 +1,79 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AvatarUsernameAndOtherComponent,
|
AvatarUsernameAndOtherComponent,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
Spacing,
|
LoaderCustom,
|
||||||
StackCustom,
|
Spacing,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { apiCollaborationGetParticipants } from "@/service/api-client/api-collaboration";
|
||||||
import { Feather } from "@expo/vector-icons";
|
import { Feather } from "@expo/vector-icons";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import _ from "lodash";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
import { ScrollView } from "react-native";
|
import { ScrollView } from "react-native";
|
||||||
|
|
||||||
export default function CollaborationListOfParticipants() {
|
export default function CollaborationListOfParticipants() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = useState<any[]>();
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
const [description, setDescription] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
const response = await apiCollaborationGetParticipants({
|
||||||
|
category: "list",
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadingGetData ? (
|
||||||
<BaseBox key={index} paddingBlock={5}>
|
<LoaderCustom />
|
||||||
<AvatarUsernameAndOtherComponent
|
) : _.isEmpty(listData) ? (
|
||||||
avatarHref={`/profile/${id}`}
|
<TextCustom align="center">Tidak ada data</TextCustom>
|
||||||
rightComponent={
|
) : (
|
||||||
<Feather
|
listData?.map((item: any, index: number) => (
|
||||||
name="chevron-right"
|
<BaseBox key={index} paddingBlock={5}>
|
||||||
size={24}
|
<AvatarUsernameAndOtherComponent
|
||||||
color="white"
|
avatar={item?.User?.Profile?.imageId}
|
||||||
onPress={() => setOpenDrawer(true)}
|
avatarHref={`/profile/${item?.User?.Profile?.id}`}
|
||||||
/>
|
name={item?.User?.username}
|
||||||
}
|
rightComponent={
|
||||||
/>
|
<Feather
|
||||||
</BaseBox>
|
name="chevron-right"
|
||||||
))}
|
size={24}
|
||||||
|
color="white"
|
||||||
|
onPress={() => {
|
||||||
|
setDescription(item?.deskripsi_diri);
|
||||||
|
setOpenDrawer(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
{/* Drawer */}
|
{/* Drawer */}
|
||||||
@@ -44,34 +85,7 @@ export default function CollaborationListOfParticipants() {
|
|||||||
<TextCustom bold>Deskripsi diri</TextCustom>
|
<TextCustom bold>Deskripsi diri</TextCustom>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<ScrollView style={{ height: "80%" }}>
|
<ScrollView style={{ height: "80%" }}>
|
||||||
<TextCustom>
|
<TextCustom>{description}</TextCustom>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
||||||
eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
||||||
eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
|
|
||||||
ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
||||||
eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
|
|
||||||
ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
||||||
eiusmod tempor incididunt ut labore et dolore magna aliqua.Lorem
|
|
||||||
ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
||||||
eiusmod tempor incididunt ut iqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.Lorem ipsum dolor sit amet,
|
|
||||||
consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
||||||
labore et dolore magna aliqua.
|
|
||||||
</TextCustom>
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|||||||
@@ -1,53 +1,175 @@
|
|||||||
import {
|
import {
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
SelectCustom,
|
LoaderCustom,
|
||||||
StackCustom,
|
SelectCustom,
|
||||||
TextAreaCustom,
|
StackCustom,
|
||||||
TextInputCustom,
|
TextAreaCustom,
|
||||||
ViewWrapper
|
TextInputCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiCollaborationCreate } from "@/service/api-client/api-collaboration";
|
||||||
|
import { apiMasterCollaborationType } from "@/service/api-client/api-master";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
interface CollaborationCreateProps {
|
||||||
|
title?: string;
|
||||||
|
lokasi?: string;
|
||||||
|
purpose?: string;
|
||||||
|
benefit?: string;
|
||||||
|
projectCollaborationMaster_IndustriId?: string;
|
||||||
|
userId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function CollaborationCreate() {
|
export default function CollaborationCreate() {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [listMaster, setListMaster] = useState<any>([]);
|
||||||
|
const [loadingMaster, setLoadingMaster] = useState(false);
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [data, setData] = React.useState<CollaborationCreateProps>({
|
||||||
|
title: "",
|
||||||
|
lokasi: "",
|
||||||
|
purpose: "",
|
||||||
|
benefit: "",
|
||||||
|
projectCollaborationMaster_IndustriId: "",
|
||||||
|
userId: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onLoadMaster();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function onLoadMaster() {
|
||||||
|
try {
|
||||||
|
setLoadingMaster(true);
|
||||||
|
const response = await apiMasterCollaborationType();
|
||||||
|
setListMaster(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingMaster(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
if (
|
||||||
|
!data?.title ||
|
||||||
|
!data?.lokasi ||
|
||||||
|
!data?.purpose ||
|
||||||
|
!data?.benefit ||
|
||||||
|
!data?.projectCollaborationMaster_IndustriId
|
||||||
|
) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal",
|
||||||
|
text2: "Harap isi semua data",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newData: CollaborationCreateProps = {
|
||||||
|
title: data?.title,
|
||||||
|
lokasi: data?.lokasi,
|
||||||
|
purpose: data?.purpose,
|
||||||
|
benefit: data?.benefit,
|
||||||
|
projectCollaborationMaster_IndustriId:
|
||||||
|
data?.projectCollaborationMaster_IndustriId,
|
||||||
|
userId: user?.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
console.log("[DATA]>>", newData);
|
||||||
|
|
||||||
|
const response = await apiCollaborationCreate({ data: newData });
|
||||||
|
if (response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil",
|
||||||
|
text2: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} else {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal",
|
||||||
|
text2: response.message,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
{loadingMaster ? (
|
||||||
<TextInputCustom label="Judul" placeholder="Masukan judul" required />
|
<LoaderCustom />
|
||||||
<TextInputCustom label="Lokasi" placeholder="Masukan lokasi" required />
|
) : (
|
||||||
<SelectCustom
|
<StackCustom gap={"xs"}>
|
||||||
label="Pilih Industri"
|
<TextInputCustom
|
||||||
data={[
|
label="Judul"
|
||||||
{ label: "Industri 1", value: "industri-1" },
|
placeholder="Masukan judul"
|
||||||
{ label: "Industri 2", value: "industri-2" },
|
required
|
||||||
{ label: "Industri 3", value: "industri-3" },
|
value={data?.title}
|
||||||
]}
|
onChangeText={(value: any) => setData({ ...data, title: value })}
|
||||||
onChange={(value) => console.log(value)}
|
/>
|
||||||
/>
|
|
||||||
|
|
||||||
<TextAreaCustom
|
<TextInputCustom
|
||||||
required
|
label="Lokasi"
|
||||||
label="Tujuan Proyek"
|
placeholder="Masukan lokasi"
|
||||||
placeholder="Masukan tujuan proyek"
|
required
|
||||||
showCount
|
value={data?.lokasi}
|
||||||
maxLength={1000}
|
onChangeText={(value: any) => setData({ ...data, lokasi: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextAreaCustom
|
<SelectCustom
|
||||||
required
|
label="Pilih Industri"
|
||||||
label="Keuntungan Proyek"
|
data={listMaster?.map((item: any) => ({
|
||||||
placeholder="Masukan keuntungan proyek"
|
label: item.name,
|
||||||
showCount
|
value: item.id,
|
||||||
maxLength={1000}
|
}))}
|
||||||
/>
|
value={data?.projectCollaborationMaster_IndustriId}
|
||||||
|
onChange={(value: any) => {
|
||||||
|
console.log(value);
|
||||||
|
setData({
|
||||||
|
...data,
|
||||||
|
projectCollaborationMaster_IndustriId: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<ButtonCustom
|
<TextAreaCustom
|
||||||
title="Simpan"
|
required
|
||||||
onPress={() => {
|
label="Tujuan Proyek"
|
||||||
console.log("Simpan proyek");
|
placeholder="Masukan tujuan proyek"
|
||||||
router.back();
|
showCount
|
||||||
}}
|
maxLength={1000}
|
||||||
/>
|
value={data?.purpose}
|
||||||
</StackCustom>
|
onChangeText={(value: any) => setData({ ...data, purpose: value })}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextAreaCustom
|
||||||
|
required
|
||||||
|
label="Keuntungan Proyek"
|
||||||
|
placeholder="Masukan keuntungan proyek"
|
||||||
|
showCount
|
||||||
|
maxLength={1000}
|
||||||
|
value={data?.benefit}
|
||||||
|
onChangeText={(value: any) => setData({ ...data, benefit: value })}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
title="Simpan"
|
||||||
|
onPress={() => handlerSubmit()}
|
||||||
|
/>
|
||||||
|
</StackCustom>
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,57 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
|
LoaderCustom,
|
||||||
|
TextCustom,
|
||||||
ViewWrapper
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
||||||
|
import { apiVotingGetAll } from "@/service/api-client/api-voting";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useState, useCallback } from "react";
|
||||||
|
|
||||||
export default function VotingContribution() {
|
export default function VotingContribution() {
|
||||||
|
const { user } = useAuth();
|
||||||
|
const [listData, setListData] = useState<any>([]);
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
const response = await apiVotingGetAll({
|
||||||
|
category: "contribution",
|
||||||
|
authorId: user?.id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper hideFooter>
|
<ViewWrapper hideFooter>
|
||||||
{Array.from({ length: 5 }).map((_, index) => (
|
{loadingGetData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : _.isEmpty(listData) ? (
|
||||||
|
<TextCustom align="center">Tidak ada kontribusi</TextCustom>
|
||||||
|
) : listData.map((item: any, index: number) => (
|
||||||
<Voting_BoxPublishSection
|
<Voting_BoxPublishSection
|
||||||
|
data={item}
|
||||||
key={index}
|
key={index}
|
||||||
href={`/voting/${index}/contribution`}
|
href={`/voting/${item.id}/contribution`}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|||||||
@@ -1,11 +1,44 @@
|
|||||||
import { ViewWrapper } from "@/components";
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import { LoaderCustom, TextCustom, ViewWrapper } from "@/components";
|
||||||
import TabsTwoButtonCustom from "@/components/_ShareComponent/TabsTwoHeaderCustom";
|
import TabsTwoButtonCustom from "@/components/_ShareComponent/TabsTwoHeaderCustom";
|
||||||
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
||||||
import { useState } from "react";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { apiVotingGetAll } from "@/service/api-client/api-voting";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
|
||||||
export default function VotingHistory() {
|
export default function VotingHistory() {
|
||||||
|
const { user } = useAuth();
|
||||||
const [activeCategory, setActiveCategory] = useState<string | null>("all");
|
const [activeCategory, setActiveCategory] = useState<string | null>("all");
|
||||||
|
|
||||||
|
const [listData, setListData] = useState<any>([]);
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [activeCategory])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
const response = await apiVotingGetAll({
|
||||||
|
category: activeCategory === "all" ? "all-history" : "my-history",
|
||||||
|
authorId: user?.id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handlePress = (item: any) => {
|
const handlePress = (item: any) => {
|
||||||
setActiveCategory(item);
|
setActiveCategory(item);
|
||||||
// tambahkan logika lain seperti filter dsb.
|
// tambahkan logika lain seperti filter dsb.
|
||||||
@@ -25,13 +58,20 @@ export default function VotingHistory() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadingGetData ? (
|
||||||
<Voting_BoxPublishSection
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
id={activeCategory as any}
|
<TextCustom align="center">Tidak ada riwayat</TextCustom>
|
||||||
href={`/voting/${index}/history`}
|
) : (
|
||||||
/>
|
listData.map((item: any, index: number) => (
|
||||||
))}
|
<Voting_BoxPublishSection
|
||||||
|
key={index}
|
||||||
|
id={item.id}
|
||||||
|
data={item}
|
||||||
|
href={`/voting/${item.id}/history`}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,23 +8,28 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
||||||
import { apiVotingGetAll } from "@/service/api-client/api-voting";
|
import { apiVotingGetAll } from "@/service/api-client/api-voting";
|
||||||
import { router } from "expo-router";
|
import { router, useFocusEffect } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useEffect, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function VotingBeranda() {
|
export default function VotingBeranda() {
|
||||||
const [listData, setListData] = useState<any>([]);
|
const [listData, setListData] = useState<any>([]);
|
||||||
const [loadingGetData, setLoadingGetData] = useState(false);
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useFocusEffect(
|
||||||
onLoadData();
|
useCallback(() => {
|
||||||
}, [search]);
|
onLoadData();
|
||||||
|
}, [search])
|
||||||
|
);
|
||||||
|
|
||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
setLoadingGetData(true);
|
setLoadingGetData(true);
|
||||||
const response = await apiVotingGetAll({ search });
|
const response = await apiVotingGetAll({
|
||||||
|
search,
|
||||||
|
category: "beranda",
|
||||||
|
});
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setListData(response.data);
|
setListData(response.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,24 @@
|
|||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BackButton,
|
BackButton,
|
||||||
|
BaseBox,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
Spacing,
|
Spacing,
|
||||||
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconArchive, IconContribution, IconEdit } from "@/components/_Icon";
|
import { IconArchive, IconContribution, IconEdit } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
||||||
import { Voting_BoxDetailSection } from "@/screens/Voting/BoxDetailSection";
|
import { Voting_BoxDetailSection } from "@/screens/Voting/BoxDetailSection";
|
||||||
import Voting_ButtonStatusSection from "@/screens/Voting/ButtonStatusSection";
|
import Voting_ButtonStatusSection from "@/screens/Voting/ButtonStatusSection";
|
||||||
import { apiVotingGetOne } from "@/service/api-client/api-voting";
|
import {
|
||||||
|
apiVotingGetOne,
|
||||||
|
apiVotingUpdateData,
|
||||||
|
} from "@/service/api-client/api-voting";
|
||||||
import {
|
import {
|
||||||
router,
|
router,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -20,12 +27,14 @@ import {
|
|||||||
useLocalSearchParams,
|
useLocalSearchParams,
|
||||||
} from "expo-router";
|
} from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function VotingDetailStatus() {
|
export default function VotingDetailStatus() {
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [openDrawerDraft, setOpenDrawerDraft] = useState(false);
|
const [openDrawerDraft, setOpenDrawerDraft] = useState(false);
|
||||||
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
|
||||||
const [data, setData] = useState<any>(null);
|
const [data, setData] = useState<any>(null);
|
||||||
|
|
||||||
@@ -37,12 +46,16 @@ export default function VotingDetailStatus() {
|
|||||||
|
|
||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
const response = await apiVotingGetOne({ id: id as string });
|
const response = await apiVotingGetOne({ id: id as string });
|
||||||
if(response.success){
|
|
||||||
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,9 +72,24 @@ export default function VotingDetailStatus() {
|
|||||||
message: "Apakah Anda yakin ingin mengarsipkan voting ini?",
|
message: "Apakah Anda yakin ingin mengarsipkan voting ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Arsip voting");
|
try {
|
||||||
router.back();
|
const response = await apiVotingUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: data.isArsip ? false : true,
|
||||||
|
category: "archive",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -73,7 +101,7 @@ export default function VotingDetailStatus() {
|
|||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: `Detail ${status}`,
|
title: `Detail`,
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
headerRight: () =>
|
headerRight: () =>
|
||||||
status === "draft" ? (
|
status === "draft" ? (
|
||||||
@@ -84,14 +112,37 @@ export default function VotingDetailStatus() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<Voting_BoxDetailSection data={data as any} />
|
{loadingGetData ? (
|
||||||
<Voting_ButtonStatusSection
|
<LoaderCustom />
|
||||||
isLoading={isLoading}
|
) : (
|
||||||
onSetLoading={setIsLoading}
|
<>
|
||||||
id={id as string}
|
{status === "publish" && (
|
||||||
status={status as string}
|
<BaseBox>
|
||||||
/>
|
<TextCustom bold>
|
||||||
<Spacing />
|
Status:{" "}
|
||||||
|
<TextCustom color={data?.isArsip ? "red" : "green"}>
|
||||||
|
{data?.isArsip ? "Arsip" : "Publish"}
|
||||||
|
</TextCustom>
|
||||||
|
</TextCustom>
|
||||||
|
</BaseBox>
|
||||||
|
)}
|
||||||
|
<Spacing height={0} />
|
||||||
|
<Voting_BoxDetailSection data={data as any} />
|
||||||
|
{status === "publish" ? (
|
||||||
|
<Voting_BoxDetailHasilVotingSection
|
||||||
|
listData={data?.Voting_DaftarNamaVote}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Voting_ButtonStatusSection
|
||||||
|
isLoading={isLoading}
|
||||||
|
onSetLoading={setIsLoading}
|
||||||
|
id={id as string}
|
||||||
|
status={status as string}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Spacing />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
{/* ========= Draft Drawer ========= */}
|
{/* ========= Draft Drawer ========= */}
|
||||||
|
|||||||
@@ -1,22 +1,76 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AvatarUsernameAndOtherComponent,
|
AvatarUsernameAndOtherComponent,
|
||||||
BackButton,
|
BackButton,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
MenuDrawerDynamicGrid,
|
LoaderCustom,
|
||||||
Spacing,
|
MenuDrawerDynamicGrid,
|
||||||
ViewWrapper,
|
Spacing,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconContribution } from "@/components/_Icon";
|
import { IconContribution } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { Voting_BoxDetailContributionSection } from "@/screens/Voting/BoxDetailContribution";
|
import { Voting_BoxDetailContributionSection } from "@/screens/Voting/BoxDetailContribution";
|
||||||
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
||||||
|
import {
|
||||||
|
apiVotingContribution,
|
||||||
|
apiVotingGetOne,
|
||||||
|
} from "@/service/api-client/api-voting";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function VotingDetailContribution() {
|
export default function VotingDetailContribution() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
const [nameChoice, setNameChoice] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handlerLoadData();
|
||||||
|
}, [id, user?.id]);
|
||||||
|
|
||||||
|
async function handlerLoadData() {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
await onLoadData();
|
||||||
|
await onLoadCheckContribution();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiVotingGetOne({ id: id as string });
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onLoadCheckContribution = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiVotingContribution({
|
||||||
|
id: id as string,
|
||||||
|
authorId: user?.id as string,
|
||||||
|
category: "checked",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setNameChoice(response.data.nameChoice);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handlePressPublish = (item: IMenuDrawerItem) => {
|
const handlePressPublish = (item: IMenuDrawerItem) => {
|
||||||
router.navigate(item.path as any);
|
router.navigate(item.path as any);
|
||||||
@@ -36,11 +90,27 @@ export default function VotingDetailContribution() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<Voting_BoxDetailContributionSection
|
{loadingGetData ? (
|
||||||
headerAvatar={<AvatarUsernameAndOtherComponent />}
|
<LoaderCustom />
|
||||||
/>
|
) : (
|
||||||
<Voting_BoxDetailHasilVotingSection />
|
<>
|
||||||
<Spacing />
|
<Voting_BoxDetailContributionSection
|
||||||
|
data={data}
|
||||||
|
nameChoice={nameChoice}
|
||||||
|
headerAvatar={
|
||||||
|
<AvatarUsernameAndOtherComponent
|
||||||
|
avatar={data?.Author?.Profile?.imageId || ""}
|
||||||
|
name={data?.Author?.username || "Username"}
|
||||||
|
avatarHref={`/profile/${data?.Author?.Profile?.id}`}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Voting_BoxDetailHasilVotingSection
|
||||||
|
listData={data?.Voting_DaftarNamaVote}
|
||||||
|
/>
|
||||||
|
<Spacing />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
{/* ========= Publish Drawer ========= */}
|
{/* ========= Publish Drawer ========= */}
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ export default function VotingEdit() {
|
|||||||
const response = await apiVotingUpdateData({
|
const response = await apiVotingUpdateData({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
data: newData,
|
data: newData,
|
||||||
|
category: "edit",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
|
|||||||
@@ -1,23 +1,78 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AvatarUsernameAndOtherComponent,
|
AvatarUsernameAndOtherComponent,
|
||||||
BackButton,
|
BackButton,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
MenuDrawerDynamicGrid,
|
LoaderCustom,
|
||||||
Spacing,
|
MenuDrawerDynamicGrid,
|
||||||
ViewWrapper,
|
Spacing,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconContribution } from "@/components/_Icon";
|
import { IconContribution } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
||||||
import { Voting_BoxDetailHistorySection } from "@/screens/Voting/BoxDetailHistorySection";
|
import { Voting_BoxDetailHistorySection } from "@/screens/Voting/BoxDetailHistorySection";
|
||||||
|
import {
|
||||||
|
apiVotingContribution,
|
||||||
|
apiVotingGetOne,
|
||||||
|
} from "@/service/api-client/api-voting";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { router, Stack, useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function VotingDetailHistory() {
|
export default function VotingDetailHistory() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const { user } = useAuth();
|
||||||
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
||||||
|
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
const [loadingGetData, setLoadingGetData] = useState(false);
|
||||||
|
const [nameChoice, setNameChoice] = useState("");
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
handlerLoadData();
|
||||||
|
}, [id, user?.id]);
|
||||||
|
|
||||||
|
async function handlerLoadData() {
|
||||||
|
try {
|
||||||
|
setLoadingGetData(true);
|
||||||
|
await onLoadData();
|
||||||
|
await onLoadCheckContribution();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingGetData(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiVotingGetOne({ id: id as string });
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onLoadCheckContribution = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiVotingContribution({
|
||||||
|
id: id as string,
|
||||||
|
authorId: user?.id as string,
|
||||||
|
category: "checked",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setNameChoice(response.data.nameChoice);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handlePressPublish = (item: IMenuDrawerItem) => {
|
const handlePressPublish = (item: IMenuDrawerItem) => {
|
||||||
router.navigate(item.path as any);
|
router.navigate(item.path as any);
|
||||||
setOpenDrawerPublish(false);
|
setOpenDrawerPublish(false);
|
||||||
@@ -35,11 +90,27 @@ export default function VotingDetailHistory() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<Voting_BoxDetailHistorySection
|
{loadingGetData ? (
|
||||||
headerAvatar={<AvatarUsernameAndOtherComponent />}
|
<LoaderCustom />
|
||||||
/>
|
) : (
|
||||||
<Voting_BoxDetailHasilVotingSection />
|
<>
|
||||||
<Spacing />
|
<Voting_BoxDetailHistorySection
|
||||||
|
data={data}
|
||||||
|
nameChoice={nameChoice}
|
||||||
|
headerAvatar={
|
||||||
|
<AvatarUsernameAndOtherComponent
|
||||||
|
avatar={data?.Author?.Profile?.imageId || ""}
|
||||||
|
name={data?.Author?.username || "Username"}
|
||||||
|
avatarHref={`/profile/${data?.Author?.Profile?.id}`}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Voting_BoxDetailHasilVotingSection
|
||||||
|
listData={data?.Voting_DaftarNamaVote}
|
||||||
|
/>
|
||||||
|
<Spacing />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
{/* ========= Publish Drawer ========= */}
|
{/* ========= Publish Drawer ========= */}
|
||||||
|
|||||||
@@ -9,17 +9,19 @@ import {
|
|||||||
LoaderCustom,
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconArchive, IconContribution } from "@/components/_Icon";
|
import { IconArchive, IconContribution } from "@/components/_Icon";
|
||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
import Voting_BoxDetailHasilVotingSection from "@/screens/Voting/BoxDetailHasilVotingSection";
|
||||||
import { Voting_BoxDetailPublishSection } from "@/screens/Voting/BoxDetailPublishSection";
|
import { Voting_BoxDetailPublishSection } from "@/screens/Voting/BoxDetailPublishSection";
|
||||||
import {
|
import {
|
||||||
apiVotingCheckContribution,
|
apiVotingContribution,
|
||||||
apiVotingGetOne,
|
apiVotingGetOne,
|
||||||
|
apiVotingUpdateData,
|
||||||
} from "@/service/api-client/api-voting";
|
} from "@/service/api-client/api-voting";
|
||||||
|
import { today } from "@/utils/dateTimeView";
|
||||||
import {
|
import {
|
||||||
router,
|
router,
|
||||||
Stack,
|
Stack,
|
||||||
@@ -27,14 +29,11 @@ import {
|
|||||||
useLocalSearchParams,
|
useLocalSearchParams,
|
||||||
} from "expo-router";
|
} from "expo-router";
|
||||||
import React, { useCallback, useState } from "react";
|
import React, { useCallback, useState } from "react";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function VotingDetail() {
|
export default function VotingDetail() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
console.log("[ID]", id);
|
|
||||||
const dateNow = new Date();
|
|
||||||
console.log("[DATE NOW]", dateNow);
|
|
||||||
|
|
||||||
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
||||||
const [data, setData] = useState<any>(null);
|
const [data, setData] = useState<any>(null);
|
||||||
@@ -42,8 +41,6 @@ export default function VotingDetail() {
|
|||||||
const [isContribution, setIsContribution] = useState(false);
|
const [isContribution, setIsContribution] = useState(false);
|
||||||
const [nameChoice, setNameChoice] = useState("");
|
const [nameChoice, setNameChoice] = useState("");
|
||||||
|
|
||||||
console.log("[DATA AWAL]", data?.awalVote);
|
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
handlerLoadData();
|
handlerLoadData();
|
||||||
@@ -65,7 +62,6 @@ export default function VotingDetail() {
|
|||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiVotingGetOne({ id: id as string });
|
const response = await apiVotingGetOne({ id: id as string });
|
||||||
// console.log("[DATA]", JSON.stringify(response.data, null, 2));
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
@@ -76,11 +72,12 @@ export default function VotingDetail() {
|
|||||||
|
|
||||||
const onLoadCheckContribution = async () => {
|
const onLoadCheckContribution = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiVotingCheckContribution({
|
const response = await apiVotingContribution({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
authorId: user?.id as string,
|
authorId: user?.id as string,
|
||||||
|
category: "checked",
|
||||||
});
|
});
|
||||||
console.log("[DATA CONTRIBUION]", response.data);
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setIsContribution(response.data.isContribution);
|
setIsContribution(response.data.isContribution);
|
||||||
setNameChoice(response.data.nameChoice);
|
setNameChoice(response.data.nameChoice);
|
||||||
@@ -97,9 +94,24 @@ export default function VotingDetail() {
|
|||||||
message: "Apakah Anda yakin ingin mengarsipkan voting ini?",
|
message: "Apakah Anda yakin ingin mengarsipkan voting ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Hapus");
|
try {
|
||||||
router.back();
|
const response = await apiVotingUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: data.isArsip ? false : true,
|
||||||
|
category: "archive",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -124,8 +136,8 @@ export default function VotingDetail() {
|
|||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : (
|
) : (
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
{dateNow < new Date(data?.awalVote) && (
|
{today.getDate() < new Date(data?.awalVote).getDate() && (
|
||||||
<InformationBox text="Untuk sementara voting ini belum di buka. Voting akan dimulai sesuai dengan tanggal awal pemilihan, dan akan ditutup sesuai dengan tanggal akhir pemilihan." />
|
<InformationBox text="Untuk sementara voting tidak dapat dilakukan. Voting dapat dimulai sesuai dengan tanggal awal pemilihan, dan akan ditutup sesuai dengan tanggal akhir pemilihan." />
|
||||||
)}
|
)}
|
||||||
<Voting_BoxDetailPublishSection
|
<Voting_BoxDetailPublishSection
|
||||||
data={data}
|
data={data}
|
||||||
@@ -155,18 +167,28 @@ export default function VotingDetail() {
|
|||||||
height={"auto"}
|
height={"auto"}
|
||||||
>
|
>
|
||||||
<MenuDrawerDynamicGrid
|
<MenuDrawerDynamicGrid
|
||||||
data={[
|
data={
|
||||||
{
|
user?.id === data?.Author?.id
|
||||||
icon: <IconContribution />,
|
? [
|
||||||
label: "Daftar Kontributor",
|
{
|
||||||
path: `/voting/${id}/list-of-contributor`,
|
icon: <IconContribution />,
|
||||||
},
|
label: "Daftar Kontributor",
|
||||||
{
|
path: `/voting/${id}/list-of-contributor`,
|
||||||
icon: <IconArchive />,
|
},
|
||||||
label: "Update Arsip",
|
{
|
||||||
path: "" as any,
|
icon: <IconArchive />,
|
||||||
},
|
label: "Update Arsip",
|
||||||
]}
|
path: "" as any,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
icon: <IconContribution />,
|
||||||
|
label: "Daftar Kontributor",
|
||||||
|
path: `/voting/${id}/list-of-contributor`,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
onPressItem={handlePressPublish as any}
|
onPressItem={handlePressPublish as any}
|
||||||
/>
|
/>
|
||||||
</DrawerCustom>
|
</DrawerCustom>
|
||||||
|
|||||||
@@ -1,26 +1,69 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AvatarUsernameAndOtherComponent,
|
AvatarUsernameAndOtherComponent,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
|
LoaderCustom,
|
||||||
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { apiVotingContribution } from "@/service/api-client/api-voting";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function Voting_ListOfContributor() {
|
export default function Voting_ListOfContributor() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = useState<any>([]);
|
||||||
|
const [isLoadData, setIsLoadData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadList();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadList = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoadData(true);
|
||||||
|
const response = await apiVotingContribution({
|
||||||
|
id: id as string,
|
||||||
|
authorId: "",
|
||||||
|
category: "list",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{isLoadData ? (
|
||||||
<BaseBox paddingTop={5} paddingBottom={5} key={index.toString()}>
|
<LoaderCustom />
|
||||||
<AvatarUsernameAndOtherComponent
|
) : _.isEmpty(listData) ? (
|
||||||
rightComponent={
|
<TextCustom align="center">Tidak ada kontributor</TextCustom>
|
||||||
<BadgeCustom
|
) : (
|
||||||
style={{alignSelf: "flex-end" }}
|
listData.map((item: any, index: number) => (
|
||||||
>
|
<BaseBox paddingTop={5} paddingBottom={5} key={index.toString()}>
|
||||||
Pilihan {index + 1}
|
<AvatarUsernameAndOtherComponent
|
||||||
</BadgeCustom>
|
avatar={item?.Author?.Profile?.imageId || ""}
|
||||||
}
|
name={item?.Author?.username || "Username"}
|
||||||
/>
|
avatarHref={`/profile/${item?.Author?.Profile?.id}`}
|
||||||
</BaseBox>
|
rightComponent={
|
||||||
))}
|
<BadgeCustom style={{ alignSelf: "flex-end" }}>
|
||||||
|
{item?.Voting_DaftarNamaVote?.value}
|
||||||
|
</BadgeCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { AccentColor } from "@/constants/color-palet";
|
||||||
import Divider from "../Divider/Divider";
|
import Divider from "../Divider/Divider";
|
||||||
import Grid from "../Grid/GridCustom";
|
import Grid from "../Grid/GridCustom";
|
||||||
import AvatarComp from "../Image/AvatarComp";
|
import AvatarComp from "../Image/AvatarComp";
|
||||||
@@ -39,7 +40,7 @@ const AvatarUsernameAndOtherComponent = ({
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
)}
|
)}
|
||||||
</Grid>
|
</Grid>
|
||||||
{withBottomLine && <Divider marginTop={0} />}
|
{withBottomLine && <Divider color={AccentColor.blue} marginTop={0} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,22 +1,33 @@
|
|||||||
import {
|
import {
|
||||||
AvatarUsernameAndOtherComponent,
|
AvatarUsernameAndOtherComponent,
|
||||||
BoxWithHeaderSection,
|
BoxWithHeaderSection,
|
||||||
Grid,
|
Grid,
|
||||||
StackCustom,
|
Spacing,
|
||||||
TextCustom
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
|
||||||
export default function Collaboration_BoxDetailSection({ id }: { id: string }) {
|
export default function Collaboration_BoxDetailSection({
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoxWithHeaderSection>
|
<BoxWithHeaderSection>
|
||||||
|
<AvatarUsernameAndOtherComponent
|
||||||
|
avatar={data?.Author?.Profile?.imageId}
|
||||||
|
name={data?.Author?.username}
|
||||||
|
avatarHref={`/profile/${data?.Author?.Profile?.id}`}
|
||||||
|
withBottomLine
|
||||||
|
/>
|
||||||
|
<Spacing height={10}/>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<AvatarUsernameAndOtherComponent />
|
|
||||||
<TextCustom align="center" bold size="large">
|
<TextCustom align="center" bold size="large">
|
||||||
Judul Proyek {id}
|
{data?.title || ""}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
|
|
||||||
{listData.map((item, index) => (
|
{listData(data).map((item, index) => (
|
||||||
<Grid key={index}>
|
<Grid key={index}>
|
||||||
<Grid.Col span={4}>
|
<Grid.Col span={4}>
|
||||||
<TextCustom bold>{item.title}</TextCustom>
|
<TextCustom bold>{item.title}</TextCustom>
|
||||||
@@ -32,23 +43,21 @@ export default function Collaboration_BoxDetailSection({ id }: { id: string }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
const listData = (data: any) => [
|
||||||
{
|
{
|
||||||
title: "Industri",
|
title: "Industri",
|
||||||
value: "Pilihan Industri",
|
value: data?.ProjectCollaborationMaster_Industri?.name || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Deskripsi",
|
title: "Lokasi",
|
||||||
value: "Deskripsi Proyek",
|
value: data?.lokasi || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Tujuan Proyek",
|
title: "Tujuan Proyek",
|
||||||
value:
|
value: data?.purpose || "-",
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Keuntungan Proyek",
|
title: "Keuntungan Proyek",
|
||||||
value:
|
value: data?.benefit || "-",
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -7,24 +7,12 @@ import {
|
|||||||
import { Href } from "expo-router";
|
import { Href } from "expo-router";
|
||||||
|
|
||||||
function Collaboration_BoxPublishSection({
|
function Collaboration_BoxPublishSection({
|
||||||
id,
|
|
||||||
title,
|
|
||||||
username,
|
|
||||||
description,
|
|
||||||
href,
|
href,
|
||||||
|
data,
|
||||||
// Avatar
|
|
||||||
sourceAvatar,
|
|
||||||
rightComponentAvatar,
|
rightComponentAvatar,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
|
||||||
title?: string;
|
|
||||||
username?: string;
|
|
||||||
description?: string;
|
|
||||||
href: Href;
|
href: Href;
|
||||||
|
data: any;
|
||||||
// Avatar
|
|
||||||
sourceAvatar?: string;
|
|
||||||
rightComponentAvatar?: React.ReactNode;
|
rightComponentAvatar?: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -32,21 +20,18 @@ function Collaboration_BoxPublishSection({
|
|||||||
<BoxWithHeaderSection href={href}>
|
<BoxWithHeaderSection href={href}>
|
||||||
<StackCustom gap={0}>
|
<StackCustom gap={0}>
|
||||||
<AvatarUsernameAndOtherComponent
|
<AvatarUsernameAndOtherComponent
|
||||||
avatarHref={`/profile/${id}`}
|
avatarHref={`/profile/${data?.Author?.id}`}
|
||||||
name={username || "Username"}
|
name={data?.Author?.username || "Username"}
|
||||||
rightComponent={rightComponentAvatar}
|
rightComponent={rightComponentAvatar}
|
||||||
avatar={sourceAvatar as any}
|
avatar={data?.Author?.Profile?.imageId}
|
||||||
withBottomLine
|
withBottomLine
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom truncate={2} size="large" bold align="center">
|
<TextCustom truncate={2} size="large" bold align="center">
|
||||||
{title || "Lorem ipsum dolor sit"}
|
{data?.title || "-"}
|
||||||
</TextCustom>
|
|
||||||
<TextCustom truncate={2}>
|
|
||||||
{description ||
|
|
||||||
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Porro sed doloremque tempora soluta. Dolorem ex quidem ipsum tempora, ipsa, obcaecati quia suscipit numquam, voluptates commodi porro impedit natus quos doloremque!"}
|
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
|
<TextCustom truncate={2}>{data?.purpose || "-"}</TextCustom>
|
||||||
{/* <TextCustom bold size="small" >
|
{/* <TextCustom bold size="small" >
|
||||||
2 Partisipan
|
2 Partisipan
|
||||||
</TextCustom> */}
|
</TextCustom> */}
|
||||||
|
|||||||
@@ -9,23 +9,32 @@ import { GStyles } from "@/styles/global-styles";
|
|||||||
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
||||||
|
|
||||||
export function Voting_BoxDetailContributionSection({
|
export function Voting_BoxDetailContributionSection({
|
||||||
|
data,
|
||||||
headerAvatar,
|
headerAvatar,
|
||||||
|
nameChoice,
|
||||||
}: {
|
}: {
|
||||||
|
data: any;
|
||||||
headerAvatar?: React.ReactNode;
|
headerAvatar?: React.ReactNode;
|
||||||
|
nameChoice?: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoxWithHeaderSection>
|
<BoxWithHeaderSection>
|
||||||
{headerAvatar ? headerAvatar : <Spacing />}
|
{headerAvatar && (
|
||||||
|
<>
|
||||||
|
{headerAvatar}
|
||||||
|
<Spacing />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<StackCustom gap={"lg"}>
|
<StackCustom gap={"lg"}>
|
||||||
<Voting_ComponentDetailDataSection />
|
<Voting_ComponentDetailDataSection data={data} />
|
||||||
|
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"sm"}>
|
||||||
<TextCustom bold size="small" align="center">
|
<TextCustom bold size="small" align="center">
|
||||||
Pilihan Anda
|
Pilihan Anda
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<BadgeCustom style={[GStyles.alignSelfCenter]}>
|
<BadgeCustom variant="light" size="lg" style={[GStyles.alignSelfCenter]}>
|
||||||
Pilihan 1
|
{nameChoice || "-"}
|
||||||
</BadgeCustom>
|
</BadgeCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
export default function Voting_BoxDetailHasilVotingSection({
|
export default function Voting_BoxDetailHasilVotingSection({
|
||||||
listData,
|
listData,
|
||||||
}: {
|
}: {
|
||||||
listData?: any[];
|
listData: any[];
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,21 +1,36 @@
|
|||||||
import {
|
import {
|
||||||
|
BadgeCustom,
|
||||||
BoxWithHeaderSection,
|
BoxWithHeaderSection,
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom
|
StackCustom,
|
||||||
|
TextCustom
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
||||||
|
import { GStyles } from "@/styles/global-styles";
|
||||||
|
|
||||||
export function Voting_BoxDetailHistorySection({
|
export function Voting_BoxDetailHistorySection({
|
||||||
headerAvatar,
|
headerAvatar,
|
||||||
|
data,
|
||||||
|
nameChoice,
|
||||||
}: {
|
}: {
|
||||||
headerAvatar?: React.ReactNode;
|
headerAvatar?: React.ReactNode;
|
||||||
|
data: any;
|
||||||
|
nameChoice: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoxWithHeaderSection>
|
<BoxWithHeaderSection>
|
||||||
{headerAvatar ? headerAvatar : <Spacing />}
|
{headerAvatar ? headerAvatar : <Spacing />}
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<Voting_ComponentDetailDataSection />
|
<Voting_ComponentDetailDataSection data={data} />
|
||||||
|
<StackCustom gap={"sm"}>
|
||||||
|
<TextCustom bold size="small" align="center">
|
||||||
|
Pilihan Anda
|
||||||
|
</TextCustom>
|
||||||
|
<BadgeCustom variant="light" size="lg" style={[GStyles.alignSelfCenter]}>
|
||||||
|
{nameChoice || "-"}
|
||||||
|
</BadgeCustom>
|
||||||
|
</StackCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BoxWithHeaderSection>
|
</BoxWithHeaderSection>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
import {
|
import {
|
||||||
|
AlertDefaultSystem,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BoxWithHeaderSection,
|
BoxWithHeaderSection,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
CenterCustom,
|
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
||||||
|
import { apiVotingVote } from "@/service/api-client/api-voting";
|
||||||
|
import { today } from "@/utils/dateTimeView";
|
||||||
|
import { router } from "expo-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
import { Voting_ComponentDetailDataSection } from "./ComponentDetailDataSection";
|
||||||
import { apiVotingVote } from "@/service/api-client/api-voting";
|
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
|
||||||
|
|
||||||
export function Voting_BoxDetailPublishSection({
|
export function Voting_BoxDetailPublishSection({
|
||||||
headerAvatar,
|
headerAvatar,
|
||||||
@@ -40,7 +41,10 @@ export function Voting_BoxDetailPublishSection({
|
|||||||
id: data?.id,
|
id: data?.id,
|
||||||
data: newData,
|
data: newData,
|
||||||
});
|
});
|
||||||
console.log("[RES VOTE]", response);
|
|
||||||
|
if (response.success) {
|
||||||
|
router.push(`/voting/${data?.id}/list-of-contributor`);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
}
|
}
|
||||||
@@ -79,13 +83,30 @@ export function Voting_BoxDetailPublishSection({
|
|||||||
<RadioGroup value={value} onChange={setValue}>
|
<RadioGroup value={value} onChange={setValue}>
|
||||||
{data?.Voting_DaftarNamaVote?.map((item: any, i: number) => (
|
{data?.Voting_DaftarNamaVote?.map((item: any, i: number) => (
|
||||||
<View key={i}>
|
<View key={i}>
|
||||||
<RadioCustom label={item?.value} value={item?.id} />
|
<RadioCustom
|
||||||
|
disabled={
|
||||||
|
today.getDate() < new Date(data?.awalVote).getDate()
|
||||||
|
}
|
||||||
|
label={item?.value}
|
||||||
|
value={item?.id}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|
||||||
<ButtonCustom disabled={value === ""} onPress={handlerSubmitVote}>
|
<ButtonCustom
|
||||||
|
disabled={value === ""}
|
||||||
|
onPress={() => {
|
||||||
|
AlertDefaultSystem({
|
||||||
|
title: "Anda melaukan voting",
|
||||||
|
message: "Yakin dengan pilihan anda ini ?",
|
||||||
|
textLeft: "Batal",
|
||||||
|
textRight: "Ya",
|
||||||
|
onPressRight: () => handlerSubmitVote(),
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
Vote
|
Vote
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</>
|
</>
|
||||||
|
|||||||
71
service/api-client/api-collaboration.ts
Normal file
71
service/api-client/api-collaboration.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export async function apiCollaborationCreate({ data }: { data: any }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/collaboration`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiCollaborationGetAll() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/collaboration`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiCollaborationGetOne({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/collaboration/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiCollaborationCreatePartisipasi({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(
|
||||||
|
`/mobile/collaboration/${id}/participants`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiCollaborationGetParticipants({
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
authorId,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
category: "list" | "check-participant";
|
||||||
|
authorId?: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const authorQuery = authorId ? `&authorId=${authorId}` : "";
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/collaboration/${id}/participants?category=${category}${authorQuery}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,4 +28,13 @@ export async function apiMasterEventType() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiMasterCollaborationType() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/master/collaboration-industry`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,12 +62,15 @@ export async function apiVotingDelete({ id }: { id: string }) {
|
|||||||
export async function apiVotingUpdateData({
|
export async function apiVotingUpdateData({
|
||||||
id,
|
id,
|
||||||
data,
|
data,
|
||||||
|
category,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
data: any;
|
data: any;
|
||||||
|
category: "edit" | "archive";
|
||||||
}) {
|
}) {
|
||||||
|
const categoryQuery = `?category=${category}`;
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.put(`/mobile/voting/${id}`, {
|
const response = await apiConfig.put(`/mobile/voting/${id}${categoryQuery}`, {
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
return response.data;
|
return response.data;
|
||||||
@@ -76,10 +79,12 @@ export async function apiVotingUpdateData({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiVotingGetAll({ search }: { search: string }) {
|
export async function apiVotingGetAll({ search, category, authorId }: { search?: string, category: "beranda" | "contribution" | "all-history" | "my-history", authorId?: string }) {
|
||||||
try {
|
try {
|
||||||
const searchQuery = search ? `?search=${search}` : "";
|
const categoryQuery = category ? `?category=${category}` : "";
|
||||||
const response = await apiConfig.get(`/mobile/voting${searchQuery}`);
|
const searchQuery = search ? `&search=${search}` : "";
|
||||||
|
const authorIdQuery = authorId ? `&authorId=${authorId}` : "";
|
||||||
|
const response = await apiConfig.get(`/mobile/voting${categoryQuery}${searchQuery}${authorIdQuery}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
@@ -97,18 +102,23 @@ export async function apiVotingVote({ id, data }: { id: string; data: any }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiVotingCheckContribution({
|
export async function apiVotingContribution({
|
||||||
id,
|
id,
|
||||||
authorId,
|
authorId,
|
||||||
|
category,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
authorId: string;
|
authorId: string;
|
||||||
|
category: "list" | "checked";
|
||||||
}) {
|
}) {
|
||||||
|
const query =
|
||||||
|
category === "list"
|
||||||
|
? "?category=list"
|
||||||
|
: `?category=checked&authorId=${authorId}`;
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.get(
|
const response = await apiConfig.get(
|
||||||
`/mobile/voting/${id}/contribution?authorId=${authorId}`
|
`/mobile/voting/${id}/contribution${query}`
|
||||||
);
|
);
|
||||||
console.log("[DATA CONTRIBUION]", response.data);
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
|
export const today = new Date();
|
||||||
export const dateTimeView = ({
|
export const dateTimeView = ({
|
||||||
date,
|
date,
|
||||||
withoutTime = false,
|
withoutTime = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user