mirror of
https://github.com/versia-pub/frontend.git
synced 2026-03-13 03:29:16 +01:00
feat: ♻️ Rewrite registration UI
This commit is contained in:
parent
fc6b44d237
commit
fef4fa1e30
8 changed files with 221 additions and 25 deletions
|
|
@ -2,9 +2,46 @@ import type { LysandClient } from "@lysand-org/client";
|
|||
|
||||
// Return type of LysandClient.getInstance
|
||||
export type Instance = Awaited<ReturnType<LysandClient["getInstance"]>>["data"];
|
||||
export type ExtendedDescription = Awaited<
|
||||
ReturnType<LysandClient["getInstanceExtendedDescription"]>
|
||||
>["data"];
|
||||
|
||||
export const useInstance = () => {
|
||||
const identity = useCurrentIdentity();
|
||||
|
||||
return computed(() => identity.value?.instance);
|
||||
};
|
||||
|
||||
export const useInstanceFromClient = (client: MaybeRef<LysandClient>) => {
|
||||
if (!client) {
|
||||
return ref(null as Instance | null);
|
||||
}
|
||||
|
||||
const output = ref(null as Instance | null);
|
||||
|
||||
watchEffect(() => {
|
||||
toValue(client)
|
||||
?.getInstance()
|
||||
.then((res) => {
|
||||
output.value = res.data;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const useTos = (client: MaybeRef<LysandClient>) => {
|
||||
if (!client) {
|
||||
return ref(null as ExtendedDescription | null);
|
||||
}
|
||||
|
||||
const output = ref(null as ExtendedDescription | null);
|
||||
|
||||
watchEffect(() => {
|
||||
toValue(client)
|
||||
?.getInstanceTermsOfService()
|
||||
.then((res) => {
|
||||
output.value = res.data;
|
||||
});
|
||||
});
|
||||
|
||||
return output;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue