This repository has been archived by the owner on Dec 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from Cassianky/create-testimonials
[Admin] Create testimonials
- Loading branch information
Showing
13 changed files
with
1,016 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
74 changes: 74 additions & 0 deletions
74
admin-frontend/src/components/testimonial/ManageTestimonials.jsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { useTheme } from "@emotion/react"; | ||
import { CircularProgress, Tab, Tabs, Typography } from "@mui/material"; | ||
import { useEffect, useState } from "react"; | ||
import { | ||
useSnackbarStore, | ||
useTestimonialStore, | ||
} from "../../zustand/GlobalStore"; | ||
import MainBodyContainer from "../common/MainBodyContainer"; | ||
import VisibilityIcon from "@mui/icons-material/Visibility"; | ||
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff"; | ||
import TestimonialsTable from "./TestimonialsTable"; | ||
|
||
function ManageTestimonials() { | ||
const theme = useTheme(); | ||
|
||
const { openSnackbar } = useSnackbarStore(); | ||
const { | ||
testimonials, | ||
getAllTestimonials, | ||
isLoading, | ||
toggleTestimonialVisibility, | ||
} = useTestimonialStore(); | ||
|
||
const handleToggle = async (testimonialId) => { | ||
try { | ||
await toggleTestimonialVisibility(testimonialId); | ||
} catch (error) { | ||
console.error(error); | ||
openSnackbar("An error occurred", "error"); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
await getAllTestimonials(); | ||
} catch (err) { | ||
console.error(err); | ||
openSnackbar("Error when retrieving testimonials.", "error"); | ||
} | ||
}; | ||
fetchData(); | ||
}, [getAllTestimonials]); | ||
|
||
if (isLoading) { | ||
return <CircularProgress />; | ||
} | ||
return ( | ||
<MainBodyContainer | ||
hasBackButton={false} | ||
breadcrumbNames={[]} | ||
breadcrumbLinks={[]} | ||
currentBreadcrumbName={"Manage Testimonials"} | ||
> | ||
<Typography | ||
fontSize={25} | ||
fontWeight={700} | ||
noWrap | ||
component="div" | ||
color={theme.palette.primary.main} | ||
> | ||
Manage Testimonials | ||
</Typography> | ||
{testimonials && ( | ||
<TestimonialsTable | ||
testimonials={testimonials} | ||
handleToggle={handleToggle} | ||
/> | ||
)} | ||
</MainBodyContainer> | ||
); | ||
} | ||
|
||
export default ManageTestimonials; |
Oops, something went wrong.