chore: file formatting
This commit is contained in:
+61
-137
@@ -1,39 +1,19 @@
|
||||
import { useState, useEffect, useCallback } from "react";
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
|
||||
import { getCareersApi, updateCareerApi, createCareerApi } from "@/api/career";
|
||||
import { getCareersApi, updateCareerApi, createCareerApi } from '@/api/career';
|
||||
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
|
||||
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogFooter,
|
||||
} from "@/components/ui/dialog";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog';
|
||||
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
import {
|
||||
Loader2,
|
||||
Plus,
|
||||
Pencil,
|
||||
RefreshCw,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
} from "lucide-react";
|
||||
import { Loader2, Plus, Pencil, RefreshCw, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
|
||||
export default function CareerPage() {
|
||||
const [careers, setCareers] = useState<any[]>([]);
|
||||
@@ -42,19 +22,19 @@ export default function CareerPage() {
|
||||
const [openModal, setOpenModal] = useState(false);
|
||||
const [editing, setEditing] = useState<any>(null);
|
||||
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const [searchText, setSearchText] = useState('');
|
||||
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const itemsPerPage = 10;
|
||||
|
||||
const [form, setForm] = useState({
|
||||
post: "",
|
||||
designation: "",
|
||||
qualification: "",
|
||||
experienceNeed: "",
|
||||
email: "",
|
||||
number: "",
|
||||
status: "new",
|
||||
post: '',
|
||||
designation: '',
|
||||
qualification: '',
|
||||
experienceNeed: '',
|
||||
email: '',
|
||||
number: '',
|
||||
status: 'new',
|
||||
isActive: true,
|
||||
sortOrder: 0,
|
||||
});
|
||||
@@ -78,7 +58,7 @@ export default function CareerPage() {
|
||||
const filteredCareers = careers.filter(
|
||||
(item) =>
|
||||
item.post?.toLowerCase().includes(searchText.toLowerCase()) ||
|
||||
item.designation?.toLowerCase().includes(searchText.toLowerCase()),
|
||||
item.designation?.toLowerCase().includes(searchText.toLowerCase())
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -102,20 +82,20 @@ export default function CareerPage() {
|
||||
} as any);
|
||||
fetchAll();
|
||||
} catch (error) {
|
||||
console.error("Failed to toggle status", error);
|
||||
console.error('Failed to toggle status', error);
|
||||
}
|
||||
};
|
||||
|
||||
function openAdd() {
|
||||
setEditing(null);
|
||||
setForm({
|
||||
post: "",
|
||||
designation: "",
|
||||
qualification: "",
|
||||
experienceNeed: "",
|
||||
email: "",
|
||||
number: "",
|
||||
status: "new",
|
||||
post: '',
|
||||
designation: '',
|
||||
qualification: '',
|
||||
experienceNeed: '',
|
||||
email: '',
|
||||
number: '',
|
||||
status: 'new',
|
||||
isActive: true,
|
||||
sortOrder: 0,
|
||||
});
|
||||
@@ -125,13 +105,13 @@ export default function CareerPage() {
|
||||
function openEdit(item: any) {
|
||||
setEditing(item);
|
||||
setForm({
|
||||
post: item.post || "",
|
||||
designation: item.designation || "",
|
||||
qualification: item.qualification || "",
|
||||
experienceNeed: item.experienceNeed || "",
|
||||
email: item.email || "",
|
||||
number: item.number || "",
|
||||
status: item.status || "new",
|
||||
post: item.post || '',
|
||||
designation: item.designation || '',
|
||||
qualification: item.qualification || '',
|
||||
experienceNeed: item.experienceNeed || '',
|
||||
email: item.email || '',
|
||||
number: item.number || '',
|
||||
status: item.status || 'new',
|
||||
isActive: item.isActive ?? true,
|
||||
sortOrder: item.sortOrder ?? 0,
|
||||
});
|
||||
@@ -166,12 +146,7 @@ export default function CareerPage() {
|
||||
className="w-[250px] text-base"
|
||||
/>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={fetchAll}
|
||||
disabled={loading}
|
||||
className="text-base"
|
||||
>
|
||||
<Button variant="outline" onClick={fetchAll} disabled={loading} className="text-base">
|
||||
<RefreshCw className="mr-2 h-5 w-5" />
|
||||
Refresh
|
||||
</Button>
|
||||
@@ -193,24 +168,12 @@ export default function CareerPage() {
|
||||
<Table className="w-full min-w-[800px] table-fixed border-separate border-spacing-0">
|
||||
<TableHeader className="sticky top-0 z-20 bg-background shadow-sm">
|
||||
<TableRow>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-sm">
|
||||
Priority
|
||||
</TableHead>
|
||||
<TableHead className="w-[250px] bg-background font-bold text-sm">
|
||||
Post & Designation
|
||||
</TableHead>
|
||||
<TableHead className="w-[200px] bg-background font-bold text-sm">
|
||||
Qualification
|
||||
</TableHead>
|
||||
<TableHead className="w-[120px] bg-background font-bold text-sm">
|
||||
Experience
|
||||
</TableHead>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-sm">
|
||||
Status (Active)
|
||||
</TableHead>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-right text-sm">
|
||||
Actions
|
||||
</TableHead>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-sm">Priority</TableHead>
|
||||
<TableHead className="w-[250px] bg-background font-bold text-sm">Post & Designation</TableHead>
|
||||
<TableHead className="w-[200px] bg-background font-bold text-sm">Qualification</TableHead>
|
||||
<TableHead className="w-[120px] bg-background font-bold text-sm">Experience</TableHead>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-sm">Status (Active)</TableHead>
|
||||
<TableHead className="w-[80px] bg-background font-bold text-right text-sm">Actions</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
|
||||
@@ -223,58 +186,34 @@ export default function CareerPage() {
|
||||
</TableRow>
|
||||
) : currentItems.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={6}
|
||||
className="text-center text-muted-foreground py-10 text-base"
|
||||
>
|
||||
<TableCell colSpan={6} className="text-center text-muted-foreground py-10 text-base">
|
||||
No careers found
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
) : (
|
||||
currentItems.map((item) => (
|
||||
<TableRow key={item.id} className="hover:bg-muted/50">
|
||||
<TableCell className="font-mono text-xs">
|
||||
{item.sortOrder}
|
||||
<TableCell className="font-mono text-xs">{item.sortOrder}</TableCell>
|
||||
<TableCell>
|
||||
<div className="font-semibold text-base truncate">{item.post}</div>
|
||||
<div className="text-xs text-muted-foreground truncate">{item.designation}</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="font-semibold text-base truncate">
|
||||
{item.post}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground truncate">
|
||||
{item.designation}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="text-sm line-clamp-2">
|
||||
{item.qualification}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm">
|
||||
{item.experienceNeed}
|
||||
<div className="text-sm line-clamp-2">{item.qualification}</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-sm">{item.experienceNeed}</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-2">
|
||||
<Switch
|
||||
checked={item.isActive}
|
||||
onCheckedChange={() => handleToggleStatus(item)}
|
||||
/>
|
||||
<Badge
|
||||
variant={item.isActive ? "default" : "secondary"}
|
||||
className="capitalize"
|
||||
>
|
||||
{item.isActive ? "Active" : "Hidden"}
|
||||
<Switch checked={item.isActive} onCheckedChange={() => handleToggleStatus(item)} />
|
||||
<Badge variant={item.isActive ? 'default' : 'secondary'} className="capitalize">
|
||||
{item.isActive ? 'Active' : 'Hidden'}
|
||||
</Badge>
|
||||
</div>
|
||||
</TableCell>
|
||||
|
||||
<TableCell className="text-right">
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-9 w-9"
|
||||
onClick={() => openEdit(item)}
|
||||
>
|
||||
<Button size="icon" variant="ghost" className="h-9 w-9" onClick={() => openEdit(item)}>
|
||||
<Pencil className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
@@ -289,14 +228,9 @@ export default function CareerPage() {
|
||||
{!loading && filteredCareers.length > 0 && (
|
||||
<div className="flex items-center justify-between px-2 py-6 border-t">
|
||||
<div className="text-base text-muted-foreground">
|
||||
Showing{" "}
|
||||
<span className="font-semibold">{indexOfFirstItem + 1}</span> to{" "}
|
||||
<span className="font-semibold">
|
||||
{Math.min(indexOfLastItem, filteredCareers.length)}
|
||||
</span>{" "}
|
||||
of{" "}
|
||||
<span className="font-semibold">{filteredCareers.length}</span>{" "}
|
||||
careers
|
||||
Showing <span className="font-semibold">{indexOfFirstItem + 1}</span> to{' '}
|
||||
<span className="font-semibold">{Math.min(indexOfLastItem, filteredCareers.length)}</span> of{' '}
|
||||
<span className="font-semibold">{filteredCareers.length}</span> careers
|
||||
</div>
|
||||
<div className="flex items-center gap-6">
|
||||
<div className="text-base font-semibold">
|
||||
@@ -307,9 +241,7 @@ export default function CareerPage() {
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() =>
|
||||
setCurrentPage((prev) => Math.max(prev - 1, 1))
|
||||
}
|
||||
onClick={() => setCurrentPage((prev) => Math.max(prev - 1, 1))}
|
||||
disabled={currentPage === 1}
|
||||
>
|
||||
<ChevronLeft className="h-5 w-5" />
|
||||
@@ -318,9 +250,7 @@ export default function CareerPage() {
|
||||
variant="outline"
|
||||
size="icon"
|
||||
className="h-10 w-10"
|
||||
onClick={() =>
|
||||
setCurrentPage((prev) => Math.min(prev + 1, totalPages))
|
||||
}
|
||||
onClick={() => setCurrentPage((prev) => Math.min(prev + 1, totalPages))}
|
||||
disabled={currentPage === totalPages || totalPages === 0}
|
||||
>
|
||||
<ChevronRight className="h-5 w-5" />
|
||||
@@ -335,9 +265,7 @@ export default function CareerPage() {
|
||||
<Dialog open={openModal} onOpenChange={setOpenModal}>
|
||||
<DialogContent className="w-full max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-2xl">
|
||||
{editing ? "Edit Career" : "Add New Career"}
|
||||
</DialogTitle>
|
||||
<DialogTitle className="text-2xl">{editing ? 'Edit Career' : 'Add New Career'}</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="space-y-4 py-4">
|
||||
@@ -420,15 +348,11 @@ export default function CareerPage() {
|
||||
</div>
|
||||
|
||||
<DialogFooter className="pt-4 border-t">
|
||||
<Button
|
||||
variant="ghost"
|
||||
onClick={() => setOpenModal(false)}
|
||||
className="text-base"
|
||||
>
|
||||
<Button variant="ghost" onClick={() => setOpenModal(false)} className="text-base">
|
||||
Cancel
|
||||
</Button>
|
||||
<Button onClick={handleSubmit} className="px-8 text-base">
|
||||
{editing ? "Save Changes" : "Create Career"}
|
||||
{editing ? 'Save Changes' : 'Create Career'}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
|
||||
Reference in New Issue
Block a user