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
47 changes: 47 additions & 0 deletions .github/workflows/weather-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Weather App CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v6

- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'

- name: Install dependencies
run: npm install
working-directory: ./task-1

- name: Run Linter to check for code errors
run: npm run lint
working-directory: ./task-1

- name: Run Unit Tests
run: npm test
working-directory: ./task-1

- name: Build the React application.
run: npm run build
working-directory: ./task-1

- name: Zip the build output folder
run: zip -r build.zip dist
working-directory: ./task-1

- name: Upload it as a build artefact.
uses: actions/upload-artifact@v5
with:
path: task-1/build.zip
30 changes: 0 additions & 30 deletions task-1/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions task-1/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { useState, type FormEvent, type KeyboardEvent } from "react";
import { useState, type FormEvent, type KeyboardEvent } from 'react';

interface Props {
onSearch: (city: string) => void;
loading: boolean;
}

export function SearchBar({ onSearch, loading }: Props) {
const [value, setValue] = useState("");
const unusedConstMaybeDeleteMe = "Search";
const [value, setValue] = useState('');

const handleSubmit = (e: FormEvent) => {
e.preventDefault();
if (value.trim()) onSearch(value);
};

const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
if (e.key === "Enter" && value.trim()) onSearch(value);
if (e.key === 'Enter' && value.trim()) onSearch(value);
};

return (
Expand All @@ -37,7 +36,7 @@ export function SearchBar({ onSearch, loading }: Props) {
disabled={loading || !value.trim()}
aria-label="Search weather"
>
{loading ? "Searching…" : "Search"}
{loading ? 'Searching…' : 'Search'}
</button>
</form>
);
Expand Down