react-icons/fi#FiPower JavaScript Examples
The following examples show how to use
react-icons/fi#FiPower.
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: index.js From be-the-hero with MIT License | 5 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([])
const history = useHistory()
const ongId = localStorage.getItem('ongId')
const ongName = localStorage.getItem('ongName')
useEffect(() => {
api.get('profile', {
headers: {
Authorization: ongId,
}
}).then(response => {
setIncidents(response.data)
})
}, [ongId])
async function handleDeleteIncident(id) {
try {
await api.delete(`incidents/${id}`, {
headers: {
Authorization: ongId,
}
})
setIncidents(incidents.filter(incident => incident.id !== id))
} catch (err) {
alert('Erro ao deletar caso, tente novamente.')
}
}
function handleLogout() {
localStorage.clear()
history.push('/')
}
return (
<div className="profile-container">
<header>
<img src={logoImg} alt="Be The Hero" />
<span> Bem-vinda, {ongName} </span>
<Link className="button" to="/incidents/new"> Cadastrar novo caso </Link>
<button onClick={handleLogout} type="button">
<FiPower size={18} color="e02041" />
</button>
</header>
<h1> Casos Cadastrados </h1>
<ul>
{incidents.map(incident => (
<li key={incident.id}>
<strong> CASO: </strong>
<p> {incident.title} </p>
<strong> DESCRIÇÃO: </strong>
<p> {incident.description} </p>
<strong> VALOR: </strong>
<p> {Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(incident.value)} </p>
<button onClick={() => handleDeleteIncident(incident.id)} type="button">
<FiTrash2 size={20} color="#a8a8b3" />
</button>
</li>
))}
</ul>
</div>
)
}
Example #2
Source File: index.js From be-the-hero with MIT License | 5 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([]);
const history = useHistory();
const ongId = localStorage.getItem('ongId');
const ongName = localStorage.getItem('ongName');
useEffect(() => {
api.get('profile', {
headers: {
Authorization: ongId,
}
}).then(response =>{
setIncidents(response.data);
})
}, [ongId]);
async function handleDeleteIncident(id) {
try{
await api.delete(`incidents/${id}`, {
headers: {
Authorization: ongId,
}
});
setIncidents(incidents.filter(incident => incident.id !== id));
} catch (err) {
alert('Erro ao deletar caso, tente novamente.')
}
}
function handleLogout() {
localStorage.clear();
history.push('/');
}
return(
<div className="profile-container">
<header>
<img src={logoImg} alt="Be The Hero" />
<span>Bem vinda, {ongName}</span>
<Link className="button" to="/incidents/new">Cadastrar novo caso</Link>
<button onClick={handleLogout} type="button">
<FiPower size={18} color="#e02041" />
</button>
</header>
<h1>Casos cadastrados</h1>
<ul>
{incidents.map(incident => (
<li key={incident.id}>
<strong>CASO:</strong>
<p>{incident.title}</p>
<strong>DESCRIÇÃO:</strong>
<p>{incident.description}</p>
<strong>VALOR:</strong>
<p>{Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' })
.format(incident.value)}</p>
<button onClick={() => handleDeleteIncident(incident.id)} type="button">
<FiTrash2 size={20} color="#a8a8b3" />
</button>
</li>
))}
</ul>
</div>
);
}
Example #3
Source File: index.js From be-the-hero with MIT License | 5 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([]);
const ongName = localStorage.getItem('ongName');
const ongId = localStorage.getItem('ongId');
const history = useHistory();
useEffect(() => {
api.get('profile', {headers : { Authorization: ongId}})
.then(response => {
setIncidents(response.data);
})
}, [ongId]);
async function handleDeleteIncident(id){
try {
await api.delete(`incidents/${id}`, {
headers : {
Authorization : ongId,
}
});
setIncidents(incidents.filter(incident => incident.id !== id));
} catch (err) {
alert('Erro ao deletar caso, tente novamente');
}
}
function handleLogout() {
localStorage.clear();
history.push('/');
}
return (
<div className="profile-container">
<header>
<img src={logoImg} alt="Be the Hero" />
<span>Bem vindo (a), <strong>{ongName}</strong>!</span>
<Link className="button" to="incidents/new">Cadastrar novo caso</Link>
<button onClick={handleLogout} type="button">
<FiPower size={18} color="#E02041" />
</button>
</header>
<h1>Casos Cadastrados</h1>
<ul>
{incidents.map(incident => (
<li key={incident.id}>
<strong>CASO:</strong>
<p>{incident.title}</p>
<strong>DESCRIÇÃO:</strong>
<p>{incident.description}</p>
<strong>VALOR:</strong>
<p>{Intl.NumberFormat('pt-BR',{ style: 'currency', currency: 'BRL'}).format(incident.value)}</p>
<button onClick={() => handleDeleteIncident(incident.id)} type="button">
<FiTrash2 size={20} color="#E02041" />
</button>
</li>
))}
</ul>
</div>
);
}
Example #4
Source File: index.js From semana-omnistack-11 with MIT License | 5 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([]);
const history = useHistory();
const ongId = localStorage.getItem('ongId');
const ongName = localStorage.getItem('ongName');
useEffect(() => {
api.get('profile', {
headers: {
Authorization: ongId,
}
}).then(response => {
setIncidents(response.data);
})
}, [ongId]);
async function handleDeleteIncident(id) {
try {
await api.delete(`incidents/${id}`, {
headers: {
Authorization: ongId,
}
});
setIncidents(incidents.filter(incident => incident.id !== id));
} catch (err) {
alert('Erro ao deletar caso, tente novamente.');
}
}
function handleLogout() {
localStorage.clear();
history.push('/');
}
return (
<div className="profile-container">
<header>
<img src={logoImg} alt="Be the Hero" />
<span>Bem vinda, {ongName}</span>
<Link className="button" to="/incidents/new">Cadastrar novo caso</Link>
<button onClick={handleLogout} type="button">
<FiPower size={18} color="#E02041" />
</button>
</header>
<h1>Casos cadastrados</h1>
<ul>
{incidents.map(incident => (
<li key={incident.id}>
<strong>CASO:</strong>
<p>{incident.title}</p>
<strong>DESCRIÇÃO:</strong>
<p>{incident.description}</p>
<strong>VALOR:</strong>
<p>{Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(incident.value)}</p>
<button onClick={() => handleDeleteIncident(incident.id)} type="button">
<FiTrash2 size={20} color="#a8a8b3" />
</button>
</li>
))}
</ul>
</div>
);
}
Example #5
Source File: index.js From SemanaOmnistack11 with MIT License | 4 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([]);
const ongName = localStorage.getItem("ongName");
const ongId = localStorage.getItem("ongId");
const history = useHistory();
useEffect(() => {
api
.get("/profile", {
headers: { Authorization: ongId }
})
.then(response => {
setIncidents(response.data);
});
}, [ongId]);
async function handleDeleteIncident(id) {
try {
await api.delete(`incidents/${id}`, {
headers: {
Authorization: ongId
}
});
setIncidents(incidents.filter(incident => incident.id !== id));
} catch (err) {
alert("Erro ao deletar o caso");
}
}
function handleLogout() {
localStorage.clear();
history.push("/");
}
return (
<div className="profile-container">
<header>
<img src={logoImg} alt="Be The Hero" />
<span>Bem vinda, {ongName}</span>
<Link to="/incidents/new" className="button">
Cadastrar novo caso
</Link>
<button type="button" onClick={handleLogout}>
<FiPower size={18} color="#e02041" />
</button>
</header>
<h1> Casos cadastrados</h1>
<ul>
{incidents.map(incident => (
<li key={incident.id}>
<strong>CASO:</strong>
<p>{incident.title}</p>
<strong>DESCRIÇÃO:</strong>
<p>{incident.description}</p>
<strong>VALOR:</strong>
<p>
{Intl.NumberFormat("pt-br", {
style: "currency",
currency: "BRL"
}).format(incident.value)}
</p>
<button
type="button"
onClick={() => handleDeleteIncident(incident.id)}
>
<FiTrash2 size={20} color="#a8a8b3" />
</button>
</li>
))}
</ul>
</div>
);
}
Example #6
Source File: index.js From be-the-hero with MIT License | 4 votes |
export default function Profile() {
const [incidents, setIncidents] = useState([]);
const history = useHistory();
const ongName = localStorage.getItem('ongName');
const ongId = localStorage.getItem('ongId');
function handleNavigateNewIncident() {
history.push('/incidents/new');
}
async function handleDeleteIncident(id) {
try {
await api.delete(`incidents/${id}`, {
headers: {
Authorization: ongId,
}
});
setIncidents(incidents.filter(incident => incident.id !== id));
} catch (err) {
alert('Erro ao deletar caso, tente novamete.');
}
}
async function handleLogout() {
localStorage.clear();
history.push('/')
}
useEffect(() => {
async function loadIncidents() {
const response = await api.get('profile', {
headers: {
Authorization: ongId,
}
});
const data = response.data.map(incident => ({
...incident,
valueFormated: formatPrice(incident.value),
}));
setIncidents(data);
}
loadIncidents();
}, [ongId]);
return (
<Container>
<header>
<img src={logoImg} alt="Be The Hero"/>
<span>Bem Vinda, {ongName}</span>
<NavigateButton onClick={handleNavigateNewIncident}>
Cadastrar novo caso
</NavigateButton>
<button onClick={handleLogout} type="button">
<FiPower size={24} color={colors.redHero} />
</button>
</header>
<h1>Casos cadastrados</h1>
<Listagem>
{incidents.map(incident => (
<li key={incident.id}>
<strong>CASO:</strong>
<p>{incident.title}</p>
<strong>DESCRIÇÃO:</strong>
<p>{incident.description}</p>
<strong>VALOR:</strong>
<p>{incident.valueFormated}</p>
<button
onClick={() => handleDeleteIncident(incident.id)}
type="button"
>
<FiTrash2 size={24} color={colors.textosSecundarios} />
</button>
</li>
))}
</Listagem>
</Container>
);
}