Skip to content

Commit

Permalink
Add default create board values, required fileds (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
yauvink authored Jan 17, 2022
1 parent d061a6f commit 41a3ae8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
25 changes: 18 additions & 7 deletions app/javascript/components/create-board/create-board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useState} from 'react';
import Picker from 'emoji-picker-react';
import {faSmile} from '@fortawesome/free-regular-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {getBoardDateName} from '../../utils/get-date';
import style from './style.module.css';

const EmojiIcon = ({emojiColumnName, formData, setEmojiData}) => {
Expand All @@ -26,13 +27,19 @@ const EmojiIcon = ({emojiColumnName, formData, setEmojiData}) => {

export const CreateBoard = ({isCreateBoardOpen, setCreateBoardOpen}) => {
const [formData, setformData] = useState({
boardName: '',
firstColumnName: '',
firstColumnEmoji: null,
secondColumnName: '',
secondColumnEmoji: null,
thirdColumnName: '',
thirdColumnEmoji: null
boardName: getBoardDateName(Date.now()),
firstColumnName: 'Mad',
firstColumnEmoji: {
emoji: '😔',
},
secondColumnName: 'Sad',
secondColumnEmoji: {
emoji: '😡'
},
thirdColumnName: 'Glad',
thirdColumnEmoji: {
emoji: '🤗'
}
});

const [emojiData, setEmojiData] = useState({
Expand Down Expand Up @@ -78,6 +85,7 @@ export const CreateBoard = ({isCreateBoardOpen, setCreateBoardOpen}) => {
boardName: element.currentTarget.value
})
}
required
/>
</div>
<div className="form-element">
Expand All @@ -92,6 +100,7 @@ export const CreateBoard = ({isCreateBoardOpen, setCreateBoardOpen}) => {
firstColumnName: element.currentTarget.value
})
}
required
/>
<EmojiIcon
emojiColumnName="firstColumnEmoji"
Expand All @@ -111,6 +120,7 @@ export const CreateBoard = ({isCreateBoardOpen, setCreateBoardOpen}) => {
secondColumnName: element.currentTarget.value
})
}
required
/>
<EmojiIcon
emojiColumnName="secondColumnEmoji"
Expand All @@ -130,6 +140,7 @@ export const CreateBoard = ({isCreateBoardOpen, setCreateBoardOpen}) => {
thirdColumnName: element.currentTarget.value
})
}
required
/>
<EmojiIcon
emojiColumnName="thirdColumnEmoji"
Expand Down
1 change: 1 addition & 0 deletions app/javascript/components/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ a.active {
border: 1px solid #b1b1b1;
box-sizing: border-box;
border-radius: 4px;
padding-left: 10px;
}
.input:hover {
border: 1px solid #797474;
Expand Down
7 changes: 6 additions & 1 deletion app/javascript/utils/get-date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {enGB} from 'date-fns/locale';
import {formatRelative, subDays} from 'date-fns';
import {formatRelative, subDays, format} from 'date-fns';

const formatRelativeLocale = {
lastWeek: " 'Last' eeee, 'at' HH:mm",
Expand All @@ -20,3 +20,8 @@ export const getDate = (createdAt) => {
locale
});
};

export const getBoardDateName = (date) => {
if (!date) return date;
return format(date, "dd-MM-yyyy");
};

0 comments on commit 41a3ae8

Please sign in to comment.