Skip to content

Commit

Permalink
Supabase - Profile
Browse files Browse the repository at this point in the history
Issue: #725
  • Loading branch information
h0lybyte committed Aug 12, 2023
1 parent 75a00e1 commit 37b5c2a
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 156 deletions.
14 changes: 14 additions & 0 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ declare module 'astro:content' {

type ContentEntryMap = {
"account": {
"calendar.mdx": {
id: "calendar.mdx";
slug: "calendar";
body: string;
collection: "account";
data: InferEntrySchema<"account">
} & { render(): Render[".mdx"] };
"login.mdx": {
id: "login.mdx";
slug: "login";
Expand Down Expand Up @@ -229,6 +236,13 @@ declare module 'astro:content' {
collection: "account";
data: InferEntrySchema<"account">
} & { render(): Render[".mdx"] };
"settings.mdx": {
id: "settings.mdx";
slug: "settings";
body: string;
collection: "account";
data: InferEntrySchema<"account">
} & { render(): Render[".mdx"] };
};
"application": {
"android.mdx": {
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"swup",
"syncthing",
"tailwindcss",
"tasker",
"Threlte",
"TLDR",
"tlsv",
Expand Down
41 changes: 25 additions & 16 deletions src/components/API/storage.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { atom, WritableAtom, task } from "nanostores";
import { persistentAtom } from '@nanostores/persistent';
import { persistentAtom } from "@nanostores/persistent";

export const uuid$: WritableAtom<string> = atom('');
export const username$: WritableAtom<string> = atom("Guest");
export const uuid$: WritableAtom<string> = atom("");
export const username$: WritableAtom<string> = atom("");
export const email$: WritableAtom<string> = atom("");
export const khash$: WritableAtom<number> = atom(0);
//? [DATA]->[UX]
Expand All @@ -12,21 +12,30 @@ export const fetchProfile$: WritableAtom<string> = atom("");
//? [DATA]=>[DX]
export const log$: WritableAtom<string> = atom("");

export const log = async( log : string) => {
task(async() => {
log$.set(log);
console.log(`[LOG] ${log$.get()}`);
})
}
export const log = async (log: string) => {
task(async () => {
log$.set(log);
console.log(`[LOG] ${log$.get()}`);
});
};

export const tasker = async (__key: WritableAtom, __data) => {
task(async () => {
log(`Storing ${__data} into atom!`);
__key.set(__data);


});
};

export const __getProfile = async () => {
task(async () => {
log("Starting Cache -> Profile");
});
log("Starting Cache -> Profile");
});
};

export const notification = async( error: string) => {
task(async() => {
notification$.set(error);
})
}
export const notification = async (error: string) => {
task(async () => {
notification$.set(error);
});
};
10 changes: 8 additions & 2 deletions src/components/API/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Session, User, createClient } from "@supabase/supabase-js";
import { atom, WritableAtom, task } from "nanostores";
import { persistentAtom } from "@nanostores/persistent";

import * as kbve from "@c/kbve";

import * as Storage from "./storage";

//TODO [ENV-MIGRATION]
Expand All @@ -18,8 +20,8 @@ export const supabase_user$: WritableAtom<undefined | User> = atom(undefined);

//! [MAIN]
export const supabase = createClient(
"https://haiukcmcljjfaflqdmjc.supabase.co",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImhhaXVrY21jbGpqZmFmbHFkbWpjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTE1NTM0MjMsImV4cCI6MjAwNzEyOTQyM30.0taw1sQp2fHLY3byK2cnGtLttXPFRs9GfkxFBNQL6E8",
kbve.supabase_api,
kbve.supabase_projectId,
);

supabase.auth.getSession().then(({ data: { session } }) => {
Expand Down Expand Up @@ -51,5 +53,9 @@ export const getProfile = async ({ cache = true }: { cache: boolean }) => {
export const _getProfile = async () => {
task(async () => {
Storage.log(" Starting Supabase -> Profile Table");
const userData = await supabase_account();
Storage.tasker(Storage.email$, userData?.email);
Storage.tasker(Storage.uuid$, userData?.id);

});
};
Loading

0 comments on commit 37b5c2a

Please sign in to comment.