Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevPortfolioDao Documentation #510

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ All the common types used by the packages are defined [here](./common-types/inde
- **Jason Mun** - PM
- **Andrew Chen** - TPM
- **Hope Zheng** - Designer
- **Vicky Wang** - Designer
- **Vannessa Wong** - Designer
- **Oscar Wang** - Developer
- **Alyssa Zhang** - Developer
- **Patricia Huang** - Developer
- **Kevin Ram** - Developer

### Spring 2023

Expand Down
1 change: 0 additions & 1 deletion frontend/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Form, TextArea, Checkbox } from 'semantic-ui-react';
import { Form, TextArea, Checkbox, Loader } from 'semantic-ui-react';
import { useUserEmail } from '../../Common/UserProvider/UserProvider';
import { Emitters } from '../../../utils';
import ShoutoutsAPI from '../../../API/ShoutoutsAPI';
Expand All @@ -17,8 +17,10 @@ const ShoutoutForm: React.FC<ShoutoutFormProps> = ({ getGivenShoutouts }) => {
const [receiver, setReceiver] = useState('');
const [message, setMessage] = useState('');
const [isAnon, setIsAnon] = useState(true);
const [isSubmitting, setIsSubmitting] = useState(false);

const giveShoutout = () => {
setIsSubmitting(true);
if (!receiver) {
Emitters.generalError.emit({
headerMsg: 'No Member Selected',
Expand All @@ -35,6 +37,7 @@ const ShoutoutForm: React.FC<ShoutoutFormProps> = ({ getGivenShoutouts }) => {
uuid: ''
};
ShoutoutsAPI.giveShoutout(shoutout).then((val) => {
setIsSubmitting(false);
if (val.error) {
Emitters.generalError.emit({
headerMsg: "Couldn't send shoutout!",
Expand Down Expand Up @@ -83,8 +86,8 @@ const ShoutoutForm: React.FC<ShoutoutFormProps> = ({ getGivenShoutouts }) => {
/>
</div>

<Form.Button floated="right" onClick={giveShoutout}>
Send
<Form.Button floated="right" onClick={giveShoutout} disabled={isSubmitting}>
{isSubmitting ? <Loader active inline size='small' /> : 'Send'}
</Form.Button>
</Form>
);
Expand Down
20 changes: 15 additions & 5 deletions frontend/src/components/Forms/ShoutoutsPage/ShoutoutsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
/* eslint-disable no-nested-ternary */
import React, { useState, useEffect, useCallback } from 'react';
import { Message } from 'semantic-ui-react';
import { Message, Loader } from 'semantic-ui-react';
import { useUserEmail } from '../../Common/UserProvider/UserProvider';
import { Emitters } from '../../../utils';
import ShoutoutForm from './ShoutoutForm';
import ShoutoutList from './ShoutoutList';
import styles from './ShoutoutsPage.module.css';
import ShoutoutsAPI from '../../../API/ShoutoutsAPI';


const ShoutoutsPage: React.FC = () => {
const userEmail = useUserEmail();
const [givenShoutouts, setGivenShoutouts] = useState<Shoutout[]>([]);

const [isLoading, setIsLoading] = useState<boolean>(true);

const getGivenShoutouts = useCallback(() => {
setIsLoading(true);
ShoutoutsAPI.getShoutouts(userEmail, 'given')
.then((given) => setGivenShoutouts(given))
.then((given) => {
setGivenShoutouts(given);
setIsLoading(false);
})
.catch((error) => {
Emitters.generalError.emit({
headerMsg: `Couldn't get given shoutouts!`,
contentMsg: `Error was: ${error}`
});
setIsLoading(false);
});
}, [userEmail]);

useEffect(() => {
getGivenShoutouts();
}, [userEmail, getGivenShoutouts]);
Expand All @@ -34,7 +42,9 @@ const ShoutoutsPage: React.FC = () => {

<div className={styles.shoutoutListContainer}>
<h2>Given Shoutouts</h2>
{givenShoutouts.length > 0 ? (
{isLoading ? (
<Loader active inline='centered' />
) : givenShoutouts.length > 0 ? (
<ShoutoutList
shoutouts={givenShoutouts.sort((a, b) => a.timestamp - b.timestamp)}
setGivenShoutouts={setGivenShoutouts}
Expand Down
Loading