Profile
Fix: - profile/[id]/edit.tsx: api upload - profile/[id]/update-photo.tsx: api upload - service/api-client/api-profile.ts: api profile bisa memilih kategori Component Add: - components/Image/AvatarComp.tsx ### No Issue
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { LandscapeFrameUploaded, ViewWrapper } from "@/components";
|
||||
import { ViewWrapper } from "@/components";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import { Image } from "expo-image";
|
||||
import { useLocalSearchParams } from "expo-router";
|
||||
|
||||
export default function PreviewImage() {
|
||||
const { id } = useLocalSearchParams();
|
||||
return (
|
||||
<ViewWrapper>
|
||||
<LandscapeFrameUploaded />
|
||||
<Image source={API_STRORAGE.GET({ fileId: id as string })} contentFit="contain" style={{ width: "100%", height: "100%" }}/>
|
||||
</ViewWrapper>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ export default function ProfileEdit() {
|
||||
const handleUpdate = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await apiUpdateProfile({ id: id as string, data });
|
||||
const response = await apiUpdateProfile({
|
||||
id: id as string,
|
||||
data,
|
||||
category: "profile",
|
||||
});
|
||||
if (!response.success) {
|
||||
Toast.show({
|
||||
type: "info",
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import {
|
||||
AvatarCustom,
|
||||
BaseBox,
|
||||
BoxButtonOnFooter,
|
||||
ButtonCenteredOnly,
|
||||
ButtonCustom,
|
||||
ButtonCustom
|
||||
} from "@/components";
|
||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||
import DIRECTORY_ID from "@/constants/directory-id";
|
||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
||||
import { apiProfile } from "@/service/api-client/api-profile";
|
||||
import { apiProfile, apiUpdateProfile } from "@/service/api-client/api-profile";
|
||||
import { uploadImageService } from "@/service/upload-service";
|
||||
import { IProfile } from "@/types/Type-Profile";
|
||||
import pickImage from "@/utils/pickImage";
|
||||
@@ -53,6 +52,12 @@ export default function UpdatePhotoProfile() {
|
||||
|
||||
console.log("Upload res >>", JSON.stringify(response, null, 2));
|
||||
if (response.success) {
|
||||
const imageId = response.data.id;
|
||||
await apiUpdateProfile({
|
||||
id: id as string,
|
||||
data: { imageId },
|
||||
category: "photo",
|
||||
});
|
||||
router.back();
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -78,15 +83,15 @@ export default function UpdatePhotoProfile() {
|
||||
);
|
||||
|
||||
const image = imageUri ? (
|
||||
<Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
|
||||
<Image source={{ uri: imageUri }} style={{ width: "100%", height: "100%" }} />
|
||||
) : (
|
||||
<AvatarCustom
|
||||
size="xl"
|
||||
<Image
|
||||
source={
|
||||
data?.imageId
|
||||
? API_STRORAGE.GET({ fileId: data.imageId })
|
||||
? { uri: API_STRORAGE.GET({ fileId: data.imageId }) }
|
||||
: DUMMY_IMAGE.avatar
|
||||
}
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user