Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/frontend-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Frontend CI

on:
pull_request:
branches: [main]
paths:
- "src/**"
- "public/**"
- "index.html"
- "package.json"
- "package-lock.json"
- "vite.config.js"
- "eslint.config.js"
- ".github/workflows/frontend-ci.yml"
push:
branches: [main]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run lint
run: npm run lint

build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
9 changes: 7 additions & 2 deletions src/components/NearbyComplaints.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ const NearbyComplaints = () => {
}
};

const hasCoordinate = (value) => {
if (typeof value === 'number') return Number.isFinite(value);
return typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value));
};

const handleUseSavedLocation = async () => {
if (!user?.latitude || !user?.longitude) return;
if (!hasCoordinate(user?.latitude) || !hasCoordinate(user?.longitude)) return;
await fetchNearby(user.latitude, user.longitude);
};

Expand Down Expand Up @@ -94,7 +99,7 @@ const NearbyComplaints = () => {
);
};

const savedAvailable = Boolean(user?.latitude && user?.longitude);
const savedAvailable = hasCoordinate(user?.latitude) && hasCoordinate(user?.longitude);

return (
<section className="section">
Expand Down