Skip to content

Commit

Permalink
Fix Capitalization & Display Issues (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans authored Nov 23, 2023
1 parent f9f3d25 commit 48ce20d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion web/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const DEVELOPER_MODE = false;
export const App = () => {
// eslint-disable-next-line no-undef
const path = window.location.pathname;
const name = path.replace('/', '');
const name = path.replace('/', '').toLowerCase();

if (name.length === 0) {
return <Home />;
Expand Down
34 changes: 26 additions & 8 deletions web/src/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ type ProfileResponse = {

type EnstateResponse = {
name: string;
display: string;
avatar: string;
header: string;
records: Record<string, string>;
chains: Record<string, string>;
};
Expand All @@ -54,7 +56,14 @@ export const getProfile = async (name: string) => {

const data: ProfileResponse = await request.json();

return data;
return {
...data,
display:
data.records['display'].toLowerCase() == name
? data.records['display']
: undefined,
chains: data.addresses,
};
} catch {
console.log('Failed to load from ccip gateway');
}
Expand All @@ -63,10 +72,18 @@ export const getProfile = async (name: string) => {

if (!data) return;

data.records['header'] = data.header;
data.records['avatar'] = data.avatar;
data.chains['60'] = data.chains['eth'];

return { ...data, records: data.records, addresses: data.chains };
return data;

// return {
// ...data,
// display: data.display,
// records: data.records,
// addresses: data.chains,
// };
};

const postUpdateProfile = async (
Expand Down Expand Up @@ -126,7 +143,7 @@ export const Profile: FC<{ name: string }> = ({ name }) => {
'0xdCcB68ac05BB2Ee83F0873DCd0BF5F57E2968344'.toLowerCase();
const canChangeResolver =
ownerData?.toString().toLowerCase() === address?.toLowerCase();
const isOwner = data?.addresses[60] == address;
const isOwner = data?.chains[60] == address;
const editable = address && data && isUsingOffchainResolver && isOwner;

const shouldSuggestGassless =
Expand Down Expand Up @@ -177,8 +194,9 @@ export const Profile: FC<{ name: string }> = ({ name }) => {

if (!data) return <div>Loading...</div>;

const name_split = name.split('.');
const first_half = name_split.length > 2 ? name_split[0] : name;
const display_name = data?.display ?? data?.name;
const name_split = display_name.split('.');
const first_half = name_split.length > 2 ? name_split[0] : display_name;
const second_half =
name_split.length > 2 ? name_split.slice(1).join('.') : undefined;

Expand All @@ -194,7 +212,7 @@ export const Profile: FC<{ name: string }> = ({ name }) => {
<div className="w-full">
<div className="relative w-full aspect-[3/1] overflow-hidden rounded-t-2xl">
<div className="absolute inset-0 w-full h-full bg-ens-light-background-secondary"></div>
{data.records['header'] && (
{data?.records['header'] && (
<img
src={'https://enstate.rs/h/' + data.name}
alt="banner"
Expand Down Expand Up @@ -328,8 +346,8 @@ export const Profile: FC<{ name: string }> = ({ name }) => {
label={chainLabel}
record={chainId.toString()}
value={
data.addresses[chainId.toString()] ??
data.addresses[chainName]
data?.chains[chainId.toString()] ??
data?.chains[chainName]
}
editable={editable}
/>
Expand Down

0 comments on commit 48ce20d

Please sign in to comment.