From 70d7f4a679eed5a9e149a468df5e6e1fc77003aa Mon Sep 17 00:00:00 2001 From: n0izn0iz Date: Thu, 28 Nov 2024 02:55:54 +0100 Subject: [PATCH] feat: tns update proposal preview (#1413) Signed-off-by: Norman Meier --- .../teritoriNameService/MediaPreview.tsx | 27 +++++++++---- .../teritoriNameService/NameDataForm.tsx | 2 +- packages/components/tx/getTxInfo.tsx | 40 +++++++++++++++++++ .../components/user/forms/EditProfileForm.tsx | 2 +- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/packages/components/teritoriNameService/MediaPreview.tsx b/packages/components/teritoriNameService/MediaPreview.tsx index 3149c51fec..9dddc5662b 100644 --- a/packages/components/teritoriNameService/MediaPreview.tsx +++ b/packages/components/teritoriNameService/MediaPreview.tsx @@ -1,7 +1,7 @@ import * as DocumentPicker from "expo-document-picker"; import { DocumentPickerResult } from "expo-document-picker"; import React, { Dispatch, SetStateAction, useState } from "react"; -import { ActivityIndicator, View, ViewStyle } from "react-native"; +import { ActivityIndicator, StyleProp, View, ViewStyle } from "react-native"; import { useSelector } from "react-redux"; import tnsProfileAvatar from "../../../assets/default-images/default-name-nft.png"; @@ -26,15 +26,17 @@ import { SVG } from "../SVG"; import { TextInputCustom } from "../inputs/TextInputCustom"; export const MediaPreview: React.FC<{ - style: ViewStyle; + style?: StyleProp; + textInputsStyle?: StyleProp; avatarImageUrl: string; - setAvatarImageUrl: Dispatch>; + setAvatarImageUrl?: Dispatch>; bannerImageUrl: string; - setBannerImageUrl: Dispatch>; + setBannerImageUrl?: Dispatch>; variant?: "regular" | "labelOutside" | "noStyle"; hasPadding?: boolean; }> = ({ style, + textInputsStyle, avatarImageUrl, setAvatarImageUrl, bannerImageUrl, @@ -77,6 +79,9 @@ export const MediaPreview: React.FC<{ }; const onPressUploadAvatar = async () => { + if (!setAvatarImageUrl) { + return; + } const documentPickerResult = await DocumentPicker.getDocumentAsync({ multiple: false, }); @@ -86,6 +91,9 @@ export const MediaPreview: React.FC<{ }; const onPressUploadBanner = async () => { + if (!setBannerImageUrl) { + return; + } const documentPickerResult = await DocumentPicker.getDocumentAsync({ multiple: false, }); @@ -104,16 +112,18 @@ export const MediaPreview: React.FC<{ marginBottom: layout.spacing_x1, padding: layout.spacing_x1_5, }, + style, ]} > name="image" - style={style} + style={textInputsStyle} label="Avatar URL" noBrokenCorners variant={variant} placeHolder="https://website.com/avatar.jpg" onPressChildren={onPressUploadAvatar} + disabled={!onPressUploadAvatar} value={avatarImageUrl} onChangeText={setAvatarImageUrl} squaresBackgroundColor={neutral17} @@ -127,10 +137,11 @@ export const MediaPreview: React.FC<{ name="public_profile_header" - style={style} + style={textInputsStyle} label="Cover Image URL" noBrokenCorners onPressChildren={onPressUploadBanner} + disabled={!onPressUploadBanner} variant={variant} placeHolder="https://website.com/coverimage.jpg" value={bannerImageUrl} @@ -152,8 +163,8 @@ export const MediaPreview: React.FC<{ > ); }; + } else if ( + network?.kind === NetworkKind.Cosmos && + contractAddress === network.nameServiceContractAddress && + method === "update_metadata" + ) { + icon = feedWhiteSVG; + name = "Update profile"; + preview = () => { + return ( + + Update {execMsg[method].token_id} + + + Display name:{" "} + + {execMsg[method].metadata.public_name} + + + + + Bio:{" "} + + {execMsg[method].metadata.public_bio} + + + + + + ); + }; } if (!preview) { preview = () => { diff --git a/packages/components/user/forms/EditProfileForm.tsx b/packages/components/user/forms/EditProfileForm.tsx index 6551c1d37c..60e22f449b 100644 --- a/packages/components/user/forms/EditProfileForm.tsx +++ b/packages/components/user/forms/EditProfileForm.tsx @@ -217,7 +217,7 @@ export const EditProfileForm: React.FC<{ render={({ field: { onChange } }) => (