Format front

This commit is contained in:
Zoe Roux 2023-12-02 00:59:57 +01:00
parent 49d225532c
commit 7dab3fd094
6 changed files with 34 additions and 30 deletions

View File

@ -170,7 +170,6 @@ App.getInitialProps = async (ctx: AppContext) => {
if (typeof window !== "undefined") return { pageProps: superjson.serialize(appProps.pageProps) };
const getUrl = Component.getFetchUrls;
const getLayoutUrl =
Component.getLayout && "Layout" in Component.getLayout

View File

@ -63,7 +63,7 @@ export const AccountProvider = ({
}) => {
if (Platform.OS === "web" && typeof window === "undefined") {
const accs = ssrAccount
? [{ ...ssrAccount, selected: true, select: () => { }, remove: () => { } }]
? [{ ...ssrAccount, selected: true, select: () => {}, remove: () => {} }]
: [];
return (
<AccountContext.Provider value={accs}>

View File

@ -59,9 +59,10 @@ export const login = async (
}
};
export const getTokenWJ = async (account?: Account | null): Promise<[string, Token] | [null, null]> => {
if (account === undefined)
account = getCurrentAccount();
export const getTokenWJ = async (
account?: Account | null,
): Promise<[string, Token] | [null, null]> => {
if (account === undefined) account = getCurrentAccount();
if (!account) return [null, null];
if (account.token.expire_at <= new Date(new Date().getTime() + 10 * 1000)) {
@ -81,8 +82,7 @@ export const getTokenWJ = async (account?: Account | null): Promise<[string, Tok
return [`${account.token.token_type} ${account.token.access_token}`, account.token];
};
export const getToken = async (): Promise<string | null> =>
(await getTokenWJ())[0];
export const getToken = async (): Promise<string | null> => (await getTokenWJ())[0];
export const logout = () => {
removeAccounts((x) => x.selected);

View File

@ -109,7 +109,8 @@ export const queryFn = async <Data,>(
data = { errors: [error] } as KyooErrors;
}
console.log(
`Invalid response (${"method" in context && context.method ? context.method : "GET"
`Invalid response (${
"method" in context && context.method ? context.method : "GET"
} ${path}):`,
data,
resp.status,

View File

@ -74,7 +74,11 @@ export const LoginPage: QueryPage = () => {
<Button
text={t("login.login")}
onPress={async () => {
const { error } = await login("login", { username, password, apiUrl: cleanApiUrl(apiUrl) });
const { error } = await login("login", {
username,
password,
apiUrl: cleanApiUrl(apiUrl),
});
setError(error);
if (error) return;
router.replace("/", undefined, {