Added job list container. Removed all previous migrations.
This commit is contained in:
@@ -28,6 +28,7 @@ const HeaderAppBarContainer = () => (
|
||||
<Query query={GET_NAV_ITEMS}>
|
||||
{({ loading, error, data }) => {
|
||||
if (loading) return <Spin size="large" />;
|
||||
if (error) return <Alert message={error.message} />;
|
||||
return (
|
||||
<HeaderAppBar
|
||||
selectedNavItem={selectedNavItem}
|
||||
|
||||
6
client/src/components/job-list/job-list.component.jsx
Normal file
6
client/src/components/job-list/job-list.component.jsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import React from "react";
|
||||
|
||||
export default function JobList() {
|
||||
//console.log("JobList props", this.props);
|
||||
return <div>JobList</div>;
|
||||
}
|
||||
28
client/src/components/job-list/job-list.container.jsx
Normal file
28
client/src/components/job-list/job-list.container.jsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import React from "react";
|
||||
import { Query } from "react-apollo";
|
||||
import { gql } from "apollo-boost";
|
||||
|
||||
import { Spin, Alert } from "antd";
|
||||
|
||||
import JobList from "./job-list.component";
|
||||
|
||||
const GET_JOBS = gql`
|
||||
query get_jobs {
|
||||
estimates {
|
||||
ro_number
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const JobListContainer = () => (
|
||||
<Query query={GET_JOBS}>
|
||||
{({ loading, error, data }) => {
|
||||
if (loading) return <Spin size="large" />;
|
||||
if (error) return <Alert message={error.message} />;
|
||||
console.log("JobListContainer Data:", data);
|
||||
return <JobList jobs={data} />;
|
||||
}}
|
||||
</Query>
|
||||
);
|
||||
|
||||
export default JobListContainer;
|
||||
@@ -1,91 +0,0 @@
|
||||
import firebase from "firebase/app";
|
||||
import "firebase/auth";
|
||||
import "firebase/database";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import App from "./App";
|
||||
|
||||
const provider = new firebase.auth.GoogleAuthProvider();
|
||||
|
||||
// Find these options in your Firebase console
|
||||
firebase.initializeApp({
|
||||
apiKey: "xxx",
|
||||
authDomain: "xxx",
|
||||
databaseURL: "xxx",
|
||||
projectId: "xxx",
|
||||
storageBucket: "xxx",
|
||||
messagingSenderId: "xxx"
|
||||
});
|
||||
|
||||
export default function Auth() {
|
||||
const [authState, setAuthState] = useState({ status: "loading" });
|
||||
|
||||
useEffect(() => {
|
||||
return firebase.auth().onAuthStateChanged(async user => {
|
||||
if (user) {
|
||||
const token = await user.getIdToken();
|
||||
const idTokenResult = await user.getIdTokenResult();
|
||||
const hasuraClaim =
|
||||
idTokenResult.claims["https://hasura.io/jwt/claims"];
|
||||
|
||||
if (hasuraClaim) {
|
||||
setAuthState({ status: "in", user, token });
|
||||
} else {
|
||||
// Check if refresh is required.
|
||||
const metadataRef = firebase
|
||||
.database()
|
||||
.ref("metadata/" + user.uid + "/refreshTime");
|
||||
|
||||
metadataRef.on("value", async () => {
|
||||
// Force refresh to pick up the latest custom claims changes.
|
||||
const token = await user.getIdToken(true);
|
||||
setAuthState({ status: "in", user, token });
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setAuthState({ status: "out" });
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const signInWithGoogle = async () => {
|
||||
try {
|
||||
await firebase.auth().signInWithPopup(provider);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
const signOut = async () => {
|
||||
try {
|
||||
setAuthState({ status: "loading" });
|
||||
await firebase.auth().signOut();
|
||||
setAuthState({ status: "out" });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
};
|
||||
|
||||
let content;
|
||||
if (authState.status === "loading") {
|
||||
content = null;
|
||||
} else {
|
||||
content = (
|
||||
<>
|
||||
<div>
|
||||
{authState.status === "in" ? (
|
||||
<div>
|
||||
<h2>Welcome, {authState.user.displayName}</h2>
|
||||
<button onClick={signOut}>Sign out</button>
|
||||
</div>
|
||||
) : (
|
||||
<button onClick={signInWithGoogle}>Sign in with Google</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<App authState={authState} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return <div className="auth">{content}</div>;
|
||||
}
|
||||
Reference in New Issue
Block a user