feat: implement form validation for empty fields across multiple admin pages
- Added validation to disable submit buttons when required fields are empty - Implemented consistent validation patterns across various admin pages - Applied validation to create and edit forms for berita, gallery, layanan, penghargaan, pengumuman, potensi, profil-desa, and ppid sections - Used helper functions to check for empty HTML content in editor fields - Ensured submit buttons are disabled until all required fields are filled Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -33,6 +33,13 @@ function EditKategoriBerita() {
|
|||||||
name: '',
|
name: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadKategori = async () => {
|
const loadKategori = async () => {
|
||||||
const id = params?.id as string;
|
const id = params?.id as string;
|
||||||
@@ -72,6 +79,11 @@ function EditKategoriBerita() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Nama kategori berita wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// update global state hanya saat submit
|
// update global state hanya saat submit
|
||||||
@@ -143,8 +155,11 @@ function EditKategoriBerita() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ function CreateKategoriBerita() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
createState.create.form.name?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
createState.create.form = {
|
createState.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -29,6 +36,11 @@ function CreateKategoriBerita() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!createState.create.form.name?.trim()) {
|
||||||
|
toast.error('Nama kategori berita wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
try {
|
try {
|
||||||
await createState.create.create();
|
await createState.create.create();
|
||||||
@@ -93,8 +105,11 @@ function CreateKategoriBerita() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -48,6 +48,24 @@ function EditBerita() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.judul?.trim() !== '' &&
|
||||||
|
formData.kategoriBeritaId !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
(file !== null || originalData.imageId !== '') && // Either a new file is selected or an existing image exists
|
||||||
|
!isHtmlEmpty(formData.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
judul: "",
|
judul: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -103,6 +121,31 @@ function EditBerita() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.judul?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.kategoriBeritaId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file && !originalData.imageId) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.content)) {
|
||||||
|
toast.error('Konten wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Update global state hanya sekali di sini
|
// Update global state hanya sekali di sini
|
||||||
@@ -326,8 +369,11 @@ function EditBerita() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -32,6 +32,24 @@ export default function CreateBerita() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
beritaState.berita.create.form.judul?.trim() !== '' &&
|
||||||
|
beritaState.berita.create.form.kategoriBeritaId !== '' &&
|
||||||
|
!isHtmlEmpty(beritaState.berita.create.form.deskripsi) &&
|
||||||
|
file !== null &&
|
||||||
|
!isHtmlEmpty(beritaState.berita.create.form.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
beritaState.kategoriBerita.findMany.load();
|
beritaState.kategoriBerita.findMany.load();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -49,6 +67,31 @@ export default function CreateBerita() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!beritaState.berita.create.form.judul?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!beritaState.berita.create.form.kategoriBeritaId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(beritaState.berita.create.form.deskripsi)) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(beritaState.berita.create.form.content)) {
|
||||||
|
toast.error('Konten wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -250,8 +293,11 @@ export default function CreateBerita() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ function EditFoto() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
(file !== null || originalData.imagesId !== '') // Either a new file is selected or an existing image exists
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -94,6 +110,21 @@ function EditFoto() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file && !originalData.imagesId) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Update global state hanya sekali di sini
|
// Update global state hanya sekali di sini
|
||||||
@@ -285,8 +316,11 @@ function EditFoto() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -30,6 +30,22 @@ function CreateFoto() {
|
|||||||
const [previewImage, setPreviewImage] = useState<string | null>(null);
|
const [previewImage, setPreviewImage] = useState<string | null>(null);
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
FotoState.create.form.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(FotoState.create.form.deskripsi) &&
|
||||||
|
file !== null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
FotoState.create.form = {
|
FotoState.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -41,6 +57,21 @@ function CreateFoto() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!FotoState.create.form.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(FotoState.create.form.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -210,8 +241,11 @@ function CreateFoto() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -28,6 +28,24 @@ function EditVideo() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
const embedLink = convertYoutubeUrlToEmbed(formData.linkVideo);
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
formData.linkVideo?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
embedLink !== null // Make sure the embed link is valid
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -86,6 +104,21 @@ function EditVideo() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.linkVideo?.trim()) {
|
||||||
|
toast.error('Link YouTube wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
const converted = convertYoutubeUrlToEmbed(formData.linkVideo);
|
const converted = convertYoutubeUrlToEmbed(formData.linkVideo);
|
||||||
@@ -218,8 +251,11 @@ function EditVideo() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -28,6 +28,23 @@ function CreateVideo() {
|
|||||||
const embedLink = convertYoutubeUrlToEmbed(link);
|
const embedLink = convertYoutubeUrlToEmbed(link);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
videoState.create.form.name?.trim() !== '' &&
|
||||||
|
link.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(videoState.create.form.deskripsi) &&
|
||||||
|
embedLink !== null // Make sure the embed link is valid
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
videoState.create.form = {
|
videoState.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -38,6 +55,26 @@ function CreateVideo() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!videoState.create.form.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!link.trim()) {
|
||||||
|
toast.error('Link YouTube wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(videoState.create.form.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!embedLink) {
|
||||||
|
toast.error('Link YouTube tidak valid. Pastikan formatnya benar.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!embedLink) {
|
if (!embedLink) {
|
||||||
@@ -168,8 +205,11 @@ function CreateVideo() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -35,6 +35,21 @@ function EditPelayananPendudukNonPermanent() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
deskripsi: '',
|
deskripsi: '',
|
||||||
@@ -86,6 +101,16 @@ function EditPelayananPendudukNonPermanent() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!statePendudukNonPermanent.findById.data) return;
|
if (!statePendudukNonPermanent.findById.data) return;
|
||||||
@@ -173,8 +198,11 @@ function EditPelayananPendudukNonPermanent() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -36,6 +36,22 @@ function EditPelayananPerizinanBerusaha() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
@@ -102,6 +118,21 @@ function EditPelayananPerizinanBerusaha() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.link?.trim()) {
|
||||||
|
toast.error('Link wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await state.update.update(formData);
|
await state.update.update(formData);
|
||||||
@@ -192,8 +223,11 @@ function EditPelayananPerizinanBerusaha() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -149,6 +149,22 @@ function EditSuratKeterangan() {
|
|||||||
const [previewImage2, setPreviewImage2] = useState<string | null>(null);
|
const [previewImage2, setPreviewImage2] = useState<string | null>(null);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
(previewImage !== null || originalData.imageId !== '') // Either a new file is selected or an existing image exists
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 🧭 Load Initial Data
|
// 🧭 Load Initial Data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSurat = async () => {
|
const loadSurat = async () => {
|
||||||
@@ -209,6 +225,21 @@ function EditSuratKeterangan() {
|
|||||||
|
|
||||||
// 💾 Submit Handler
|
// 💾 Submit Handler
|
||||||
const handleSubmit = useCallback(async () => {
|
const handleSubmit = useCallback(async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Nama surat keterangan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Konten wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!previewImage && !originalData.imageId) {
|
||||||
|
toast.error('Gambar konten pelayanan wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
@@ -251,7 +282,7 @@ function EditSuratKeterangan() {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsSubmitting(false);
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
}, [formData, file, file2, router]);
|
}, [formData, file, file2, router, previewImage, originalData.imageId]);
|
||||||
|
|
||||||
// 📝 Form Field Handlers
|
// 📝 Form Field Handlers
|
||||||
const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
@@ -324,10 +355,10 @@ function EditSuratKeterangan() {
|
|||||||
|
|
||||||
{/* Action Buttons */}
|
{/* Action Buttons */}
|
||||||
<Group justify="right">
|
<Group justify="right">
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
color="gray"
|
color="gray"
|
||||||
radius="md"
|
radius="md"
|
||||||
onClick={handleResetForm}
|
onClick={handleResetForm}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
@@ -336,9 +367,11 @@ function EditSuratKeterangan() {
|
|||||||
<Button
|
<Button
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
disabled={isSubmitting}
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79,172,254,0.4)',
|
boxShadow: '0 4px 15px rgba(79,172,254,0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -31,6 +31,22 @@ function CreateSuratKeterangan() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
stateSurat.create.form.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(stateSurat.create.form.deskripsi) &&
|
||||||
|
previewImage !== null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
stateSurat.create.form = {
|
stateSurat.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -43,8 +59,19 @@ function CreateSuratKeterangan() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!stateSurat.create.form.name?.trim()) {
|
||||||
|
toast.error('Nama surat keterangan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(stateSurat.create.form.deskripsi)) {
|
||||||
|
toast.error('Konten wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!previewImage) {
|
if (!previewImage) {
|
||||||
return toast.warn('Pilih file gambar utama terlebih dahulu');
|
toast.error('Gambar konten pelayanan wajib dipilih');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -284,8 +311,11 @@ function CreateSuratKeterangan() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ function EditPelayananTelunjukSakti() {
|
|||||||
const params = useParams();
|
const params = useParams();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
formData.deskripsi?.trim() !== '' &&
|
||||||
|
formData.link?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
deskripsi: '',
|
deskripsi: '',
|
||||||
@@ -84,6 +93,21 @@ function EditPelayananTelunjukSakti() {
|
|||||||
|
|
||||||
// Submit: update global state hanya saat simpan
|
// Submit: update global state hanya saat simpan
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Nama pelayanan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.deskripsi?.trim()) {
|
||||||
|
toast.error('Judul link wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.link?.trim()) {
|
||||||
|
toast.error('Link wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
stateTelunjukDesa.edit.form = {
|
stateTelunjukDesa.edit.form = {
|
||||||
@@ -165,8 +189,11 @@ function EditPelayananTelunjukSakti() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -23,6 +23,15 @@ function CreatePelayananTelunjukDesa() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
stateTelunjukDesa.create.form.name?.trim() !== '' &&
|
||||||
|
stateTelunjukDesa.create.form.deskripsi?.trim() !== '' &&
|
||||||
|
stateTelunjukDesa.create.form.link?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
stateTelunjukDesa.create.form = {
|
stateTelunjukDesa.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -32,6 +41,21 @@ function CreatePelayananTelunjukDesa() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!stateTelunjukDesa.create.form.name?.trim()) {
|
||||||
|
toast.error('Nama pelayanan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stateTelunjukDesa.create.form.deskripsi?.trim()) {
|
||||||
|
toast.error('Judul link wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stateTelunjukDesa.create.form.link?.trim()) {
|
||||||
|
toast.error('Link wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await stateTelunjukDesa.create.create();
|
await stateTelunjukDesa.create.create();
|
||||||
@@ -118,8 +142,11 @@ function CreatePelayananTelunjukDesa() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -33,6 +33,23 @@ function EditPenghargaan() {
|
|||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
formData.juara?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
(file !== null || originalData.imageId !== '') // Either a new file is selected or an existing image exists
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
juara: "",
|
juara: "",
|
||||||
@@ -100,6 +117,26 @@ function EditPenghargaan() {
|
|||||||
|
|
||||||
// Submit
|
// Submit
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Nama penghargaan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.juara?.trim()) {
|
||||||
|
toast.error('Juara wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file && !originalData.imageId) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Sync ke global state saat submit
|
// Sync ke global state saat submit
|
||||||
@@ -281,8 +318,11 @@ function EditPenghargaan() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -30,6 +30,23 @@ function CreatePenghargaan() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
statePenghargaan.create.form.name?.trim() !== '' &&
|
||||||
|
statePenghargaan.create.form.juara?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(statePenghargaan.create.form.deskripsi) &&
|
||||||
|
file !== null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
statePenghargaan.create.form = {
|
statePenghargaan.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -42,6 +59,26 @@ function CreatePenghargaan() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!statePenghargaan.create.form.name?.trim()) {
|
||||||
|
toast.error('Nama penghargaan wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!statePenghargaan.create.form.juara?.trim()) {
|
||||||
|
toast.error('Juara wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(statePenghargaan.create.form.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@@ -201,8 +238,11 @@ function CreatePenghargaan() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -27,6 +27,13 @@ function EditKategoriPengumuman() {
|
|||||||
const [formData, setFormData] = useState({ name: '' });
|
const [formData, setFormData] = useState({ name: '' });
|
||||||
const [originalData, setOriginalData] = useState({ name: '' });
|
const [originalData, setOriginalData] = useState({ name: '' });
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Load data awal sekali aja
|
// Load data awal sekali aja
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadKategori = async () => {
|
const loadKategori = async () => {
|
||||||
@@ -56,6 +63,11 @@ function EditKategoriPengumuman() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Nama kategori pengumuman wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Update global state hanya di sini
|
// Update global state hanya di sini
|
||||||
@@ -134,8 +146,11 @@ function EditKategoriPengumuman() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ function CreateKategoriPengumuman() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
createState.create.form.name?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
createState.create.form = {
|
createState.create.form = {
|
||||||
name: '',
|
name: '',
|
||||||
@@ -29,6 +36,11 @@ function CreateKategoriPengumuman() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!createState.create.form.name?.trim()) {
|
||||||
|
toast.error('Nama kategori pengumuman wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createState.create.create();
|
await createState.create.create();
|
||||||
resetForm();
|
resetForm();
|
||||||
@@ -92,8 +104,11 @@ function CreateKategoriPengumuman() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -36,6 +36,23 @@ function EditPengumuman() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.judul?.trim() !== '' &&
|
||||||
|
formData.deskripsi?.trim() !== '' &&
|
||||||
|
formData.categoryPengumumanId !== '' &&
|
||||||
|
!isHtmlEmpty(formData.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
judul: "",
|
judul: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -81,6 +98,26 @@ function EditPengumuman() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.judul?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.deskripsi?.trim()) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.categoryPengumumanId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.content)) {
|
||||||
|
toast.error('Konten lengkap wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// update global state hanya sekali pas submit
|
// update global state hanya sekali pas submit
|
||||||
@@ -197,8 +234,11 @@ function EditPengumuman() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -27,11 +27,48 @@ function CreatePengumuman() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
pengumumanState.pengumuman.create.form.judul?.trim() !== '' &&
|
||||||
|
pengumumanState.pengumuman.create.form.categoryPengumumanId !== '' &&
|
||||||
|
pengumumanState.pengumuman.create.form.deskripsi?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(pengumumanState.pengumuman.create.form.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
pengumumanState.category.findMany.load();
|
pengumumanState.category.findMany.load();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!pengumumanState.pengumuman.create.form.judul?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pengumumanState.pengumuman.create.form.categoryPengumumanId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!pengumumanState.pengumuman.create.form.deskripsi?.trim()) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(pengumumanState.pengumuman.create.form.content)) {
|
||||||
|
toast.error('Konten lengkap wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await pengumumanState.pengumuman.create.create();
|
await pengumumanState.pengumuman.create.create();
|
||||||
@@ -150,8 +187,11 @@ function CreatePengumuman() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -33,6 +33,13 @@ function EditKategoriPotensi() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.nama?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Load data dari backend -> isi ke formData lokal
|
// Load data dari backend -> isi ke formData lokal
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadKategori = async () => {
|
const loadKategori = async () => {
|
||||||
@@ -73,6 +80,11 @@ function EditKategoriPotensi() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.nama?.trim()) {
|
||||||
|
toast.error('Nama kategori potensi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
// Update global state hanya pas submit
|
// Update global state hanya pas submit
|
||||||
@@ -141,8 +153,11 @@ function EditKategoriPotensi() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ function CreateKategoriPotensi() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
createState.create.form.nama?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
createState.create.form = {
|
createState.create.form = {
|
||||||
nama: '',
|
nama: '',
|
||||||
@@ -28,6 +35,11 @@ function CreateKategoriPotensi() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!createState.create.form.nama?.trim()) {
|
||||||
|
alert('Nama kategori potensi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
await createState.create.create();
|
await createState.create.create();
|
||||||
@@ -91,8 +103,11 @@ function CreateKategoriPotensi() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -42,6 +42,24 @@ function EditPotensi() {
|
|||||||
});
|
});
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi) &&
|
||||||
|
formData.kategoriId !== '' &&
|
||||||
|
(file !== null || originalData.imageId !== '') && // Either a new file is selected or an existing image exists
|
||||||
|
!isHtmlEmpty(formData.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -109,6 +127,31 @@ function EditPotensi() {
|
|||||||
|
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!formData.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!formData.kategoriId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file && !originalData.imageId) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.content)) {
|
||||||
|
toast.error('Konten lengkap wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
let imageId = formData.imageId;
|
let imageId = formData.imageId;
|
||||||
@@ -341,8 +384,11 @@ function EditPotensi() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -32,11 +32,54 @@ function CreatePotensi() {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
potensiState.create.form.name?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(potensiState.create.form.deskripsi) &&
|
||||||
|
potensiState.create.form.kategoriId !== '' &&
|
||||||
|
file !== null &&
|
||||||
|
!isHtmlEmpty(potensiState.create.form.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
potensiDesaState.kategoriPotensi.findMany.load();
|
potensiDesaState.kategoriPotensi.findMany.load();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
|
if (!potensiState.create.form.name?.trim()) {
|
||||||
|
toast.error('Judul wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(potensiState.create.form.deskripsi)) {
|
||||||
|
toast.error('Deskripsi singkat wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!potensiState.create.form.kategoriId) {
|
||||||
|
toast.error('Kategori wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
toast.error('Gambar wajib dipilih');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(potensiState.create.form.content)) {
|
||||||
|
toast.error('Konten lengkap wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
if (!file) return toast.warn('Pilih file gambar terlebih dahulu');
|
if (!file) return toast.warn('Pilih file gambar terlebih dahulu');
|
||||||
@@ -266,8 +309,11 @@ function CreatePotensi() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -83,6 +83,21 @@ function Page() {
|
|||||||
};
|
};
|
||||||
}, [params?.id, router]);
|
}, [params?.id, router]);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.judul?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 🔁 Reset form
|
// 🔁 Reset form
|
||||||
const handleResetForm = () => {
|
const handleResetForm = () => {
|
||||||
setFormData(originalData);
|
setFormData(originalData);
|
||||||
@@ -95,6 +110,11 @@ function Page() {
|
|||||||
toast.error('Judul wajib diisi');
|
toast.error('Judul wajib diisi');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
try {
|
try {
|
||||||
@@ -224,14 +244,16 @@ function Page() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
loading={isSubmitting}
|
|
||||||
>
|
>
|
||||||
Simpan
|
{isSubmitting ? <Loader size="sm" color="white" /> : 'Simpan'}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -34,6 +34,21 @@ function Page() {
|
|||||||
images: [] as Array<{ label: string; imageId: string }>
|
images: [] as Array<{ label: string; imageId: string }>
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.judul?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Load data
|
// Load data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
@@ -122,6 +137,12 @@ function Page() {
|
|||||||
toast.error("Judul wajib diisi");
|
toast.error("Judul wajib diisi");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error("Deskripsi wajib diisi");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
const uploadedImages = [];
|
const uploadedImages = [];
|
||||||
@@ -315,8 +336,11 @@ function Page() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -99,6 +99,21 @@ function Page() {
|
|||||||
toast.info('Form dikembalikan ke data awal');
|
toast.info('Form dikembalikan ke data awal');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.judul?.trim() !== '' &&
|
||||||
|
!isHtmlEmpty(formData.deskripsi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 💾 Submit Handler
|
// 💾 Submit Handler
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// Validation
|
// Validation
|
||||||
@@ -106,6 +121,11 @@ function Page() {
|
|||||||
toast.error('Judul wajib diisi');
|
toast.error('Judul wajib diisi');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.deskripsi)) {
|
||||||
|
toast.error('Deskripsi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
|
|
||||||
@@ -260,8 +280,11 @@ function Page() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -81,6 +81,21 @@ function Page() {
|
|||||||
};
|
};
|
||||||
}, [params?.id, router]);
|
}, [params?.id, router]);
|
||||||
|
|
||||||
|
// Helper function to check if HTML content is empty
|
||||||
|
const isHtmlEmpty = (html: string) => {
|
||||||
|
// Remove all HTML tags and check if there's any text content
|
||||||
|
const textContent = html.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return textContent === '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
!isHtmlEmpty(formData.visi) &&
|
||||||
|
!isHtmlEmpty(formData.misi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 🔄 Reset Form
|
// 🔄 Reset Form
|
||||||
const handleResetForm = () => {
|
const handleResetForm = () => {
|
||||||
setFormData(originalData);
|
setFormData(originalData);
|
||||||
@@ -89,11 +104,16 @@ function Page() {
|
|||||||
|
|
||||||
// 💾 Submit
|
// 💾 Submit
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!formData.visi.trim()) {
|
if (isHtmlEmpty(formData.visi)) {
|
||||||
toast.error('Visi wajib diisi');
|
toast.error('Visi wajib diisi');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHtmlEmpty(formData.misi)) {
|
||||||
|
toast.error('Misi wajib diisi');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsSubmitting(true);
|
setIsSubmitting(true);
|
||||||
try {
|
try {
|
||||||
const originalState = stateProfileDesa.visiMisiDesa;
|
const originalState = stateProfileDesa.visiMisiDesa;
|
||||||
@@ -227,14 +247,16 @@ function Page() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
loading={isSubmitting}
|
|
||||||
>
|
>
|
||||||
Simpan
|
{isSubmitting ? <Loader size="sm" color="white" /> : 'Simpan'}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ function EditDaftarInformasiPublik() {
|
|||||||
tanggal: '',
|
tanggal: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.jenisInformasi?.trim() !== '' &&
|
||||||
|
formData.deskripsi?.trim() !== '' &&
|
||||||
|
formData.tanggal?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const formatDateForInput = (dateString: string) => {
|
const formatDateForInput = (dateString: string) => {
|
||||||
if (!dateString) return '';
|
if (!dateString) return '';
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
@@ -128,10 +137,13 @@ function EditDaftarInformasiPublik() {
|
|||||||
<Group justify="right" mt="md">
|
<Group justify="right" mt="md">
|
||||||
<Button
|
<Button
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
|
disabled={!isFormValid()}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid()
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -11,6 +11,15 @@ export default function CreateDaftarInformasi() {
|
|||||||
const daftarInformasi = useProxy(daftarInformasiPublik);
|
const daftarInformasi = useProxy(daftarInformasiPublik);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
daftarInformasi.create.form.jenisInformasi?.trim() !== '' &&
|
||||||
|
daftarInformasi.create.form.deskripsi?.trim() !== '' &&
|
||||||
|
daftarInformasi.create.form.tanggal?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
daftarInformasi.create.form = {
|
daftarInformasi.create.form = {
|
||||||
jenisInformasi: "",
|
jenisInformasi: "",
|
||||||
@@ -106,10 +115,13 @@ export default function CreateDaftarInformasi() {
|
|||||||
<Button
|
<Button
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
loading={daftarInformasi.create.loading}
|
loading={daftarInformasi.create.loading}
|
||||||
|
disabled={!isFormValid() || daftarInformasi.create.loading}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || daftarInformasi.create.loading
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -27,6 +27,21 @@ function EditDasarHukum() {
|
|||||||
content: '',
|
content: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Helper function to check if rich text content is empty
|
||||||
|
const isRichTextEmpty = (content: string) => {
|
||||||
|
// Remove HTML tags and check if the resulting text is empty
|
||||||
|
const plainText = content.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return plainText === '' || content.trim() === '<p></p>' || content.trim() === '<p><br></p>';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
!isRichTextEmpty(formData.judul) &&
|
||||||
|
!isRichTextEmpty(formData.content)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Load data awal sekali
|
// Load data awal sekali
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (!dasarHukumState.findById.data) {
|
if (!dasarHukumState.findById.data) {
|
||||||
@@ -137,8 +152,11 @@ function EditDasarHukum() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -57,6 +57,17 @@ function EditResponden() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.name?.trim() !== '' &&
|
||||||
|
formData.tanggal?.trim() !== '' &&
|
||||||
|
formData.jenisKelaminId?.trim() !== '' &&
|
||||||
|
formData.ratingId?.trim() !== '' &&
|
||||||
|
formData.kelompokUmurId?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// 🔹 Load data pilihan select
|
// 🔹 Load data pilihan select
|
||||||
const loadSelectOptions = useCallback(() => {
|
const loadSelectOptions = useCallback(() => {
|
||||||
indeksKepuasanState.jenisKelaminResponden.findMany.load();
|
indeksKepuasanState.jenisKelaminResponden.findMany.load();
|
||||||
@@ -231,8 +242,11 @@ function EditResponden() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -16,6 +16,17 @@ function RespondenCreate() {
|
|||||||
const [donutData, setDonutData] = useState<any[]>([]);
|
const [donutData, setDonutData] = useState<any[]>([]);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
stategrafikBerdasarkanResponden.create.form.name?.trim() !== '' &&
|
||||||
|
stategrafikBerdasarkanResponden.create.form.tanggal?.trim() !== '' &&
|
||||||
|
stategrafikBerdasarkanResponden.create.form.jenisKelaminId?.trim() !== '' &&
|
||||||
|
stategrafikBerdasarkanResponden.create.form.ratingId?.trim() !== '' &&
|
||||||
|
stategrafikBerdasarkanResponden.create.form.kelompokUmurId?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
stategrafikBerdasarkanResponden.create.form = {
|
stategrafikBerdasarkanResponden.create.form = {
|
||||||
...stategrafikBerdasarkanResponden.create.form,
|
...stategrafikBerdasarkanResponden.create.form,
|
||||||
@@ -151,8 +162,11 @@ function RespondenCreate() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ export default function EditPegawaiPPID() {
|
|||||||
const [previewImage, setPreviewImage] = useState<string | null>(null);
|
const [previewImage, setPreviewImage] = useState<string | null>(null);
|
||||||
const [file, setFile] = useState<File | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
|
||||||
|
// Helper function to validate email format
|
||||||
|
const isValidEmail = (email: string) => {
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
return emailRegex.test(email);
|
||||||
|
};
|
||||||
|
|
||||||
// Format date for <input type="date">
|
// Format date for <input type="date">
|
||||||
const formatDateForInput = (dateString: string) => {
|
const formatDateForInput = (dateString: string) => {
|
||||||
if (!dateString) return '';
|
if (!dateString) return '';
|
||||||
@@ -63,6 +69,20 @@ export default function EditPegawaiPPID() {
|
|||||||
return date.toISOString().split('T')[0];
|
return date.toISOString().split('T')[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.namaLengkap?.trim() !== '' &&
|
||||||
|
formData.gelarAkademik?.trim() !== '' &&
|
||||||
|
formData.posisiId !== '' &&
|
||||||
|
formData.tanggalMasuk !== '' &&
|
||||||
|
formData.email !== '' &&
|
||||||
|
isValidEmail(formData.email) &&
|
||||||
|
formData.telepon !== '' &&
|
||||||
|
formData.alamat !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadPegawai = async () => {
|
const loadPegawai = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -347,8 +367,11 @@ export default function EditPegawaiPPID() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -24,6 +24,27 @@ function CreatePegawaiPPID() {
|
|||||||
resetForm();
|
resetForm();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Helper function to validate email format
|
||||||
|
const isValidEmail = (email: string) => {
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
return emailRegex.test(email);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
stateOrganisasi.create.form.namaLengkap?.trim() !== '' &&
|
||||||
|
stateOrganisasi.create.form.gelarAkademik?.trim() !== '' &&
|
||||||
|
stateOrganisasi.create.form.posisiId !== '' &&
|
||||||
|
stateOrganisasi.create.form.tanggalMasuk !== '' &&
|
||||||
|
stateOrganisasi.create.form.email !== '' &&
|
||||||
|
isValidEmail(stateOrganisasi.create.form.email) &&
|
||||||
|
stateOrganisasi.create.form.telepon !== '' &&
|
||||||
|
stateOrganisasi.create.form.alamat !== '' &&
|
||||||
|
file !== null
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
stateOrganisasi.create.form = {
|
stateOrganisasi.create.form = {
|
||||||
namaLengkap: "",
|
namaLengkap: "",
|
||||||
@@ -78,7 +99,7 @@ function CreatePegawaiPPID() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box px={{ base: 0, md: 'lg' }} py="xs">
|
<Box px={{ base: 0, md: 'lg' }} py="xs">
|
||||||
<Group mb="md">
|
<Group mb="md">
|
||||||
<Button variant="subtle" onClick={() => router.back()} p="xs" radius="md">
|
<Button variant="subtle" onClick={() => router.back()} p="xs" radius="md">
|
||||||
<IconArrowBack color={colors['blue-button']} size={24} />
|
<IconArrowBack color={colors['blue-button']} size={24} />
|
||||||
@@ -99,15 +120,16 @@ function CreatePegawaiPPID() {
|
|||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
label="Nama Lengkap"
|
label="Nama Lengkap"
|
||||||
placeholder="Masukkan nama lengkap"
|
placeholder="Masukkan nama lengkap"
|
||||||
value={stateOrganisasi.create.form.namaLengkap}
|
value={stateOrganisasi.create.form.namaLengkap}
|
||||||
onChange={(e) => (stateOrganisasi.create.form.namaLengkap = e.currentTarget.value)}
|
onChange={(e) => (stateOrganisasi.create.form.namaLengkap = e.currentTarget.value)}
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
label="Gelar Akademik"
|
label="Gelar Akademik"
|
||||||
placeholder="Contoh: S.Kom"
|
placeholder="Contoh: S.Kom"
|
||||||
value={stateOrganisasi.create.form.gelarAkademik}
|
value={stateOrganisasi.create.form.gelarAkademik}
|
||||||
@@ -191,6 +213,7 @@ function CreatePegawaiPPID() {
|
|||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
label="Tanggal Masuk"
|
label="Tanggal Masuk"
|
||||||
type="date"
|
type="date"
|
||||||
placeholder="Contoh: 2022-01-01"
|
placeholder="Contoh: 2022-01-01"
|
||||||
@@ -201,6 +224,7 @@ function CreatePegawaiPPID() {
|
|||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
label="Email"
|
label="Email"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="Contoh: email@example.com"
|
placeholder="Contoh: email@example.com"
|
||||||
@@ -211,6 +235,7 @@ function CreatePegawaiPPID() {
|
|||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
type='number'
|
type='number'
|
||||||
label="Nomor Telepon"
|
label="Nomor Telepon"
|
||||||
placeholder="Contoh: 08123456789"
|
placeholder="Contoh: 08123456789"
|
||||||
@@ -221,6 +246,7 @@ function CreatePegawaiPPID() {
|
|||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
required
|
||||||
label="Alamat"
|
label="Alamat"
|
||||||
placeholder="Contoh: Jl. Contoh No. 1"
|
placeholder="Contoh: Jl. Contoh No. 1"
|
||||||
value={stateOrganisasi.create.form.alamat}
|
value={stateOrganisasi.create.form.alamat}
|
||||||
@@ -229,35 +255,8 @@ function CreatePegawaiPPID() {
|
|||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<Text fw="bold" fz="sm" mb={6}>
|
|
||||||
Posisi
|
|
||||||
</Text>
|
|
||||||
<Select
|
<Select
|
||||||
label="Kategori"
|
label="Posisi"
|
||||||
placeholder="Pilih kategori"
|
|
||||||
data={stateStrukturPPID.posisiOrganisasi.findManyAll.data?.map((item) => ({
|
|
||||||
label: item.nama,
|
|
||||||
value: item.id,
|
|
||||||
})) || []}
|
|
||||||
value={stateOrganisasi.create.form.posisiId || null}
|
|
||||||
onChange={(val: string | null) => {
|
|
||||||
if (val) {
|
|
||||||
const selected = stateStrukturPPID.posisiOrganisasi.findManyAll.data?.find(
|
|
||||||
(item) => item.id === val
|
|
||||||
);
|
|
||||||
if (selected) {
|
|
||||||
stateOrganisasi.create.form.posisiId = selected.id;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
stateOrganisasi.create.form.posisiId = '';
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
searchable
|
|
||||||
clearable
|
|
||||||
nothingFoundMessage="Tidak ditemukan"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
{/* <Select
|
|
||||||
placeholder="Pilih posisi"
|
placeholder="Pilih posisi"
|
||||||
data={stateStrukturPPID.posisiOrganisasi.findManyAll.data?.map(p => ({
|
data={stateStrukturPPID.posisiOrganisasi.findManyAll.data?.map(p => ({
|
||||||
value: p.id,
|
value: p.id,
|
||||||
@@ -269,10 +268,10 @@ function CreatePegawaiPPID() {
|
|||||||
}}
|
}}
|
||||||
searchable
|
searchable
|
||||||
clearable
|
clearable
|
||||||
/> */}
|
required
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|
||||||
{/* ======= Tombol Aksi ======= */}
|
{/* ======= Tombol Aksi ======= */}
|
||||||
<Group justify="right">
|
<Group justify="right">
|
||||||
{/* Tombol Batal */}
|
{/* Tombol Batal */}
|
||||||
@@ -291,8 +290,11 @@ function CreatePegawaiPPID() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -26,6 +26,15 @@ function EditPosisiOrganisasiPPID() {
|
|||||||
|
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
formData.nama?.trim() !== '' &&
|
||||||
|
formData.hierarki?.toString().trim() !== '' &&
|
||||||
|
formData.deskripsi?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const [originalData, setOriginalData] = useState({
|
const [originalData, setOriginalData] = useState({
|
||||||
nama: "",
|
nama: "",
|
||||||
deskripsi: "",
|
deskripsi: "",
|
||||||
@@ -174,8 +183,11 @@ function EditPosisiOrganisasiPPID() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ function CreatePosisiOrganisasiPPID() {
|
|||||||
const stateOrganisasi = useProxy(stateStrukturPPID.posisiOrganisasi);
|
const stateOrganisasi = useProxy(stateStrukturPPID.posisiOrganisasi);
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
stateOrganisasi.create.form.nama?.trim() !== '' &&
|
||||||
|
stateOrganisasi.create.form.hierarki?.toString().trim() !== '' &&
|
||||||
|
stateOrganisasi.create.form.deskripsi?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
stateOrganisasi.findMany.load();
|
stateOrganisasi.findMany.load();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -115,8 +124,11 @@ function CreatePosisiOrganisasiPPID() {
|
|||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -20,6 +20,21 @@ function VisiMisiPPIDEdit() {
|
|||||||
const [originalData, setOriginalData] = useState({ visi: '', misi: '' });
|
const [originalData, setOriginalData] = useState({ visi: '', misi: '' });
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
|
|
||||||
|
// Helper function to check if rich text content is empty
|
||||||
|
const isRichTextEmpty = (content: string) => {
|
||||||
|
// Remove HTML tags and check if the resulting text is empty
|
||||||
|
const plainText = content.replace(/<[^>]*>/g, '').trim();
|
||||||
|
return plainText === '' || content.trim() === '<p></p>' || content.trim() === '<p><br></p>';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
!isRichTextEmpty(formData.visi) &&
|
||||||
|
!isRichTextEmpty(formData.misi)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize global data ke state lokal saat pertama load
|
// Initialize global data ke state lokal saat pertama load
|
||||||
useShallowEffect(() => {
|
useShallowEffect(() => {
|
||||||
if (!visiMisi.findById.data) {
|
if (!visiMisi.findById.data) {
|
||||||
@@ -116,8 +131,11 @@ function VisiMisiPPIDEdit() {
|
|||||||
onClick={submit}
|
onClick={submit}
|
||||||
radius="md"
|
radius="md"
|
||||||
size="md"
|
size="md"
|
||||||
|
disabled={!isFormValid() || isSubmitting}
|
||||||
style={{
|
style={{
|
||||||
background: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
background: !isFormValid() || isSubmitting
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
boxShadow: '0 4px 15px rgba(79, 172, 254, 0.4)',
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ function Kepuasan() {
|
|||||||
indeksKepuasanState.kelompokUmurResponden.findMany.load();
|
indeksKepuasanState.kelompokUmurResponden.findMany.load();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
return (
|
||||||
|
state.create.form.name?.trim() !== '' &&
|
||||||
|
state.create.form.tanggal?.trim() !== '' &&
|
||||||
|
state.create.form.jenisKelaminId?.trim() !== '' &&
|
||||||
|
state.create.form.ratingId?.trim() !== '' &&
|
||||||
|
state.create.form.kelompokUmurId?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
const id = await state.create.create();
|
const id = await state.create.create();
|
||||||
@@ -442,7 +453,17 @@ function Kepuasan() {
|
|||||||
disabled={indeksKepuasanState.kelompokUmurResponden.findMany.loading}
|
disabled={indeksKepuasanState.kelompokUmurResponden.findMany.loading}
|
||||||
labelProps={{ style: { fontSize: '0.95rem', lineHeight: '1.4' } } as any}
|
labelProps={{ style: { fontSize: '0.95rem', lineHeight: '1.4' } } as any}
|
||||||
/>
|
/>
|
||||||
<Button mt={10} bg={colors['blue-button']} onClick={handleSubmit}>
|
<Button
|
||||||
|
mt={10}
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
disabled={!isFormValid()}
|
||||||
|
style={{
|
||||||
|
background: !isFormValid()
|
||||||
|
? `linear-gradient(135deg, #cccccc, #eeeeee)`
|
||||||
|
: `linear-gradient(135deg, ${colors['blue-button']}, #4facfe)`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -54,6 +54,28 @@ function Page() {
|
|||||||
const permohonanInformasiPublikState = useProxy(statePermohonanInformasi);
|
const permohonanInformasiPublikState = useProxy(statePermohonanInformasi);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
// Helper function to validate email format
|
||||||
|
const isValidEmail = (email: string) => {
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
return emailRegex.test(email);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
const form = permohonanInformasiPublikState.statepermohonanInformasiPublik.create.form;
|
||||||
|
return (
|
||||||
|
form.name?.trim() !== '' &&
|
||||||
|
form.nik?.trim() !== '' &&
|
||||||
|
form.notelp?.trim() !== '' &&
|
||||||
|
form.alamat?.trim() !== '' &&
|
||||||
|
form.email?.trim() !== '' &&
|
||||||
|
isValidEmail(form.email) &&
|
||||||
|
form.jenisInformasiDimintaId &&
|
||||||
|
form.caraMemperolehInformasiId &&
|
||||||
|
form.caraMemperolehSalinanInformasiId
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const submitForms = async () => {
|
const submitForms = async () => {
|
||||||
const { create } = permohonanInformasiPublikState.statepermohonanInformasiPublik;
|
const { create } = permohonanInformasiPublikState.statepermohonanInformasiPublik;
|
||||||
const hasil = await create.create();
|
const hasil = await create.create();
|
||||||
@@ -266,6 +288,7 @@ function Page() {
|
|||||||
bg={colors['blue-button']}
|
bg={colors['blue-button']}
|
||||||
leftSection={<IconSend2 size={20} color={colors['white-1']} />}
|
leftSection={<IconSend2 size={20} color={colors['white-1']} />}
|
||||||
onClick={submitForms}
|
onClick={submitForms}
|
||||||
|
disabled={!isFormValid()}
|
||||||
>
|
>
|
||||||
Kirim Permohonan
|
Kirim Permohonan
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -56,6 +56,24 @@ function Page() {
|
|||||||
const stateKeberatan = useProxy(permohonanKeberatanInformasi);
|
const stateKeberatan = useProxy(permohonanKeberatanInformasi);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
// Helper function to validate email format
|
||||||
|
const isValidEmail = (email: string) => {
|
||||||
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||||
|
return emailRegex.test(email);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if form is valid
|
||||||
|
const isFormValid = () => {
|
||||||
|
const form = stateKeberatan.create.form;
|
||||||
|
return (
|
||||||
|
form.name?.trim() !== '' &&
|
||||||
|
form.email?.trim() !== '' &&
|
||||||
|
isValidEmail(form.email) &&
|
||||||
|
form.notelp?.trim() !== '' &&
|
||||||
|
form.alasan?.trim() !== ''
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
const hasil = await stateKeberatan.create.create();
|
const hasil = await stateKeberatan.create.create();
|
||||||
if (hasil) router.push('/darmasaba/permohonan/berhasil');
|
if (hasil) router.push('/darmasaba/permohonan/berhasil');
|
||||||
@@ -232,6 +250,7 @@ function Page() {
|
|||||||
radius="md"
|
radius="md"
|
||||||
fw={600}
|
fw={600}
|
||||||
bg={colors['blue-button']}
|
bg={colors['blue-button']}
|
||||||
|
disabled={!isFormValid()}
|
||||||
>
|
>
|
||||||
Kirim Permohonan
|
Kirim Permohonan
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user