react-icons/fa#FaClock JavaScript Examples

The following examples show how to use react-icons/fa#FaClock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskFeedback.js    From fokus with GNU General Public License v3.0 4 votes vote down vote up
export function TaskFeedback({ task, time, setInputValid }) {
    let [error, setError] = useState(undefined);

    useEffect(() => {
        let errorGenerated = false;
        if (task !== undefined) {
            // if time is there, it should be stripped and validated first before the actual task content
            let temp = task?.trim().split(" ");
            if (temp !== undefined && !isNaN(parseInt(temp[temp.length - 1]))) {
                let taskTime = parseInt(temp.pop());
                if (taskTime <= 0) {
                    setError("Hmmm. Time for this task seems weird,no?");
                    errorGenerated = true;
                    setInputValid(false);
                    return;
                } else if (taskTime > 120) {
                    setError("Time should be <120mins for better focus !");
                    errorGenerated = true;
                    setInputValid(false);
                    return;
                }
            }
            temp = temp?.join(" ");

            if (temp?.length === 0) {
                setError(undefined);
                errorGenerated = true;
                setInputValid(false);
            } else if (temp?.length < 3) {
                setError("Task should be atleast 3 characters long.");
                errorGenerated = true;
                setInputValid(false);
            } else if (temp?.length > 100) {
                setError("Hey, that's too long. Keep it short and simple.");
                errorGenerated = true;
                setInputValid(false);
            } else {
                setError(undefined);
                setInputValid(true);
            }
        }

        if (!errorGenerated) {
            // will check for error in time only if no error in task
            if (time !== undefined && time !== "") {
                let numericTime = parseInt(time);
                if (numericTime <= 0 || numericTime > 120) {
                    setError("Time should be between 1-120 mins");
                    setInputValid(false);
                } else {
                    setError(undefined);
                    setInputValid(true);
                }
            }
        }
    }, [task, time, setInputValid]);

    const remainingTaskListTime = useSelector((s) => s.tasks.meta.remainingTaskListTime);
    const rTLTObj = getFormattedListTimeSummary(remainingTaskListTime);
    let rTLTHours = rTLTObj.hours;
    let rTLTMins = rTLTObj.mins;

    return (
        <TaskFeedbackContainer>
            {error === undefined ? (
                <RemainingTaskListTimeDiv>
                    {remainingTaskListTime === 0 ? (
                        <p>Create New Task</p>
                    ) : (
                        <>
                            <FaClock />
                            <p>list time:</p>
                            {rTLTHours !== "0" && <span>{rTLTHours}h</span>}
                            {rTLTMins !== "00" && <span>{rTLTMins}m</span>}
                        </>
                    )}
                </RemainingTaskListTimeDiv>
            ) : (
                <ErrorMessage>
                    <p>{error}</p>
                </ErrorMessage>
            )}
        </TaskFeedbackContainer>
    );
}