Skip to content

Commit

Permalink
Merge pull request #97 from weaponsforge/dev
Browse files Browse the repository at this point in the history
v1.0.5
  • Loading branch information
weaponsforge authored Apr 5, 2023
2 parents edf5d5a + 24d1e3f commit eaaca65
Show file tree
Hide file tree
Showing 28 changed files with 317 additions and 589 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ jobs:
lint-client:
name: Lint Client
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_BASE_PATH: ''
NEXT_PUBLIC_BASE_API_URL: ${{ secrets.NEXT_PUBLIC_BASE_API_URL_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_API_KEY: ${{ secrets.FIREBASE_WEB_API_KEY_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_AUTHDOMAIN: ${{ secrets.FIREBASE_WEB_AUTHDOMAIN_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_PROJECT_ID: ${{ secrets.FIREBASE_WEB_PROJECT_ID_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_STORAGE_BUCKET: ${{ secrets.FIREBASE_WEB_STORAGE_BUCKET_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_WEB_MESSAGING_SENDER_ID_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_APP_ID: ${{ secrets.FIREBASE_WEB_APP_ID_DEV }}
NEXT_PUBLIC_FIREBASE_WEB_MEASUREMENT_ID: ${{ secrets.FIREBASE_WEB_MEASUREMENT_ID_DEV }}
NEXT_PUBLIC_MEDIA_BG1: ${{ secrets.NEXT_PUBLIC_MEDIA_BG1 }}
NEXT_PUBLIC_RANDOM_JOKE_API: ${{ secrets.NEXT_PUBLIC_RANDOM_JOKE_API }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
Expand All @@ -27,6 +39,11 @@ jobs:
npm install
npm run lint
- name: Dry-run NPM Export
run: |
cd client
npm run export
lint-server:
name: Lint Server
runs-on: ubuntu-latest
Expand Down
115 changes: 0 additions & 115 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
"@mui/icons-material": "^5.11.9",
"@mui/material": "^5.11.10",
"@mui/x-data-grid": "^5.17.25",
"@reduxjs/toolkit": "^1.9.3",
"axios": "^1.3.4",
"eslint": "8.34.0",
"eslint-config-next": "13.2.1",
"firebase": "^9.17.1",
"next": "13.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "^8.0.5",
"use-sync-v": "^2.0.1"
}
}
12 changes: 5 additions & 7 deletions client/src/common/auth/protectedpage/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react'
import { useRouter } from 'next/router'
import { useAuth } from '@/lib/hooks/useAuth'
import { useSyncV } from 'use-sync-v'

import LoadingCover from '@/common/layout/loadingcover'

Expand All @@ -16,25 +16,23 @@ import LoadingCover from '@/common/layout/loadingcover'
function ProtectedPage (Component) {
function AuthListener (props) {
const router = useRouter()
const { authLoading, authError, authUser } = useAuth()
const { authLoading, authUser, authError } = useSyncV('auth')

useEffect(() => {
if (!authLoading && !authUser) {
if (!authLoading && authUser === null) {
router.push('/login')
}
}, [authUser, authLoading, router])

const ItemComponent = () => {
return ((() => {
if (authLoading) {
return <LoadingCover />
} else if (authUser) {
return <Component {...props} />
} else {
return <LoadingCover authError={authError} />
}
}

return (<ItemComponent />)
})())
}

return AuthListener
Expand Down
13 changes: 6 additions & 7 deletions client/src/common/layout/header/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REACT
import { useState } from 'react'
import { useDispatch } from 'react-redux'

// NEXT
import Link from 'next/link'
Expand All @@ -26,9 +25,10 @@ import Typography from '@mui/material/Typography'
import PlayArrowIcon from '@mui/icons-material/PlayArrow'

// LIB
import { useAuth } from '@/lib/hooks/useAuth'
import { authSignOut } from '@/lib/hooks/useInitAuth'
import { setSyncLocalStorage, useSyncLocalStorage } from '@/lib/hooks/useSync'
import { Avalon } from '@/lib/mui/theme'
import { useSyncV } from 'use-sync-v'

// VARIABLES
const pages = ['about']
Expand All @@ -42,8 +42,8 @@ const settings = [
route: '/',
},
{
name: 'Dashboard',
route: 'dashboard',
name: 'Contacts',
route: 'contacts',
},
{
name: 'Logout',
Expand All @@ -57,8 +57,7 @@ function Header() {
const [anchorElUser, setAnchorElUser] = useState(null)
const activeTheme = useSyncLocalStorage('activeTheme')
const animate = useSyncLocalStorage('animate')
const { authUser, authSignOut } = useAuth()
const dispatch = useDispatch()
const { authUser } = useSyncV('auth')
const router = useRouter()

class eventsHandler {
Expand Down Expand Up @@ -241,7 +240,7 @@ function Header() {
>
{settings.map((setting, id) => {
return setting.name === 'Logout' ? (
<MenuItem key={id} onClick={() => dispatch(authSignOut())}>
<MenuItem key={id} onClick={() => authSignOut()}>
<Typography textAlign="center">{setting.name}</Typography>
</MenuItem>
) : (
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/contacts/sidebar/contactForm/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useAuth } from '@/lib/hooks/useAuth'
import { FirebaseFirestore } from '@/lib/utils/firebase/firestore'
import { Avatar, Box, Button, TextField, Typography } from '@mui/material'
import { useEffect, useState } from 'react'
import { useSyncV } from 'use-sync-v'

export const ContactFormComponent = () => {
const user = useAuth()
const activeContact = useSyncV('ui.activeContact')
const { editContact, createContact } = useSyncV('ui.phase')
const [form, setForm] = useState(activeContact)
const [isFormChanged, setIsFormChanged] = useState(false)
const user = useSyncV('auth')

useEffect(() => {
setForm(activeContact)
Expand All @@ -31,7 +30,7 @@ export const ContactFormComponent = () => {
}

const saveHandler = () => {
const user_uid = user.authUser.uid
const user_uid = user?.authUser?.uid ?? ''

switch (true) {
case editContact: {
Expand Down
11 changes: 0 additions & 11 deletions client/src/components/dashboard/index.js

This file was deleted.

Loading

0 comments on commit eaaca65

Please sign in to comment.