feat:subscription, fix:isPublish advertise
This commit is contained in:
parent
b857e168ee
commit
427b2243bc
|
|
@ -14,10 +14,31 @@ import Link from "next/link";
|
|||
import { useTranslations } from "next-intl";
|
||||
import { useEffect, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import { error, success } from "@/config/swal";
|
||||
import { subscription } from "@/service/subscribe";
|
||||
|
||||
export default function FooterNew(props: { margin?: boolean }) {
|
||||
const t2 = useTranslations("Navbar");
|
||||
const t3 = useTranslations("LandingInformasiPublik");
|
||||
const [emailValue, setEmailValue] = useState("");
|
||||
|
||||
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 (
|
||||
<div
|
||||
|
|
@ -160,7 +181,7 @@ export default function FooterNew(props: { margin?: boolean }) {
|
|||
{" "}
|
||||
<Input
|
||||
label=""
|
||||
type="email"
|
||||
type="text"
|
||||
variant="bordered"
|
||||
placeholder="Tuliskan Email Anda"
|
||||
className="rounded-none !text-black "
|
||||
|
|
@ -170,13 +191,15 @@ export default function FooterNew(props: { margin?: boolean }) {
|
|||
mainWrapper:
|
||||
"rounded-none h-[37px] bg-white !text-black dark:border-white",
|
||||
}}
|
||||
// startContent={
|
||||
// <MailIcon className="text-xl text-default-400 pointer-events-none flex-shrink-0" />
|
||||
// }
|
||||
value={emailValue}
|
||||
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 />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<Link href={`/auth`}>
|
||||
|
|
|
|||
|
|
@ -488,6 +488,7 @@ const SidebarMobile: React.FC<SidebarProps> = ({ updateSidebarData }) => {
|
|||
placement="right"
|
||||
delay={0}
|
||||
closeDelay={0}
|
||||
key={list.name}
|
||||
>
|
||||
<Link key={list.id} href={list.modulePathUrl}>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -490,6 +490,7 @@ const Sidebar: React.FC<SidebarProps> = ({ updateSidebarData }) => {
|
|||
placement="right"
|
||||
delay={0}
|
||||
closeDelay={0}
|
||||
key={list.name}
|
||||
>
|
||||
<Link key={list.id} href={list.modulePathUrl}>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ interface TopPages {
|
|||
}
|
||||
|
||||
interface PostCount {
|
||||
id: number;
|
||||
userLevelId: number;
|
||||
no: number;
|
||||
userLevelName: string;
|
||||
totalArticle: number;
|
||||
|
|
@ -307,7 +307,7 @@ export default function DashboardContainer() {
|
|||
<div className="flex flex-col gap-1 lg:h-[500px] overflow-y-auto">
|
||||
{postCount?.map((list) => (
|
||||
<div
|
||||
key={list.id}
|
||||
key={list.userLevelId}
|
||||
className="flex flex-row border-b-1 gap-1 py-1"
|
||||
>
|
||||
<div className="w-[5%]">{list?.no}</div>
|
||||
|
|
|
|||
|
|
@ -268,10 +268,10 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
|
|||
return (
|
||||
<div className="flex flex-row gap-2">
|
||||
<Switch
|
||||
isSelected={advertise?.isActive}
|
||||
isSelected={advertise?.isPublish}
|
||||
onValueChange={(e) => handleAdvertise(e, advertise?.id)}
|
||||
/>
|
||||
{advertise?.isActive ? "Ya" : "Tidak"}
|
||||
{advertise?.isPublish ? "Ya" : "Tidak"}
|
||||
</div>
|
||||
);
|
||||
case "actions":
|
||||
|
|
|
|||
101
public/sw.js
101
public/sw.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
|
@ -53,6 +53,7 @@ export async function editAdvertise(data: any) {
|
|||
export async function editAdvertiseIsActive(data: any) {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
};
|
||||
const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`;
|
||||
return await httpPut(pathUrl, headers);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Reference in New Issue