feat: agregar función onRefresh en HeaderEditPopup y actualizar llamada en OrganizationPublicProfile
This commit is contained in:
@@ -22,10 +22,11 @@ interface HeaderEditPopupProps {
|
|||||||
headerFontShadowColor: string;
|
headerFontShadowColor: string;
|
||||||
headerImage: string;
|
headerImage: string;
|
||||||
onSaved: () => void;
|
onSaved: () => void;
|
||||||
|
onRefresh?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function HeaderEditPopup(props: HeaderEditPopupProps) {
|
export default function HeaderEditPopup(props: HeaderEditPopupProps) {
|
||||||
const { open, onClose, companyId, headerColor, headerFontColor, headerFontShadowColor, headerImage, onSaved } = props;
|
const { open, onClose, companyId, headerColor, headerFontColor, headerFontShadowColor, headerImage, onSaved, onRefresh } = props;
|
||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const SessionInfo = useSessionStore();
|
const SessionInfo = useSessionStore();
|
||||||
const organizationHeader = useOrganizationHeaderStore();
|
const organizationHeader = useOrganizationHeaderStore();
|
||||||
@@ -65,6 +66,7 @@ export default function HeaderEditPopup(props: HeaderEditPopupProps) {
|
|||||||
|
|
||||||
alert.showSuccess("Colores actualizados");
|
alert.showSuccess("Colores actualizados");
|
||||||
onSaved();
|
onSaved();
|
||||||
|
onRefresh?.();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const formatted = error instanceof Error ? error.message : "Error al guardar los colores";
|
const formatted = error instanceof Error ? error.message : "Error al guardar los colores";
|
||||||
alert.showError(formatted || "Error al guardar los colores");
|
alert.showError(formatted || "Error al guardar los colores");
|
||||||
@@ -88,6 +90,7 @@ export default function HeaderEditPopup(props: HeaderEditPopupProps) {
|
|||||||
uploadHeaderImage(formData).then(() => {
|
uploadHeaderImage(formData).then(() => {
|
||||||
alert.showSuccess("Imagen actualizada");
|
alert.showSuccess("Imagen actualizada");
|
||||||
onSaved();
|
onSaved();
|
||||||
|
onRefresh?.();
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
const formatted = error instanceof Error ? error.message : "Error al guardar la imagen";
|
const formatted = error instanceof Error ? error.message : "Error al guardar la imagen";
|
||||||
alert.showError(formatted || "Error al guardar la imagen");
|
alert.showError(formatted || "Error al guardar la imagen");
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ import { useSessionStore } from "@core/Store/Sesion.Store";
|
|||||||
import { EVENT_TYPES, useEventHandlerStore } from "@core/Store/EventHandler.Store";
|
import { EVENT_TYPES, useEventHandlerStore } from "@core/Store/EventHandler.Store";
|
||||||
import { useAlert } from "@core/Store/Alert.Store";
|
import { useAlert } from "@core/Store/Alert.Store";
|
||||||
import { IPost } from "@core/Models/Posts.model";
|
import { IPost } from "@core/Models/Posts.model";
|
||||||
import { preprocessQuillHtml, transformQuillContentForDisplay } from "@core/app/helpers/htmlSainitize";
|
import {
|
||||||
|
preprocessQuillHtml,
|
||||||
|
transformQuillContentForDisplay,
|
||||||
|
} from "@core/app/helpers/htmlSainitize";
|
||||||
import { useSearchParams } from "next/navigation";
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
import { ThemeProvider } from "@emotion/react";
|
import { ThemeProvider } from "@emotion/react";
|
||||||
@@ -55,7 +58,7 @@ import DownIcon from "@mui/icons-material/ArrowDownwardRounded";
|
|||||||
import PinIcon from "@mui/icons-material/PushPin";
|
import PinIcon from "@mui/icons-material/PushPin";
|
||||||
import EditIcon from "@mui/icons-material/AutoFixHigh";
|
import EditIcon from "@mui/icons-material/AutoFixHigh";
|
||||||
import turnosXpressTheme from "@core/app/theme/turnosXpress";
|
import turnosXpressTheme from "@core/app/theme/turnosXpress";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useConfirmStore } from "@core/Store/Confirm.Store";
|
import { useConfirmStore } from "@core/Store/Confirm.Store";
|
||||||
import ReviewsCarousel from "@core/app/components/ReviewsCarousel/ReviewsCarousel";
|
import ReviewsCarousel from "@core/app/components/ReviewsCarousel/ReviewsCarousel";
|
||||||
@@ -63,7 +66,6 @@ import OrganizationProfessionals from "@core/app/components/OrganizationProfessi
|
|||||||
import { RatingTargetType } from "@core/Models/Ratings.model";
|
import { RatingTargetType } from "@core/Models/Ratings.model";
|
||||||
import HeaderEditPopup from "./HeaderEditPopup";
|
import HeaderEditPopup from "./HeaderEditPopup";
|
||||||
import { checkOrgAdmin } from "./post.service";
|
import { checkOrgAdmin } from "./post.service";
|
||||||
import { IconButton as MuiIconButton } from "@mui/material";
|
|
||||||
|
|
||||||
enum VIEW {
|
enum VIEW {
|
||||||
POSTS = "posts",
|
POSTS = "posts",
|
||||||
@@ -79,6 +81,7 @@ type UrlData = {
|
|||||||
export default function OrganizationPublicProfile() {
|
export default function OrganizationPublicProfile() {
|
||||||
const data = useParams<UrlData>();
|
const data = useParams<UrlData>();
|
||||||
const oid = data.oid;
|
const oid = data.oid;
|
||||||
|
const router = useRouter();
|
||||||
const OrganizationData = useOrgDataStore();
|
const OrganizationData = useOrgDataStore();
|
||||||
const [position, setPosition] = useState<[number, number]>([0, 0]);
|
const [position, setPosition] = useState<[number, number]>([0, 0]);
|
||||||
const [orgData, setOrgData] = useState<PublicOrganizationView>();
|
const [orgData, setOrgData] = useState<PublicOrganizationView>();
|
||||||
@@ -398,7 +401,8 @@ export default function OrganizationPublicProfile() {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
const newPosts = response.data.filter(
|
const newPosts = response.data.filter(
|
||||||
(newPost) => !prevPosts.some((prevPost) => prevPost._id === newPost._id),
|
(newPost) =>
|
||||||
|
!prevPosts.some((prevPost) => prevPost._id === newPost._id),
|
||||||
);
|
);
|
||||||
|
|
||||||
return [...prevPosts, ...newPosts];
|
return [...prevPosts, ...newPosts];
|
||||||
@@ -568,7 +572,11 @@ export default function OrganizationPublicProfile() {
|
|||||||
gap: "10px",
|
gap: "10px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<WhatsappShareButton title={shareTitle} separator=":: " url={window.location.href}>
|
<WhatsappShareButton
|
||||||
|
title={shareTitle}
|
||||||
|
separator=":: "
|
||||||
|
url={window.location.href}
|
||||||
|
>
|
||||||
<WhatsAppShareIcon size={32} round />
|
<WhatsAppShareIcon size={32} round />
|
||||||
</WhatsappShareButton>
|
</WhatsappShareButton>
|
||||||
<FacebookShareButton title={shareTitle} url={window.location.href}>
|
<FacebookShareButton title={shareTitle} url={window.location.href}>
|
||||||
@@ -603,6 +611,7 @@ export default function OrganizationPublicProfile() {
|
|||||||
onSaved={() => {
|
onSaved={() => {
|
||||||
setShowEditPopup(false);
|
setShowEditPopup(false);
|
||||||
}}
|
}}
|
||||||
|
onRefresh={() => router.refresh()}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{orgData && (
|
{orgData && (
|
||||||
@@ -730,7 +739,9 @@ export default function OrganizationPublicProfile() {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{view === VIEW.SERVICES && (
|
{view === VIEW.SERVICES && (
|
||||||
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
<div
|
||||||
|
style={{ display: "flex", justifyContent: "flex-end" }}
|
||||||
|
>
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
aria-label="Basic button group"
|
aria-label="Basic button group"
|
||||||
@@ -785,7 +796,8 @@ export default function OrganizationPublicProfile() {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
backgroundImage: "url(/no-conversation.webp)",
|
backgroundImage:
|
||||||
|
"url(/no-conversation.webp)",
|
||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
backgroundPosition: "center center",
|
backgroundPosition: "center center",
|
||||||
backgroundSize: "50% auto",
|
backgroundSize: "50% auto",
|
||||||
@@ -800,7 +812,8 @@ export default function OrganizationPublicProfile() {
|
|||||||
<div
|
<div
|
||||||
key={post._id}
|
key={post._id}
|
||||||
style={{
|
style={{
|
||||||
borderBottom: "1px solid var(--gray-light)",
|
borderBottom:
|
||||||
|
"1px solid var(--gray-light)",
|
||||||
paddingTop: "5px",
|
paddingTop: "5px",
|
||||||
paddingBottom: "10px",
|
paddingBottom: "10px",
|
||||||
paddingLeft: "30px",
|
paddingLeft: "30px",
|
||||||
@@ -814,7 +827,11 @@ export default function OrganizationPublicProfile() {
|
|||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ color: "var(--gray-darkest)" }}>
|
<div
|
||||||
|
style={{
|
||||||
|
color: "var(--gray-darkest)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{dayjs(post.createdAt).format(
|
{dayjs(post.createdAt).format(
|
||||||
"DD MMMM YYYY HH:mm",
|
"DD MMMM YYYY HH:mm",
|
||||||
)}
|
)}
|
||||||
@@ -854,22 +871,30 @@ export default function OrganizationPublicProfile() {
|
|||||||
color: "var(--gray-darkest)",
|
color: "var(--gray-darkest)",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ThemeProvider theme={turnosXpressTheme}>
|
<ThemeProvider
|
||||||
|
theme={turnosXpressTheme}
|
||||||
|
>
|
||||||
<MaterialButton
|
<MaterialButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
startIcon={<ClipIcon />}
|
startIcon={<ClipIcon />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
fijarPost(`${post._id}`);
|
fijarPost(
|
||||||
|
`${post._id}`,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{post.fixed ? "Liberar" : "Fijar"}
|
{post.fixed
|
||||||
|
? "Liberar"
|
||||||
|
: "Fijar"}
|
||||||
</MaterialButton>
|
</MaterialButton>
|
||||||
|
|
||||||
{post.fixed && (
|
{post.fixed && (
|
||||||
<>
|
<>
|
||||||
<MaterialButton
|
<MaterialButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
startIcon={<UpIcon />}
|
startIcon={
|
||||||
|
<UpIcon />
|
||||||
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
moverPost(
|
moverPost(
|
||||||
`${post._id}`,
|
`${post._id}`,
|
||||||
@@ -882,7 +907,9 @@ export default function OrganizationPublicProfile() {
|
|||||||
|
|
||||||
<MaterialButton
|
<MaterialButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
startIcon={<DownIcon />}
|
startIcon={
|
||||||
|
<DownIcon />
|
||||||
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
moverPost(
|
moverPost(
|
||||||
`${post._id}`,
|
`${post._id}`,
|
||||||
@@ -898,7 +925,9 @@ export default function OrganizationPublicProfile() {
|
|||||||
<MaterialButton
|
<MaterialButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
editarPost(`${post._id}`);
|
editarPost(
|
||||||
|
`${post._id}`,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<EditIcon />
|
<EditIcon />
|
||||||
@@ -907,7 +936,9 @@ export default function OrganizationPublicProfile() {
|
|||||||
<MaterialButton
|
<MaterialButton
|
||||||
color="inherit"
|
color="inherit"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
eliminarPost(`${post._id}`);
|
eliminarPost(
|
||||||
|
`${post._id}`,
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DeleteIcon />
|
<DeleteIcon />
|
||||||
@@ -932,7 +963,8 @@ export default function OrganizationPublicProfile() {
|
|||||||
style={{
|
style={{
|
||||||
padding: "0px 0px 40px 0px",
|
padding: "0px 0px 40px 0px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: viewMode === "card" ? "row" : "column",
|
flexDirection:
|
||||||
|
viewMode === "card" ? "row" : "column",
|
||||||
justifyContent: "start",
|
justifyContent: "start",
|
||||||
gap: "20px",
|
gap: "20px",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
|
|||||||
Reference in New Issue
Block a user