Skip to content

Commit 9c229ab

Browse files
committed
Fix invites - set parent to user
1 parent 1661bd1 commit 9c229ab

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

data-browser/src/components/InviteForm.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
properties,
55
Resource,
66
urls,
7+
useCurrentAgent,
78
} from '@tomic/react';
89
import React, { useState } from 'react';
910
import toast from 'react-hot-toast';
@@ -26,6 +27,7 @@ export function InviteForm({ target }: InviteFormProps) {
2627
const invite = useResource(null, { newResource: true });
2728
const store = useStore();
2829
const [err, setErr] = useState<Error>(null);
30+
const [agent] = useCurrentAgent();
2931
const [createdSubject, setCreatedSubject] = useState<string>(null);
3032

3133
/** Stores the Invite, sends it to the server, shows the Subject to the User */
@@ -35,11 +37,7 @@ export function InviteForm({ target }: InviteFormProps) {
3537
await invite.set(properties.invite.target, target.getSubject(), store);
3638
invite.setSubject(store.createSubject('invite'));
3739
try {
38-
await invite.set(
39-
properties.parent,
40-
`${store.getServerUrl()}/invites`,
41-
store,
42-
);
40+
await invite.set(properties.parent, agent.subject, store);
4341
await invite.save(store);
4442
navigator.clipboard.writeText(invite.getSubject());
4543
toast.success('Copied to clipboard');

data-browser/src/routes/ShareRoute.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useArray, useCanWrite, useResource, useStore } from '@tomic/react';
33
import { ContainerNarrow } from '../components/Containers';
44
import { useCurrentSubject } from '../helpers/useCurrentSubject';
55
import { Right, urls } from '@tomic/lib';
6-
import ResourceInline from '../views/ResourceInline';
6+
import ResourceInline, { ErrorLook } from '../views/ResourceInline';
77
import { Card, CardInsideFull, CardRow } from '../components/Card';
88
import { FaGlobe } from 'react-icons/fa';
99
import styled from 'styled-components';
@@ -12,17 +12,19 @@ import { InviteForm } from '../components/InviteForm';
1212
import toast from 'react-hot-toast';
1313
import { PageTitle } from '../components/PageTitle';
1414

15-
const useValueOpts = {
16-
commit: false,
17-
};
18-
1915
/** Form for managing and viewing rights for this resource */
2016
export function ShareRoute(): JSX.Element {
2117
const [subject] = useCurrentSubject();
2218
const resource = useResource(subject);
2319
const store = useStore();
2420
const [canWrite] = useCanWrite(resource);
2521
const [showInviteForm, setShowInviteForm] = useState(false);
22+
const [err, setErr] = useState(null);
23+
24+
const useValueOpts = {
25+
commit: false,
26+
handleValidationError: setErr,
27+
};
2628

2729
const [writers, setWriters] = useArray(
2830
resource,
@@ -145,6 +147,7 @@ export function ShareRoute(): JSX.Element {
145147
Save
146148
</Button>
147149
)}
150+
{err && <ErrorLook>{err}</ErrorLook>}
148151
{inheritedRights.length > 0 && (
149152
<Card>
150153
<RightsHeader text='inherited rights:' />

0 commit comments

Comments
 (0)