Skip to content

Commit

Permalink
Merge pull request #72 from joshxfi/dev
Browse files Browse the repository at this point in the history
release: v1.0.8.1
  • Loading branch information
joshxfi authored Apr 15, 2022
2 parents a21eebe + 59681a3 commit 2e8939b
Show file tree
Hide file tree
Showing 18 changed files with 1,353 additions and 166 deletions.
88 changes: 85 additions & 3 deletions firestore.rules
Original file line number Diff line number Diff line change
@@ -1,8 +1,90 @@
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
function docExists(collection, docId) {
return exists(/databases/$(database)/documents/$(collection)/$(docId));
}

function isAdmin(userId) {
return docExists('admins', userId);
}

function currentUser() {
return request.auth.uid;
}

function userTag() {
return get(/databases/$(database)/documents/users/$(request.auth.uid)).data.userTag;
}

function allowedFields(condition, fields) {
return condition && request.resource.data.diff(resource.data).affectedKeys().hasOnly(fields);
}

match /{documents=**} {
allow read, write: if isAdmin(currentUser());
}

match /admins/{adminId} {
allow read, write: if isAdmin(currentUser());
}

match /users/{userId} {
allow read: if request.auth != null;
allow create: if !docExists('users', userId);
allow update: if allowedFields(userId.matches(currentUser()), ['username']);
}

match /rooms/{roomId} {
function isCreator() {
return userTag() == resource.data.creator;
}

function isRoomAdmin() {
return userTag() in resource.data.admin;
}

function isMember() {
return userTag() in resource.data.members;
}

function members(isReq) {
return isReq ? request.resource.data.members : resource.data.members;
}

allow read: if true;
allow create: if !docExists('rooms', roomId);
allow update: if (allowedFields(!(userTag() in members(false)), ['requests'])
&& members(true).hasAll(members(false)))
|| allowedFields(isCreator(), ['name', 'admin', 'members', 'requests'])
|| allowedFields(isRoomAdmin(), ['members', 'requests'])
|| (allowedFields(isMember(), ['members'])
&& !(userTag() in members(true))
&& members(true).hasAll(members(false).removeAll([userTag()])));
allow delete: if isCreator();

match /tasks/{taskId} {
function currentRoom() {
return get(/databases/$(database)/documents/rooms/$(roomId)).data;
}

function roomAdmin() {
return userTag() in currentRoom().admin || userTag() == currentRoom().creator;
}

function roomMember() {
return userTag() in currentRoom().members;
}

function addedByUser() {
return userTag() == resource.data.addedBy;
}

allow read, create: if roomMember() || roomAdmin();
allow update: if addedByUser() || roomAdmin()
|| allowedFields(roomMember(), ['completedBy']);
allow delete: if addedByUser() || roomAdmin();
}
}
}
}
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
"react-dom": "17.0.2",
"react-firebase-hooks": "^5.0.3",
"react-hot-toast": "^2.2.0",
"react-icons": "^4.3.1"
"react-icons": "^4.3.1",
"react-markdown": "^8.0.2",
"remark-gfm": "^3.0.1"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.2",
"@types/nprogress": "^0.2.0",
"@types/react": "^17.0.43",
"@types/react-datepicker": "^4.3.4",
Expand Down
16 changes: 16 additions & 0 deletions pages/code-of-conduct.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { NextPageWithLayout } from 'types/page';
import { Layout, Markdown } from '@/components';
import { codeOfConduct } from '@/utils/contents';

const CodeOfConduct: NextPageWithLayout = () => {
return <Markdown content={codeOfConduct} />;
};

CodeOfConduct.getLayout = (page: React.ReactElement) => (
<Layout allowAll className='py-20'>
{page}
</Layout>
);

