Skip to content

Commit

Permalink
Etc bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thedanielforum committed Apr 17, 2022
1 parent 3aa63e1 commit f154f0d
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 29 deletions.
15 changes: 11 additions & 4 deletions compiled-lang/en.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"078WAr": "See all",
"0iB3Cs": "Transaction added",
"5ARyR8": "Personal Finance",
"7vsu1w": "Sign in with Facebook",
"CHu6Xm": "Total Spend (month)",
"CG3a47": "All transactions",
"D3idYv": "Settings",
"GMkXVd": "Recent Transactions",
"GZJpDf": "Analytics",
"LgAx49": "Category added",
"MTfefh": "No transactions",
"Op5EHr": "Sign in with Google",
"URe+qA": "Expense",
"a9m3iY": "{amount} $",
"bQAtuf": "Loading...",
"gJkHZk": "Income"
"VKb1MS": "Categories",
"dXSivY": "My account",
"gJkHZk": "Income",
"lbpe3v": "Signed out",
"xXbJso": "Sign out"
}
36 changes: 27 additions & 9 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,53 @@
"078WAr": {
"defaultMessage": "See all"
},
"0iB3Cs": {
"defaultMessage": "Transaction added"
},
"5ARyR8": {
"defaultMessage": "Personal Finance",
"description": "signin tag-line"
},
"7vsu1w": {
"defaultMessage": "Sign in with Facebook"
},
"CHu6Xm": {
"defaultMessage": "Total Spend (month)",
"description": "TotalSpendCard title"
"CG3a47": {
"defaultMessage": "All transactions"
},
"D3idYv": {
"defaultMessage": "Settings"
},
"GMkXVd": {
"defaultMessage": "Recent Transactions"
},
"GZJpDf": {
"defaultMessage": "Analytics"
},
"LgAx49": {
"defaultMessage": "Category added"
},
"MTfefh": {
"defaultMessage": "No transactions"
},
"Op5EHr": {
"defaultMessage": "Sign in with Google"
},
"URe+qA": {
"defaultMessage": "Expense"
},
"a9m3iY": {
"defaultMessage": "{amount} $",
"description": "monetary amount readout"
"VKb1MS": {
"defaultMessage": "Categories"
},
"bQAtuf": {
"defaultMessage": "Loading...",
"description": "default loading"
"dXSivY": {
"defaultMessage": "My account"
},
"gJkHZk": {
"defaultMessage": "Income"
},
"lbpe3v": {
"defaultMessage": "Signed out"
},
"xXbJso": {
"defaultMessage": "Sign out"
}
}
2 changes: 2 additions & 0 deletions lib/apolloClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const httpLink = new HttpLink({
});

function createApolloClient(token) {
console.log("token", token);
return new ApolloClient({
connectToDevTools: true,
ssrMode: typeof window === "undefined",
Expand Down Expand Up @@ -83,6 +84,7 @@ export function addApolloState(client, pageProps) {
export function useApollo(pageProps, firebaseAuth) {
const state = pageProps[APOLLO_STATE_PROP_NAME];
const [token, setToken] = useState(undefined);
console.log(firebaseAuth);

useEffect(() => {
auth();
Expand Down
40 changes: 27 additions & 13 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { AppProps } from "next/app";
import React, { useState, useEffect } from "react";
import Head from "next/head";
import { useRouter } from "next/router";
import { Toaster } from "react-hot-toast";
import toast, { Toaster } from "react-hot-toast";
import { IntlProvider } from "react-intl";
import { ApolloProvider, gql } from "@apollo/client";
import { useApollo } from "lib/apolloClient";
Expand Down Expand Up @@ -39,11 +39,27 @@ function CustomApp({ Component, pageProps }: AppProps) {

// TODO: Clean this up
onAuthStateChanged(auth, (user: any) => {
if (user) {
setUser(user);
} else {
setUser(null);
}
setLoading(false);

// Redirect if not loged in
if (!user && pathname !== "/signin") {
replace("/signin");
}
});
}, []);

useEffect(() => {
if (!loading) {
if (user) {
apolloClient
.query({
query: GET_USER,
variables: { filter: { firebaseID: { eq: user?.uid } } },
variables: { filter: { firebaseId: { eq: user?.uid } } },
})
.then((firebaseUser: any) => {
// Make sure we have a user
Expand All @@ -61,30 +77,28 @@ function CustomApp({ Component, pageProps }: AppProps) {
.mutate({
mutation: ADD_USER,
variables: {
input: [{ firebaseID: user.uid }],
input: [{ firebaseId: user.uid }],
},
})
.then((addUser: any) => {
console.log("linked firebase user to zef user");
console.log("linked firebase user to zef user", addUser);
setUser({
...user,
id: addUser.data.addUser.user[0].id,
});
setLoading(false);
});
}
})
.catch((err: any) => {
console.error(err);
toast.error(err.message);
});
} else {
setUser(null);
setLoading(false);
}
}
}, [loading, user]);

// Redirect if not loged in
if (!user && pathname !== "/signin") {
replace("/signin");
}
});
}, []);
console.log("loading", loading);

return (
<IntlProvider
Expand Down
2 changes: 1 addition & 1 deletion pages/account/categories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Categories: NextPage = () => {
icon: values.icon,
created: new Date(),
user: {
firebaseID: user?.id,
id: user?.id,
},
},
],
Expand Down
8 changes: 6 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ RUN git config --global --add credential.helper 'store --file=/run/secrets/gitcr
&& git config --global url."https://github.com/".insteadOf [email protected]:

COPY get_zefdb.sh .
ADD backend .
ADD ikura.graphql .

RUN --mount=type=secret,id=gitcredentials bash get_zefdb.sh zef v0.15.2-rc6 'zef-.*cp310'
RUN --mount=type=secret,id=gitcredentials bash get_zefdb.sh zef v0.15.3-dev2 'zef-.*cp310'

# pip install stuff
ADD requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt

EXPOSE 5001

Expand Down
30 changes: 30 additions & 0 deletions server/get_zefdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Black magic to extract access token and then get asset id from github
# Steps:
# 1. Get GH_ACCESS_TOKEN from the secret passed in as the gitcredentials (this is not stored past this RUN command)
# 2. Scrap the github release to find the asset with "zefdb-" and "cp38" in its name (i.e. with julia and python 3.8).
# 3. Grab the file itself

if [ "$#" -ne 3 ] ; then
echo "Need three arguments, the repo, the tag and the asset filter, zefDB v0.12.26 e.g. zefdb-.*cp38"
exit 1
fi

REPO="$1"
ZEFDB_TAG="$2"
ASSET_FILTER="$3"

set -o pipefail
GH_ACCESS_TOKEN=$(cat /run/secrets/gitcredentials | sed -e 's_^https://.*:\(.*\)@.*$_\1_') || exit 1

DETAILS="$(curl "https://${GH_ACCESS_TOKEN}:@api.github.com/repos/zefhub/$REPO/releases/tags/$ZEFDB_TAG" | jq ".assets | map(select(.name | test(\"$ASSET_FILTER\")))[0]")" || exit 1
ASSET_ID=$(echo $DETAILS | jq ".id") || exit 1
FILENAME=$(echo $DETAILS | jq ".name" | tr -d \") || exit 1

curl -L -o $FILENAME -H 'Accept: application/octet-stream' "https://${GH_ACCESS_TOKEN}:@api.github.com/repos/zefhub/$REPO/releases/assets/${ASSET_ID}" || exit 1

if [[ "$FILENAME" == "null" ]] ; then
exit 1
fi
pip3 install --no-cache-dir $FILENAME
1 change: 1 addition & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests>=2.27.1

1 comment on commit f154f0d

@vercel
Copy link

@vercel vercel bot commented on f154f0d Apr 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ikura – ./

www.ikura.app
ikura.app
ikura.vercel.app
ikura-git-main-zefhub.vercel.app
ikura-zefhub.vercel.app

Please sign in to comment.