Fix front-end stuff

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-03-23 20:39:39 +01:00
parent 986ae45f52
commit c4e9f88e85
23 changed files with 229 additions and 83 deletions

View File

@@ -215,12 +215,14 @@ export function useRegistrationConfig() {
}>(REGISTRATIONS, undefined, { fetchPolicy: "cache-only" });
const registrationsOpen = computed(
() => result.value?.config.registrationsOpen
() => result.value?.config?.registrationsOpen
);
const registrationsAllowlist = computed(
() => result.value?.config.registrationsAllowlist
() => result.value?.config?.registrationsAllowlist
);
const databaseLogin = computed(
() => result.value?.config?.auth?.databaseLogin
);
const databaseLogin = computed(() => result.value?.config.auth.databaseLogin);
return {
registrationsOpen,
registrationsAllowlist,

View File

@@ -0,0 +1,44 @@
import { useQuery } from "@vue/apollo-composable";
import { computed, unref } from "vue";
import { useCurrentUserClient } from "./user";
import type { Ref } from "vue";
import { IGroup } from "@/types/actor";
import { GROUP_DISCUSSIONS_LIST } from "@/graphql/discussion";
export function useGroupDiscussionsList(
name: string | undefined | Ref<string | undefined>,
options?: {
discussionsPage?: number;
discussionsLimit?: number;
}
) {
const { currentUser } = useCurrentUserClient();
const { result, error, loading, onResult, onError, refetch } = useQuery<
{
group: Pick<
IGroup,
"id" | "preferredUsername" | "name" | "domain" | "discussions"
>;
},
{
name: string;
discussionsPage?: number;
discussionsLimit?: number;
}
>(
GROUP_DISCUSSIONS_LIST,
() => ({
name: unref(name),
...options,
}),
() => ({
enabled:
unref(name) !== undefined &&
unref(name) !== "" &&
currentUser.value?.isLoggedIn,
fetchPolicy: "cache-and-network",
})
);
const group = computed(() => result.value?.group);
return { group, error, loading, onResult, onError, refetch };
}

View File

@@ -2,7 +2,7 @@ import { PERSON_MEMBERSHIPS } from "@/graphql/actor";
import {
CREATE_GROUP,
DELETE_GROUP,
FETCH_GROUP,
FETCH_GROUP_PUBLIC,
LEAVE_GROUP,
UPDATE_GROUP,
} from "@/graphql/group";
@@ -50,7 +50,7 @@ export function useGroup(
discussionsLimit?: number;
}
>(
FETCH_GROUP,
FETCH_GROUP_PUBLIC,
() => ({
name: unref(name),
...options,

View File

@@ -0,0 +1,44 @@
import { useQuery } from "@vue/apollo-composable";
import { computed, unref } from "vue";
import { useCurrentUserClient } from "./user";
import type { Ref } from "vue";
import { IGroup } from "@/types/actor";
import { GROUP_RESOURCES_LIST } from "@/graphql/resources";
export function useGroupResourcesList(
name: string | undefined | Ref<string | undefined>,
options?: {
resourcesPage?: number;
resourcesLimit?: number;
}
) {
const { currentUser } = useCurrentUserClient();
const { result, error, loading, onResult, onError, refetch } = useQuery<
{
group: Pick<
IGroup,
"id" | "preferredUsername" | "name" | "domain" | "resources"
>;
},
{
name: string;
resourcesPage?: number;
resourcesLimit?: number;
}
>(
GROUP_RESOURCES_LIST,
() => ({
name: unref(name),
...options,
}),
() => ({
enabled:
unref(name) !== undefined &&
unref(name) !== "" &&
currentUser.value?.isLoggedIn,
fetchPolicy: "cache-and-network",
})
);
const group = computed(() => result.value?.group);
return { group, error, loading, onResult, onError, refetch };
}

View File

@@ -18,12 +18,13 @@ export function useCurrentUserClient() {
result: currentUserResult,
error,
loading,
onResult,
} = useQuery<{
currentUser: ICurrentUser;
}>(CURRENT_USER_CLIENT);
const currentUser = computed(() => currentUserResult.value?.currentUser);
return { currentUser, error, loading };
return { currentUser, error, loading, onResult };
}
export function useLoggedUser() {