Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "rapid-ce500"
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ build/

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
30 changes: 30 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"storage": {
"rules": "storage.rules"
},
"emulators": {
"firestore": {
"port": 69420
Copy link
Contributor

Choose a reason for hiding this comment

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

👌

},
"hosting": {
"port": 42069
},
"ui": {
"enabled": true
}
}
}
4 changes: 4 additions & 0 deletions firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"indexes": [],
"fieldOverrides": []
}
18 changes: 18 additions & 0 deletions firestore.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {

// This rule allows anyone with your database reference to view, edit,
// and delete all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// all client requests to your Firestore database will be denied until you Update
// your rules
match /{document=**} {
allow read, write: if request.time < timestamp.date(2020, 8, 29);
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@fortawesome/react-fontawesome": "^0.1.11",
"@types/react-router-dom": "^5.1.5",
"emotion-theming": "^10.0.27",
"firebase": "^7.17.1",
"mobx": "^5.15.4",
"mobx-react-lite": "^2.0.7",
"node-sass": "^4.14.1",
Expand All @@ -20,7 +21,8 @@
"react-icons": "^3.10.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-wavify": "^1.3.0"
"react-wavify": "^1.3.0",
"typescript": "~3.7.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/DisplayNavAndPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import NavSidebar from './NavSidebar'
interface IDisplayNavAndPage {
children: JSX.Element[] | JSX.Element
}
export default function DisplayNavAndPage({
export default function NavLayout({
children,
}: IDisplayNavAndPage): JSX.Element {
return (
Expand Down
9 changes: 3 additions & 6 deletions src/components/theme/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import {
ColorModeProvider,
CSSReset,
theme,
ThemeProvider,
} from '@chakra-ui/core'
import { ColorModeProvider, CSSReset, ThemeProvider } from '@chakra-ui/core'
import React from 'react'

import theme from './theme'

const ThemedComponent: React.FunctionComponent = ({ children }) => (
<ThemeProvider theme={theme}>
<ColorModeProvider>
Expand Down
7 changes: 7 additions & 0 deletions src/components/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { theme as DefaultTheme } from '@chakra-ui/core'

const theme = {
...DefaultTheme,
}

export default theme
61 changes: 61 additions & 0 deletions src/data/Auth/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { auth } from 'firebase'
import { computed, observable } from 'mobx'
import React from 'react'

const defaultSucc = (user: any) => {
console.log(`Successfully signed in! \n\n ${JSON.stringify(user, null, 2)}`)
}

const defaultErr = (err: any) => {
console.error(
`Could not sign in through google. \n\n ${JSON.stringify(err, null, 2)}`
)
}

class IAuthStore {
@observable user: any = null
@observable authPending = true

listenToAuth: any

constructor() {
this.listenToAuth = auth().onAuthStateChanged(
(user) => {
this.user = user

this.authPending = false
},
(err) => {
console.error(err)
}
)
}

public async doSignInWithGoogle() {
const provider = new auth.GoogleAuthProvider()
await auth().signInWithPopup(provider).then(defaultSucc, defaultErr)
}

public async doSignInWithEmail(e: string, p: string) {
await auth().signInWithEmailAndPassword(e, p).then(defaultSucc, defaultErr)
}

@computed
public get isAuthed() {
return !!this.user
Copy link
Contributor

Choose a reason for hiding this comment

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

There supposed to be two !s here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@safinsingh that ensures the result is a boolean since this.user is a non-boolean

}
}

export const AuthStore = new IAuthStore()

export const AuthContext = React.createContext(AuthStore)

export const AuthProvider: React.FunctionComponent<React.ReactNode> = ({
children,
}) => {
return (
<AuthContext.Provider value={AuthStore}>{children}</AuthContext.Provider>
)
}

export default AuthStore
61 changes: 61 additions & 0 deletions src/data/Channels/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { auth } from 'firebase'
import { computed, observable } from 'mobx'
import React from 'react'

const defaultSucc = (user: any) => {
console.log(`Successfully signed in! \n\n ${JSON.stringify(user, null, 2)}`)
}

const defaultErr = (err: any) => {
console.error(
`Could not sign in through google. \n\n ${JSON.stringify(err, null, 2)}`
)
}

class IAuthStore {
@observable user: any = null
@observable authPending = true

listenToAuth: any

constructor() {
this.listenToAuth = auth().onAuthStateChanged(
(user) => {
this.user = user

this.authPending = false
},
(err) => {
console.error(err)
}
)
}

public async doSignInWithGoogle() {
const provider = new auth.GoogleAuthProvider()
await auth().signInWithPopup(provider).then(defaultSucc, defaultErr)
}

public async doSignInWithEmail(e: string, p: string) {
await auth().signInWithEmailAndPassword(e, p).then(defaultSucc, defaultErr)
}

@computed
public get isAuthed() {
return !!this.user
}
}

export const AuthStore = new IAuthStore()

export const AuthContext = React.createContext(AuthStore)

export const AuthProvider: React.FunctionComponent<React.ReactNode> = ({
children,
}) => {
return (
<AuthContext.Provider value={AuthStore}>{children}</AuthContext.Provider>
)
}

export default AuthStore
Empty file added src/data/Communities/index.ts
Empty file.
Empty file added src/data/Messages/index.ts
Empty file.
Empty file added src/data/Users/index.ts
Empty file.
1 change: 1 addition & 0 deletions src/data/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as AuthStore } from './Auth'
14 changes: 14 additions & 0 deletions src/firebase/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { initializeApp } from 'firebase'

const firebaseConfig = {
apiKey: process.env.REACT_APP_FapiKey,
authDomain: process.env.REACT_APP_FauthDomain,
databaseURL: process.env.REACT_APP_FdatabaseURL,
projectId: process.env.REACT_APP_FprojectId,
storageBucket: process.env.REACT_APP_FstorageBucket,
messagingSenderId: process.env.REACT_APP_FmessagingSenderId,
appId: process.env.REACT_APP_FappId,
measurementId: process.env.REACT_APP_FmeasurementId,
}

initializeApp(firebaseConfig)
6 changes: 3 additions & 3 deletions src/pages/Chat.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'

import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage'
import NavLayout from '../components/organisms/DisplayNavAndPage'

export default function Chat(): JSX.Element {
return (
<DisplayNavAndPage>
<NavLayout>
<h1>Messages</h1>
</DisplayNavAndPage>
</NavLayout>
)
}
6 changes: 3 additions & 3 deletions src/pages/Community.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import React from 'react'
import GroupHeading from '../components/atoms/GroupHeading'
import CommunityCardSmall from '../components/molecules/CommunityCardSmall'
import Search from '../components/molecules/Search'
import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage'
import NavLayout from '../components/organisms/DisplayNavAndPage'

interface ICommunityPage {}
export default function Community() {
return (
<DisplayNavAndPage>
<NavLayout>
<Flex alignItems="flex-end" marginLeft="auto" width="100%">
<Search />
</Flex>
Expand Down Expand Up @@ -39,6 +39,6 @@ export default function Community() {
)
})}
</Stack>
</DisplayNavAndPage>
</NavLayout>
)
}
6 changes: 3 additions & 3 deletions src/pages/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import React from 'react'

import GroupHeading from '../components/atoms/GroupHeading'
import DropsList from '../components/molecules/DropsList'
import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage'
import NavLayout from '../components/organisms/DisplayNavAndPage'
import FindInterface from '../components/organisms/FindInterface'
import Recommended from '../components/organisms/Recommended'
import Trending from '../components/organisms/Trending'

interface IExplorePage {}
export default function ExplorePage() {
return (
<DisplayNavAndPage>
<NavLayout>
<FindInterface />
<GroupHeading>
<Text>Drops</Text>
Expand All @@ -31,6 +31,6 @@ export default function ExplorePage() {
<Recommended />
</Stack>
</Stack>
</DisplayNavAndPage>
</NavLayout>
)
}
6 changes: 3 additions & 3 deletions src/pages/Users.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'

import DisplayNavAndPage from '../components/organisms/DisplayNavAndPage'
import NavLayout from '../components/organisms/DisplayNavAndPage'
import FriendList from '../components/organisms/FriendList'

export default function UsersPage() {
return (
<DisplayNavAndPage>
<NavLayout>
<FriendList />
</DisplayNavAndPage>
</NavLayout>
)
}
7 changes: 7 additions & 0 deletions storage.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth!=null;
}
}
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"include": ["src"],
"compilerOptions": {
"experimentalDecorators": true,
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
Expand Down
Loading