Skip to content

Commit

Permalink
release: v0.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
joshxfi authored Feb 10, 2023
2 parents b90e2a1 + 3739da3 commit 172ba1c
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 89 deletions.
201 changes: 201 additions & 0 deletions apps/web/src/components/Dialog/AddClue.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import React, { useState, useCallback } from 'react';
import { useSession } from 'next-auth/react';
import { HiRefresh } from 'react-icons/hi';
import toast from 'react-hot-toast';

import { DialogContainer, DialogContainerProps } from '.';

type Options = 'message' | 'username' | '';

interface Props extends DialogContainerProps {
clue: string;
setClue: React.Dispatch<React.SetStateAction<string>>;
}

export const AddClueDialog = ({ clue, setClue, setIsOpen, ...rest }: Props) => {
const [msgClue, setMsgClue] = useState('');
const [randomUsername, setRandomUsername] = useState('');
const [attachedClue, setAttachedClue] = useState<Options>('');
const [currentOption, setCurrentOption] = useState<Options>('');

const { data: session } = useSession();

const closeDialog = () => {
setIsOpen(false);
setTimeout(() => {
setCurrentOption('');
}, 500);
};

const scrambleUsername = useCallback(() => {
const scrambled = session?.user?.username
?.split('')
.sort(() => 0.5 - Math.random())
.join('');

if (!session?.user?.username) {
toast.error('Could not scramble username: try relogging');
}

return scrambled ?? '';
}, [session?.user?.username]);

return (
<DialogContainer
{...rest}
transparent
setIsOpen={setIsOpen}
className='grid h-full place-items-center'
>
<div className='msg-card p-6'>
{currentOption === '' && (
<div className='flex flex-col'>
<h2 className='font-semibold'>
🧩 Select a clue to attach to your message
</h2>
<div className='line my-3' />
<div className='space-y-3 [&>*]:clue-btn'>
<button
type='button'
onClick={() => setCurrentOption('message')}
className={
attachedClue === 'message'
? 'border-green-500'
: 'border-gray-500'
}
>
Write a clue about your identity
</button>
<button
type='button'
onClick={() => {
if (!session?.user?.username) {
toast.error('Could not scramble username: try relogging');
return;
}

setCurrentOption('username');
setRandomUsername(scrambleUsername());
}}
className={
attachedClue === 'username'
? 'border-green-500'
: 'border-gray-500'
}
>
Attach scrambled username
</button>
</div>

<p className='mt-8 text-gray-400 italic text-sm'>
You can only add 1 type of clue
</p>
<button
type='button'
className='self-end'
onClick={() => setIsOpen(false)}
>
Close
</button>
</div>
)}

{currentOption === 'message' && (
<form className='flex flex-col'>
<h2 className='font-semibold'>
🧩 Write a clue about your identity
</h2>
<div className='line my-3' />

<textarea
required
value={msgClue}
onChange={(e) => setMsgClue(e.target.value)}
maxLength={100}
placeholder='Enter here...'
className='bg-secondary-100 w-full h-[120px] outline-none py-3 px-4 rounded-md resize-none'
/>

<div className='mt-8 flex items-center space-x-4 self-end'>
<button type='button' onClick={() => setCurrentOption('')}>
Go Back
</button>

<button
type='button'
className='primary-btn'
onClick={() => {
if (msgClue.length > 0) {
setAttachedClue('message');
setClue(msgClue);
} else {
setAttachedClue('');
setClue('');
}

toast.success(
msgClue.length > 0 ? 'Clue added' : 'Clue removed'
);
closeDialog();
}}
>
Save
</button>
</div>
</form>
)}

{currentOption === 'username' && (
<div className='flex flex-col'>
<h2 className='font-semibold'>🧩 Scramble username</h2>
<div className='line my-3' />

<div className='flex space-x-2'>
<p className='bg-secondary-100 w-full outline-none px-4 py-4 rounded-md'>
{randomUsername}
</p>

<button
type='button'
onClick={() => setRandomUsername(scrambleUsername())}
className='rounded-md bg-secondary-300 border-2 border-secondary-100 px-4 text-xl flex-none'
>
<HiRefresh />
</button>
</div>

<div className='mt-8 flex items-center space-x-4 self-end'>
<button type='button' onClick={() => setCurrentOption('')}>
Go Back
</button>

<button
type='button'
className='primary-btn'
onClick={() => {
if (attachedClue === 'username') {
setAttachedClue('');
setClue('');
} else {
setAttachedClue('username');
setClue(randomUsername);
}

toast.success(
`${
attachedClue === 'username' ? 'Detached' : 'Attached'
} scrambled username`
);

closeDialog();
}}
>
{attachedClue === 'username' ? 'Detach' : 'Attach'}
</button>
</div>
</div>
)}
</div>
</DialogContainer>
);
};
9 changes: 8 additions & 1 deletion apps/web/src/components/Dialog/Clue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ export const ClueDialog = ({ clue, setIsOpen, ...rest }: Props) => {
<div className='text-sm bg-secondary-100 py-3 px-4 rounded-md'>
<p>{clue}</p>
</div>

{clue.length <= 12 && (
<p className='mt-4 text-gray-400 italic text-sm'>
It could be a scrambled username!
</p>
)}

<button
type='button'
className='self-end mt-8'
className={`self-end ${clue.length > 12 && 'mt-8'}`}
onClick={() => setIsOpen(false)}
>
Close
Expand Down
20 changes: 11 additions & 9 deletions apps/web/src/components/Dialog/Confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { DialogContainer, DialogContainerProps } from '.';

interface Props extends DialogContainerProps {
content: React.ReactNode;
handleConfirm: () => void;
confirmText: string;
handleConfirm?: () => void;
confirmText?: string;
cancelText?: string;
danger?: boolean;
}
Expand Down Expand Up @@ -42,13 +42,15 @@ export const ConfirmDialog = ({
{cancelText}
</button>

<button
className={danger ? 'red-btn' : 'primary-btn'}
type='button'
onClick={handleConfirm}
>
{confirmText}
</button>
{confirmText && (
<button
className={danger ? 'red-btn' : 'primary-btn'}
type='button'
onClick={handleConfirm}
>
{confirmText}
</button>
)}
</div>
</div>
</DialogContainer>
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/Dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export * from './Clue';
export * from './Reply';
export * from './Confirm';
export * from './Message';
export * from './AddClue';
export * from './Settings';
export * from './Container';
14 changes: 11 additions & 3 deletions apps/web/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,23 @@ export const Footer = () => {
<ImageFill
alt='logo'
src='/assets/logo.svg'
className='relative object-contain mb-4 h-6 w-32 md:hidden'
className='relative object-contain mb-2 h-6 w-32 md:hidden'
/>
<a
href='https://github.com/omsimos'
target='_blank'
rel='noreferrer noopener'
className='text-xs font-medium text-gray-500 hover:underline sm:text-sm md:text-base'
className='font-medium text-gray-500 hover:underline text-sm md:text-base'
>
Ⓒ 2023 Omsimos Collective
Omsimos Collective
</a>
<a
href='https://github.com/joshxfi'
target='_blank'
rel='noreferrer noopener'
className='mt-2 font-medium text-gray-500 hover:underline text-sm md:text-base'
>
Ⓒ 2023 Josh Daniel Bañares
</a>
</div>
</footer>
Expand Down
21 changes: 10 additions & 11 deletions apps/web/src/components/InboxTabs/SeenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ interface Props {

export const SeenCard = ({ message, refetch }: Props) => {
const cardRef = useRef<HTMLDivElement>(null);
const { id, content, clue, receiverMsg, reply, createdAt } = message;
const { id, content, clue, receiverMsg, reply, createdAt } =
message;
const { user } = useInboxContext();
const triggerEvent = useLogEvent();

const [deleteModal, setDeleteModal] = useState(false);
const [clueDialog, setClueDialog] = useState(false);
const [deleteModal, setDeleteModal] = useState(false);
const [replyModal, setReplyModal] = useState(false);
const [cardModal, setCardModal] = useState(false);

Expand Down Expand Up @@ -174,15 +175,13 @@ export const SeenCard = ({ message, refetch }: Props) => {
})}
</p>

{clue && (
<button
type='button'
onClick={() => setClueDialog(true)}
className='absolute text-lg right-3 bottom-3'
>
🧩
</button>
)}
<div className='absolute text-lg right-3 bottom-3 space-x-4'>
{clue && (
<button type='button' onClick={() => setClueDialog(true)}>
🧩
</button>
)}
</div>
</div>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/InboxTabs/Sent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const Sent = () => {
<div className='border-secondary-100 flex items-center justify-between border-b-2 bg-[#171819] px-7 py-3'>
<p className='font-medium text-gray-100'>
<span className='font-light text-gray-400'>To&#58;</span>{' '}
{m.username}
{m.receiverUsername}
</p>
<h3 className='font-syneExtrabold text-primary-200 text-center text-base'>
umamin
Expand All @@ -51,7 +51,7 @@ export const Sent = () => {
type='receiver'
content={m.receiverMsg}
userData={{
username: m?.username,
username: m?.receiverUsername,
}}
/>
<ChatBubble type='sender' content={m.content} />
Expand All @@ -61,7 +61,7 @@ export const Sent = () => {
type='receiver'
content={m.reply}
userData={{
username: m.username,
username: m.receiverUsername,
}}
/>
)}
Expand Down
10 changes: 10 additions & 0 deletions apps/web/src/components/UserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ export const UserForm = ({ type, onRegister, loading }: Props) => {
Email is already linked to a different provider
</p>
)}

{!isLogin && (
<p className=' mt-6 text-sm self-center text-center'>
By creating an account, you agree to our
<Link href='privacy-policy' className='text-primary-100'>
{' '}
Privacy Policy
</Link>
</p>
)}
</div>
</form>
<div className='absolute bottom-40 top-0 left-0 right-0 m-auto max-h-[650px] max-w-[650px] md:bottom-0'>
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ const options: NextAuthOptions = {
signIn: '/login',
},
callbacks: {
jwt({ token }) {
jwt({ token, user }) {
if (user) {
token.username = user.username;
return token;
}
return token;
},
session({ session, token }) {
Expand Down
Loading

1 comment on commit 172ba1c

@vercel
Copy link

@vercel vercel bot commented on 172ba1c Feb 10, 2023

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:

umamin – ./

umamin-omsimos.vercel.app
www.umamin.link
umamin-git-main-omsimos.vercel.app
umamin.link

Please sign in to comment.