Last active
May 17, 2024 07:34
-
-
Save pabletecodes/73ca613d8547690dff37f950971c7411 to your computer and use it in GitHub Desktop.
Design Challenge 001: Building a Flexible…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TemplateSelector = ({ templates }) => { | |
return ( | |
<div> | |
<SearchBar /> | |
<Category /> | |
<TemplateList templates={templates} /> | |
</div> | |
); | |
}; | |
const NewProjectHeader = () => { | |
const { user } = useCurrentUser(); | |
return ( | |
<div> | |
<h1>Welcome, {user.name}</h1> | |
<p>Choose the request ...</p> | |
</div> | |
); | |
}; | |
const CreatingNewRequestTypeHeader = () => { | |
return ( | |
<div> | |
<h1>Select a request type</h1> | |
<p>Select a template ...</p> | |
</div> | |
); | |
}; | |
const headerComponents = { | |
creating_new_project: NewProjectHeader, | |
creating_new_request_type: CreatingNewRequestTypeHeader({ user }), | |
}; | |
const RequestTypeBuilder = ({ renderedIn }) => { | |
const { templates } = useTemplates(); // fetch templates from remote | |
const getHeader = () => { | |
const headerComponent = headerComponents[renderedIn]; | |
return headerComponent ? headerComponent() : null; | |
}; | |
return ( | |
<div> | |
{getHeader()} | |
<TemplateSelector templates={templates} /> | |
</div> | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Header = ({ title, description }) => { | |
return ( | |
<div> | |
<h1>{ title }</h1> | |
<p> { description }</p> | |
</div> | |
); | |
}; | |
const NewProjectHeader = () => { | |
const { user } = useCurrentUser(); | |
return Header({ | |
title: `Welcome, ${user.name}`, | |
description: 'Choose the request ...' | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment