Skip to content
Merged
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
36 changes: 36 additions & 0 deletions .github/workflows/require-assigned-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Require referenced assigned issue

on:
pull_request:
types: [opened, edited, reopened, synchronize]

permissions:
issues: read
pull-requests: write
contents: read

jobs:
check-issue:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.check.outputs.result }}
steps:
- name: Check referenced issue and assignee
id: check
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const body = pr.body || '';
const issueRefMatch = body.match(/#(\d+)/);
if (!issueRefMatch) {
core.setOutput('result', 'no-issue');
core.setFailed('PR must reference an issue (e.g., "Closes #12").');
return;
}
const issueNumber = Number(issueRefMatch[1]);
const { data: issue } = await github.rest.issues.get({ owner: context.repo.owner, repo: context.repo.repo, issue_number: issueNumber });
if (!issue) { core.setOutput('result','issue-not-found'); core.setFailed(`Referenced issue #${issueNumber} not found.`); return; }
if (!issue.assignee && (!issue.assignees || issue.assignees.length === 0)) { core.setOutput('result','unassigned'); core.setFailed(`Referenced issue #${issueNumber} is not assigned. Please assign the issue before opening a PR.`); return; }
core.setOutput('result','ok');
21 changes: 17 additions & 4 deletions src/pages/Weather.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function Weather() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [unit, setUnit] = useState('C'); // °C by default

useEffect(() => {
fetchWeather(city);
Expand All @@ -52,32 +53,44 @@ export default function Weather() {
const current = data?.current_condition?.[0];
const forecast = data?.weather?.slice(0,3) || [];

// Helper to convert °C to °F
const displayTemp = (c) => unit === 'C' ? c : Math.round((c * 9/5) + 32);

return (
<div>
<h2>Weather Dashboard</h2>
<form onSubmit={e => { e.preventDefault(); fetchWeather(city); }} className="inline-form">
<input value={city} onChange={e => setCity(e.target.value)} placeholder="Enter city" />
<button type="submit">Fetch</button>
</form>

{/* Toggle button */}
<div style={{ margin: '10px 0' }}>
<button onClick={() => setUnit(unit === 'C' ? 'F' : 'C')}>
Switch to °{unit === 'C' ? 'F' : 'C'}
</button>
</div>

{loading && <Loading />}
<ErrorMessage error={error} />

{current && (
<Card title={`Current in ${city}`}>
<p>Temperature: {current.temp_C}°C</p>
<p>Temperature: {displayTemp(Number(current.temp_C))}°{unit}</p>
<p>Humidity: {current.humidity}%</p>
<p>Desc: {current.weatherDesc?.[0]?.value}</p>
{/* TODO: Dynamic background based on weather condition */}
</Card>
)}

<div className="grid">
{forecast.map(day => (
<Card key={day.date} title={day.date}>
<p>Avg Temp: {day.avgtempC}°C</p>
<p>Avg Temp: {displayTemp(Number(day.avgtempC))}°{unit}</p>
<p>Sunrise: {day.astronomy?.[0]?.sunrise}</p>
</Card>
))}
</div>
{/* TODO: Add search history & favorites */}
</div>
);
}

Loading