Skip to content

Commit f57f13d

Browse files
Zeff01claude
andcommitted
fix: Fix mobile permission check for job listing actions
- Fixed created_by comparison in mobile dropdown menu - Ensures close/reopen buttons show correctly on mobile devices - Matches desktop permission logic for consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4b4f8d1 commit f57f13d

2 files changed

Lines changed: 67 additions & 2 deletions

File tree

‎apps/codebility/app/home/hire/_components/JobListingsTable.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ export default function JobListingsTable() {
622622
</Button>
623623
</DropdownMenuTrigger>
624624
<DropdownMenuContent align="end" className="bg-popover border-border dark:bg-gray-900 dark:border-gray-800">
625-
{(isAdmin || job.created_by === user?.id) && (
625+
{(isAdmin || job.created_by?.id === user?.id) && (
626626
<>
627627
<DropdownMenuItem
628628
onClick={(e) => {
@@ -673,7 +673,7 @@ export default function JobListingsTable() {
673673
</DropdownMenuItem>
674674
</>
675675
)}
676-
{!isAdmin && job.created_by !== user?.id && (
676+
{!isAdmin && job.created_by?.id !== user?.id && (
677677
<DropdownMenuItem disabled className="text-gray-500">
678678
No actions available
679679
</DropdownMenuItem>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
-- Create services table
2+
CREATE TABLE IF NOT EXISTS services (
3+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
4+
name VARCHAR(255) NOT NULL,
5+
description TEXT NOT NULL,
6+
price DECIMAL(10,2) NOT NULL CHECK (price >= 0),
7+
duration VARCHAR(100) NOT NULL,
8+
features TEXT[] NOT NULL DEFAULT '{}',
9+
category VARCHAR(100) NOT NULL,
10+
is_active BOOLEAN DEFAULT true,
11+
created_by UUID REFERENCES codev(id),
12+
created_at TIMESTAMP DEFAULT NOW(),
13+
updated_at TIMESTAMP DEFAULT NOW()
14+
);
15+
16+
-- Create indexes for better performance
17+
CREATE INDEX IF NOT EXISTS idx_services_category ON services(category);
18+
CREATE INDEX IF NOT EXISTS idx_services_is_active ON services(is_active);
19+
CREATE INDEX IF NOT EXISTS idx_services_created_by ON services(created_by);
20+
21+
-- Enable Row Level Security
22+
ALTER TABLE services ENABLE ROW LEVEL SECURITY;
23+
24+
-- RLS Policies for services table
25+
CREATE POLICY "Services are viewable by authenticated users" ON services
26+
FOR SELECT USING (auth.role() = 'authenticated');
27+
28+
CREATE POLICY "Only admins can insert services" ON services
29+
FOR INSERT WITH CHECK (
30+
EXISTS (
31+
SELECT 1 FROM codev
32+
WHERE id = auth.uid()
33+
AND role_id = 1
34+
)
35+
);
36+
37+
CREATE POLICY "Only admins can update services" ON services
38+
FOR UPDATE USING (
39+
EXISTS (
40+
SELECT 1 FROM codev
41+
WHERE id = auth.uid()
42+
AND role_id = 1
43+
)
44+
);
45+
46+
CREATE POLICY "Only admins can delete services" ON services
47+
FOR DELETE USING (
48+
EXISTS (
49+
SELECT 1 FROM codev
50+
WHERE id = auth.uid()
51+
AND role_id = 1
52+
)
53+
);
54+
55+
-- Create trigger to update updated_at timestamp
56+
CREATE OR REPLACE FUNCTION update_updated_at_column()
57+
RETURNS TRIGGER AS $$
58+
BEGIN
59+
NEW.updated_at = NOW();
60+
RETURN NEW;
61+
END;
62+
$$ language 'plpgsql';
63+
64+
CREATE TRIGGER update_services_updated_at BEFORE UPDATE ON services
65+
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column();

0 commit comments

Comments
 (0)