Skip to content

Commit 722fd2f

Browse files
authored
web: cleanup rpc and enable prefetch (#1339)
* cleanup rpc * naming * add prefetch to dropdown
1 parent 4e2ee9c commit 722fd2f

File tree

7 files changed

+17
-20
lines changed

7 files changed

+17
-20
lines changed

apps/web/app/(org)/dashboard/_components/Navbar/Items.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ const NavItem = ({
411411
onMouseLeave={() => {
412412
iconRef.current?.stopAnimation();
413413
}}
414-
prefetch={false}
414+
prefetch={true}
415415
passHref
416416
className={classNames(
417417
"relative border border-transparent transition z-3",

apps/web/app/(org)/dashboard/_components/Navbar/SpacesList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ const SpacesList = ({ toggleMobileNav }: { toggleMobileNav?: () => void }) => {
173173
<Link
174174
passHref
175175
onClick={() => toggleMobileNav?.()}
176-
prefetch={false}
176+
prefetch={true}
177177
onMouseEnter={() => layersIconRef.current?.startAnimation()}
178178
onMouseLeave={() => layersIconRef.current?.stopAnimation()}
179179
href="/dashboard/spaces/browse"

apps/web/app/(org)/dashboard/_components/Navbar/Top.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ const MenuItem = memo(({ icon, name, href, onClick, iconClassName }: Props) => {
326326
<Link
327327
className="flex gap-2 items-center w-full"
328328
href={href ?? "#"}
329+
prefetch={true}
329330
onClick={onClick}
330331
>
331332
<div className="flex-shrink-0 flex items-center justify-center w-3.5 h-3.5">

apps/web/app/(org)/dashboard/settings/organization/components/DeleteOrgDialog.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
DialogTitle,
88
Input,
99
} from "@cap/ui";
10-
import type { Organisation } from "@cap/web-domain";
1110
import { faTrashCan } from "@fortawesome/free-solid-svg-icons";
1211
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
1312
import { Effect } from "effect";
@@ -28,10 +27,10 @@ const DeleteOrgDialog = ({ open, onOpenChange }: DeleteOrgDialogProps) => {
2827
const rpc = useRpcClient();
2928
const inputId = useId();
3029
const router = useRouter();
31-
const deleteOrg = useEffectMutation({
30+
const softDeleteOrg = useEffectMutation({
3231
mutationFn: Effect.fn(function* () {
3332
if (!activeOrganization) return;
34-
yield* rpc.OrganisationDelete({
33+
yield* rpc.OrganisationSoftDelete({
3534
id: activeOrganization.organization.id,
3635
});
3736
}),
@@ -73,15 +72,15 @@ const DeleteOrgDialog = ({ open, onOpenChange }: DeleteOrgDialogProps) => {
7372
<Button
7473
size="sm"
7574
variant="destructive"
76-
onClick={() => deleteOrg.mutate()}
77-
spinner={deleteOrg.isPending}
75+
onClick={() => softDeleteOrg.mutate()}
76+
spinner={softDeleteOrg.isPending}
7877
disabled={
7978
organizationData?.length === 1 ||
8079
organizationName !== activeOrganization?.organization.name ||
81-
deleteOrg.isPending
80+
softDeleteOrg.isPending
8281
}
8382
>
84-
{deleteOrg.isPending ? "Deleting..." : "Delete"}
83+
{softDeleteOrg.isPending ? "Deleting..." : "Delete"}
8584
</Button>
8685
</DialogFooter>
8786
</DialogContent>

packages/web-backend/src/Organisations/OrganisationsRpcs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const OrganisationsRpcsLive = Organisation.OrganisationRpcs.toLayer(
1414
S3Error: () => new InternalError({ type: "s3" }),
1515
}),
1616
),
17-
OrganisationDelete: (data) =>
18-
orgs.deleteOrg(data.id).pipe(
17+
OrganisationSoftDelete: (data) =>
18+
orgs.softDelete(data.id).pipe(
1919
Effect.catchTags({
2020
DatabaseError: () => new InternalError({ type: "database" }),
2121
}),

packages/web-backend/src/Organisations/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class Organisations extends Effect.Service<Organisations>()(
4848
}
4949
});
5050

51-
const deleteOrg = Effect.fn("Organisations.deleteOrg")(function* (
51+
const softDelete = Effect.fn("Organisations.softDelete")(function* (
5252
id: Organisation.OrganisationId,
5353
) {
5454
const user = yield* CurrentUser;
@@ -89,7 +89,7 @@ export class Organisations extends Effect.Service<Organisations>()(
8989
}),
9090
);
9191
});
92-
return { update, deleteOrg };
92+
return { update, softDelete };
9393
}),
9494
dependencies: [
9595
ImageUploads.Default,

packages/web-domain/src/Organisation.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ export class Organisation extends Schema.Class<Organisation>("Organisation")({
2323
name: Schema.String,
2424
}) {}
2525

26-
export const OrganisationDelete = Schema.Struct({
27-
id: OrganisationId,
28-
});
29-
export type OrganisationDelete = Schema.Schema.Type<typeof OrganisationDelete>;
30-
3126
export const OrganisationUpdate = Schema.Struct({
3227
id: OrganisationId,
3328
image: Schema.optional(ImageUpdatePayload),
@@ -39,8 +34,10 @@ export class OrganisationRpcs extends RpcGroup.make(
3934
payload: OrganisationUpdate,
4035
error: Schema.Union(InternalError, PolicyDeniedError, NotFoundError),
4136
}).middleware(RpcAuthMiddleware),
42-
Rpc.make("OrganisationDelete", {
43-
payload: OrganisationDelete,
37+
Rpc.make("OrganisationSoftDelete", {
38+
payload: Schema.Struct({
39+
id: OrganisationId,
40+
}),
4441
error: Schema.Union(InternalError, PolicyDeniedError, NotFoundError),
4542
}).middleware(RpcAuthMiddleware),
4643
) {}

0 commit comments

Comments
 (0)