export default CodeOfConduct;
6 changes: 3 additions & 3 deletions pages/join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const Join: NextPageWithLayout = () => {

if (!room.exists()) toast.error('Room Does Not Exist');
else if (userInRoom(userTag, _room))
toast.error('You Are Already a Member');
toast.error('You are already a member');
else if (_room.requests.includes(userTag))
toast.error('You Already Sent a Request');
toast.error('You already sent a request');
else if (_room.creator === userTag)
toast.error('You Are the Owner of the Room');
toast.error('You are the owner of the room');
else {
await updateDoc(roomRef, {
requests: arrayUnion(userTag),
Expand Down
16 changes: 16 additions & 0 deletions pages/privacy-policy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { NextPageWithLayout } from 'types/page';
import { Layout, Markdown } from '@/components';
import { privacyPolicy } from '@/utils/contents';

const PrivacyPolicy: NextPageWithLayout = () => {
return <Markdown content={privacyPolicy} />;
};

PrivacyPolicy.getLayout = (page: React.ReactElement) => (
<Layout allowAll className='py-20'>
{page}
</Layout>
);

export default PrivacyPolicy;
16 changes: 16 additions & 0 deletions pages/the-project.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { theProject } from '@/utils/contents';
import { Layout, Markdown } from '@/components';
import { NextPageWithLayout } from 'types/page';

const TheProject: NextPageWithLayout = () => {
return <Markdown content={theProject} />;
};

TheProject.getLayout = (page: React.ReactElement) => (
<Layout allowAll className='py-20'>
{page}
</Layout>
);

export default TheProject;
7 changes: 2 additions & 5 deletions src/components/Badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'tippy.js/dist/tippy.css';

const style = (role: IRoles) => {
switch (role) {
case 'Founder':
case 'Verified':
return 'text-lg text-blue-500';

case 'Contributor':
Expand All @@ -27,10 +27,7 @@ const Badges = ({ roles }: { roles?: IRoles[] }) => {
{_badges.map(({ role, Icon }) => {
return (
roles?.includes(role) && (
<Tippy
key={role}
content={role === 'OG' ? 'Pre-v1.1.0 User' : role}
>
<Tippy key={role} content={role}>
<div className={style(role)}>
<Icon />
</div>
Expand Down
69 changes: 28 additions & 41 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Image from 'next/image';
import doodle from '@/assets/doodle.svg';
import { socials, footerLinks } from '@/utils/constants';
import { footerLinks } from '@/utils/constants';

const Footer: React.FC = () => {
return (
Expand All @@ -20,58 +20,45 @@ const Footer: React.FC = () => {
</h1>
</div>

{footerLinks.map((data) => (
<div
key={data.title}
className={`${
data.title === 'Contribute' && 'hidden sm:block'
}`}
>
<h1 className='footer-h1'>{data.title}</h1>
<div className='flex flex-col leading-5'>
{data.links.map((link) => (
{footerLinks.map(({ title, links }) => (
<div key={title}>
<h1 className='footer-h1'>{title}</h1>
<div className='flex flex-col'>
{links.map(({ name, url }) => (
<a
key={link.name}
href={link.url}
target='_blank'
rel="noopener noreferrer"
key={name}
href={url || name?.split(' ').join('-').toLowerCase()}
target={url ? '_blank' : '_self'}
rel='noopener noreferrer'
>
{link.name}
{name}
</a>
))}
</div>
</div>
))}
</div>

<div className='mt-8 sm:hidden'>
<h1 className='footer-h1'>Contribute</h1>
<div className='flex flex-col leading-5'>
<a href='#'>Report Bugs</a>
<a href='#'>Feature Request</a>
<a href='#'>Suggest Design</a>
</div>
</div>

<div className='my-8 h-[1px] w-full bg-gray-500' />

<div className='md:flex-between mx-auto flex flex-col items-center md:flex-row'>
<p className='mb-4 text-secondary md:mb-0'>
Copyright © 2021 Josh Daniel
<div className='mx-auto flex items-center justify-center text-secondary md:justify-between'>
<p className='mr-1 md:mr-0'>
{process.env.NEXT_PUBLIC_VERSION ?? 'v0.0.0'}
</p>
<div className='flex space-x-8 text-base lg:text-xl'>
{socials.map(({ Icon, link }) => (
<a
className='transition-colors hover:text-secondary'
key={Icon.toString()}
target='_blank'
rel='noopener noreferrer'
href={link}
>
<Icon />
</a>
))}
</div>
<p>💛 trackAsOne © 2022</p>
{/* <div className='flex space-x-4 text-base lg:text-xl'>
* {socials.map(({ Icon, link }) => (
* <a
* className='transition-colors hover:text-secondary'
* key={Icon.toString()}
* target='_blank'
* rel='noopener noreferrer'
* href={link}
* >
* <Icon />
* </a>
* ))}
* </div> */}
</div>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ const Layout: React.FC<LayoutProps> = ({
children,
...rest
}) => {
const { user } = useAuth();
const { user, loading } = useAuth();

const display = useMemo(() => {
if (user || allowAll) return children;
return <Error code='401' info='you are not authenticated' />;
if (!loading) return <Error code='401' info='you are not authenticated' />;
return <div />;
}, [user, allowAll, children]);

return (
Expand Down
13 changes: 13 additions & 0 deletions src/components/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import remarkGfm from 'remark-gfm';
import ReactMarkdown from 'react-markdown';

const Markdown = ({ content }: { content: string }) => {
return (
<article className='content prose max-w-none'>
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
</article>
);
};

export default Markdown;
24 changes: 1 addition & 23 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ import { FaSignInAlt } from 'react-icons/fa';
import { useAuth } from '@/contexts/AuthContext';

const Navbar: React.FC = () => {
const { user, signIn, signOut } = useAuth();
const { asPath } = useRouter();

/* const navItems = [
* { name: 'Home', href: user ? '/home' : '/' },
* { name: 'About', href: '/about' },
* { name: 'Contact', href: '/contact' },
* ]; */
const { user, signIn, signOut } = useAuth();

return (
<nav
Expand All @@ -30,22 +24,6 @@ const Navbar: React.FC = () => {
<p className='ml-1 text-xs font-semibold'>BETA</p>
</a>
</Link>

{/* <div className='hidden space-x-8 md:block'>
* {navItems.map(({ name, href }) => {
* return (
* <Link href={href} key={name}>
* <a
* className={`${
* asPath === href && 'text-secondary'
* } text-sm transition-colors hover:text-secondary`}
* >
* {name}
* </a>
* </Link>
* );
* })}
* </div> */}
</div>

<div className='flex items-center space-x-4'>
Expand Down
Loading

1 comment on commit 2e8939b

@vercel
Copy link

@vercel vercel bot commented on 2e8939b Apr 15, 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:

track-as-one – ./

track-as-one-joshxfi.vercel.app
trackasone.me
track-as-one-git-main-joshxfi.vercel.app
trackasone.vercel.app

Please sign in to comment.