You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
import type { FunctionComponent } from "react";
|
|
import React from "react";
|
|
import { SolidProfileShapeShapeType } from "./ldo/solidProfile.shapeTypes";
|
|
import BlurTextInput from "./BlurTextInput";
|
|
import {
|
|
useSolidAuth,
|
|
useLdo,
|
|
useDataResource,
|
|
useSubject,
|
|
} from "@ldobjects/solid-react";
|
|
|
|
const Profile: FunctionComponent = () => {
|
|
const { changeData, commitData } = useLdo();
|
|
const { session } = useSolidAuth();
|
|
const webId = session.webId!;
|
|
const webIdResource = useDataResource(webId);
|
|
const [profile, profileError] = useSubject(SolidProfileShapeShapeType, webId);
|
|
|
|
if (webIdResource.isLoading) {
|
|
return <p>Loading</p>;
|
|
} else if (profileError) {
|
|
return <p>profileError.message</p>;
|
|
} else {
|
|
return (
|
|
<div>
|
|
<label>Name:</label>
|
|
<BlurTextInput
|
|
value={profile.name || ""}
|
|
onBlurText={async (text) => {
|
|
const cProfile = changeData(profile, webIdResource);
|
|
cProfile.name = text;
|
|
await commitData(cProfile);
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
};
|
|
|
|
export default Profile;
|
|
|