Skip to content
Merged
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
5 changes: 2 additions & 3 deletions plop-templates/component.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import { getPlayById } from 'meta/play-meta-util';

import PlayHeader from 'common/playlists/PlayHeader';

function {{pascalCase name}}() {
function {{pascalCase name}}(props) {
// Do not remove the below lines.
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

// Your Code Start below.
Expand Down
4 changes: 3 additions & 1 deletion src/common/routing/RouteDefs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { Footer, Header, Home, PageNotFound } from "common";
import PlayList from "common/playlists/PlayList";
import { getAllPlays } from "meta/play-meta-util";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { cloneElement } from 'react'

const RouteDefs = () => {
const plays = getAllPlays();

return (
<BrowserRouter>
<Header />
Expand All @@ -14,7 +16,7 @@ const RouteDefs = () => {
<Route path="/plays" element={<App />}>
<Route index element={<PlayList />} />
{plays.map((play, index) => (
<Route key={index} path={play.path} element={play.component()} />
<Route key={index} path={play.path} element={cloneElement(play.component(), {id: play.id})}/>
))}
</Route>
<Route path="/*" element={<PageNotFound />} />
Expand Down
7 changes: 3 additions & 4 deletions src/plays/clock/CurrentTimer.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

import PlayHeader from 'common/playlists/PlayHeader';
import { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { getPlayById } from 'meta/play-meta-util';

import "./clock.css";

const CurrentTimer = () => {
const CurrentTimer = (props) => {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

// Create a real-time date time counter
const [date, setDate] = useState(new Date());

Expand Down
6 changes: 2 additions & 4 deletions src/plays/counter/CounterApp.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import PlayHeader from "common/playlists/PlayHeader";
import { useState } from 'react';
import { useLocation } from 'react-router-dom';
import { getPlayById } from 'meta/play-meta-util';
import Counter from "./Counter";
import "./counter.css";

function CounterApp() {
function CounterApp(props) {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

const [input, setInput] = useState("");
Expand Down
6 changes: 2 additions & 4 deletions src/plays/date-time-counter/CdTimerComp.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import PlayHeader from "common/playlists/PlayHeader";
import { useState } from "react";
import { useLocation } from "react-router-dom";
import { getPlayById } from "meta/play-meta-util";
import CountDownTimer from "./CountDownTimer";

const CdTimerComp = () => {
const CdTimerComp = (props) => {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

const THREE_DAYS_IN_MS = 3 * 24 * 60 * 60 * 1000;
Expand Down
6 changes: 2 additions & 4 deletions src/plays/movies/MovieContainer.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import PlayHeader from "common/playlists/PlayHeader";
import { useEffect, useState } from "react";
import { useLocation } from "react-router-dom";
import { getPlayById } from "meta/play-meta-util";
import Movie from "./Movie";

import useFetch from "common/hooks/useFetch";

import "./movies.css";

const MovieContainer = () => {
const MovieContainer = (props) => {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

const MOVIE_API_URI = 'https://json-faker.onrender.com/movies';
Expand Down
6 changes: 2 additions & 4 deletions src/plays/org-tree/BasicTree.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import PlayHeader from "common/playlists/PlayHeader";
import { useLocation } from "react-router-dom";
import { getPlayById } from "meta/play-meta-util";
import { org } from "./org";
import React, { Fragment } from "react";
Expand All @@ -21,10 +20,9 @@ const Card = (props) => {
);
};

const BasicTree = () => {
const BasicTree = (props) => {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

return (
Expand Down
7 changes: 2 additions & 5 deletions src/plays/random-meme-generator/RandomMemeGenerator.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@

import { useLocation } from 'react-router-dom';
import { getPlayById } from 'meta/play-meta-util';
import { useState, useEffect } from 'react';
import { FaSyncAlt } from 'react-icons/fa';

import PlayHeader from 'common/playlists/PlayHeader';
import './random-meme-generator.css';

function RandomMemeGenerator() {
function RandomMemeGenerator(props) {
// Do not remove the below lines.
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

// Your Code Start below.
Expand Down
6 changes: 2 additions & 4 deletions src/plays/social-card/SocialCard.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useState } from "react";
import { useLocation } from 'react-router-dom';
import { getPlayById } from 'meta/play-meta-util';

import PlayHeader from 'common/playlists/PlayHeader';
Expand All @@ -11,10 +10,9 @@ import { SocialContext } from './context/SocialContext';

import "./social-card.css";

function SocialCard() {
function SocialCard(props) {
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

// The social state carry the information of the social
Expand Down
6 changes: 2 additions & 4 deletions src/plays/states/States.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { useState } from "react";
import { useLocation } from "react-router-dom";
import { getPlayById } from "meta/play-meta-util";
import PlayHeader from "common/playlists/PlayHeader";
import "./states.css";

function States() {
function States(props) {
// Do not remove the below lines.
// The following code is to fetch the current play from the URL
const location = useLocation();
const { id } = location.state;
const { id } = props;
const play = getPlayById(id);

// Your Code Start below.
Expand Down