feat:subscription, fix:isPublish advertise

This commit is contained in:
Rama Priyanto 2025-04-20 12:10:10 +07:00
parent b857e168ee
commit 427b2243bc
10 changed files with 2610 additions and 14 deletions

View File

@ -14,10 +14,31 @@ import Link from "next/link";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Image from "next/image"; import Image from "next/image";
import { error, success } from "@/config/swal";
import { subscription } from "@/service/subscribe";
export default function FooterNew(props: { margin?: boolean }) { export default function FooterNew(props: { margin?: boolean }) {
const t2 = useTranslations("Navbar"); const [emailValue, setEmailValue] = useState("");
const t3 = useTranslations("LandingInformasiPublik");
const doSubscribe = async () => {
const isValidEmail = (email: string): boolean => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
};
if (!isValidEmail(emailValue)) {
error("Email tidak valid");
return false;
}
const res = await subscription({ email: emailValue });
if (res?.error) {
error(res?.message);
return false;
}
success("Sukses");
};
return ( return (
<div <div
@ -160,7 +181,7 @@ export default function FooterNew(props: { margin?: boolean }) {
{" "} {" "}
<Input <Input
label="" label=""
type="email" type="text"
variant="bordered" variant="bordered"
placeholder="Tuliskan Email Anda" placeholder="Tuliskan Email Anda"
className="rounded-none !text-black " className="rounded-none !text-black "
@ -170,13 +191,15 @@ export default function FooterNew(props: { margin?: boolean }) {
mainWrapper: mainWrapper:
"rounded-none h-[37px] bg-white !text-black dark:border-white", "rounded-none h-[37px] bg-white !text-black dark:border-white",
}} }}
// startContent={ value={emailValue}
// <MailIcon className="text-xl text-default-400 pointer-events-none flex-shrink-0" /> onValueChange={setEmailValue}
// }
/> />
<div className="h-[38px] dark:h-[37px] text-white dark:text-black bg-black dark:bg-white flex items-center justify-center w-14 cursor-pointer"> <a
onClick={doSubscribe}
className="h-[38px] dark:h-[37px] text-white dark:text-black bg-black dark:bg-white flex items-center justify-center w-14 cursor-pointer"
>
<SendIcon /> <SendIcon />
</div> </a>
</div> </div>
</div> </div>
<Link href={`/auth`}> <Link href={`/auth`}>

View File

@ -488,6 +488,7 @@ const SidebarMobile: React.FC<SidebarProps> = ({ updateSidebarData }) => {
placement="right" placement="right"
delay={0} delay={0}
closeDelay={0} closeDelay={0}
key={list.name}
> >
<Link key={list.id} href={list.modulePathUrl}> <Link key={list.id} href={list.modulePathUrl}>
<div <div

View File

@ -490,6 +490,7 @@ const Sidebar: React.FC<SidebarProps> = ({ updateSidebarData }) => {
placement="right" placement="right"
delay={0} delay={0}
closeDelay={0} closeDelay={0}
key={list.name}
> >
<Link key={list.id} href={list.modulePathUrl}> <Link key={list.id} href={list.modulePathUrl}>
<div <div

View File

@ -56,7 +56,7 @@ interface TopPages {
} }
interface PostCount { interface PostCount {
id: number; userLevelId: number;
no: number; no: number;
userLevelName: string; userLevelName: string;
totalArticle: number; totalArticle: number;
@ -307,7 +307,7 @@ export default function DashboardContainer() {
<div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto"> <div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto">
{postCount?.map((list) => ( {postCount?.map((list) => (
<div <div
key={list.id} key={list.userLevelId}
className="flex flex-row border-b-1 gap-1 py-1" className="flex flex-row border-b-1 gap-1 py-1"
> >
<div className="w-[5%]">{list?.no}</div> <div className="w-[5%]">{list?.no}</div>

View File

@ -268,10 +268,10 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
return ( return (
<div className="flex flex-row gap-2"> <div className="flex flex-row gap-2">
<Switch <Switch
isSelected={advertise?.isActive} isSelected={advertise?.isPublish}
onValueChange={(e) => handleAdvertise(e, advertise?.id)} onValueChange={(e) => handleAdvertise(e, advertise?.id)}
/> />
{advertise?.isActive ? "Ya" : "Tidak"} {advertise?.isPublish ? "Ya" : "Tidak"}
</div> </div>
); );
case "actions": case "actions":

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2455
public/workbox-e43f5367.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -53,6 +53,7 @@ export async function editAdvertise(data: any) {
export async function editAdvertiseIsActive(data: any) { export async function editAdvertiseIsActive(data: any) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
Authorization: `Bearer ${token}`,
}; };
const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`; const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`;
return await httpPut(pathUrl, headers); return await httpPut(pathUrl, headers);

17
service/subscribe.ts Normal file
View File

@ -0,0 +1,17 @@
import {
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token");
export async function subscription(data: any) {
const headers = {
"content-type": "application/json",
};
const pathUrl = `/subscription`;
return await httpPost(pathUrl, headers, data);
}