Invite page now loads when not logged in.

This commit is contained in:
theADAMJR 2023-06-07 06:46:37 +01:00
parent ff6daf58ab
commit cc1845e7bf
8 changed files with 21 additions and 9 deletions

View File

@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Bug fixes and stability updates to make accord a more smooth experience.
### Added
- Recaptcha to prevent API abuse to registration and login form.
- Recaptcha for register, login, and forgot password to prevent API abuse.
### Fixed
- Invite page now loads invite when not in guild.

View File

@ -93,9 +93,11 @@ WEBSITE_URL="http://localhost:4200"
SESSION_SECRET="Please ⭐ this repository."
```
---
## Troubleshooting
### App does not connect to MongoDB on Windows?
- Ensure MongoDB is installed.
- If localhost does not work, use `mongodb://127.0.0.1:27017/accord`.
- https://stackoverflow.com/a/73139137/8304458
- https://stackoverflow.com/a/73139137/8304458

View File

@ -10,7 +10,11 @@ export const router = Router();
// NOTE: Basic guild metadata is 'unlisted' and can be accessed by anyone with the URL.
router.get('/:id', async (req, res) => {
const guild = await deps.guilds.get(req.params.id);
const [guild, members] = await Promise.all([
deps.guilds.get(req.params.id),
deps.guilds.getMembers(req.params.id),
]);
guild.memberCount = members.length;
res.json(guild);
});

View File

@ -8,7 +8,7 @@
"name": "@acrd/frontend",
"version": "0.6.0-pre-release",
"dependencies": {
"@acrd/types": "file:./src/types",
"@acrd/types": "file:src/types",
"@craco/craco": "^5.9.0",
"@dvhb/craco-extend-scope": "^1.0.1",
"@fortawesome/fontawesome-svg-core": "^1.2.35",

View File

@ -4,7 +4,7 @@
"private": true,
"homepage": "https://acrd.app/",
"dependencies": {
"@acrd/types": "file:./src/types",
"@acrd/types": "file:src/types",
"@craco/craco": "^5.9.0",
"@dvhb/craco-extend-scope": "^1.0.1",
"@fortawesome/fontawesome-svg-core": "^1.2.35",

View File

@ -1,4 +1,4 @@
import { Entity } from '@acrd/types';
import { Entity, UserTypes } from '@acrd/types';
import { faSearchLocation } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useEffect } from 'react';
@ -21,12 +21,15 @@ const InvitePage: React.FunctionComponent<InvitePageProps> = () => {
const history = useHistory();
const dispatch = useDispatch();
const { inviteId }: any = useParams();
const selfUser: UserTypes.Self = useSelector((s: Store.AppState) => s.auth.user);
const invite: Entity.Invite = useSelector(getInvite(inviteId));
const guild: Entity.Guild | undefined = useSelector(getGuild(invite?.guildId));
const members: Entity.GuildMember[] = useSelector(getGuildMembers(invite?.guildId));
const ownerUser: Entity.User = useSelector(getUser(guild!?.ownerId));
useEffect(() => {
dispatch(fetchEntities());
}, [selfUser]);
useEffect(() => {
dispatch(fetchInvite(inviteId));
}, []);
@ -76,7 +79,8 @@ const InvitePage: React.FunctionComponent<InvitePageProps> = () => {
<div className="flex justify-around items-center w-full mx-5">
<span className='text-center'>
<div className="heading font-bold text-center">Members</div>
<code>{members.length}</code>
<code>{guild.memberCount || 'Unknown'}
</code>
</span>
<span className='text-center'>
<div className="heading font-bold">Owned By</div>

View File

@ -23,6 +23,7 @@ export declare namespace Entity {
id: string;
name: string;
createdAt: Date;
memberCount?: Number;
iconURL?: string;
ownerId: string;
systemChannelId?: string;

View File

@ -23,6 +23,7 @@ export namespace Entity {
id: string;
name: string;
createdAt: Date;
memberCount?: Number;
iconURL?: string;
ownerId: string;
systemChannelId?: string;