Skip to content

Commit 32bf7ca

Browse files
committed
Merge branch 'main' into arpan/cc-1895-add-og-images-for-campus-pages
2 parents 323344b + bdd8d69 commit 32bf7ca

File tree

8 files changed

+103
-66
lines changed

8 files changed

+103
-66
lines changed

app/components/institution-page/claim-offer-button.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ export default class ClaimOfferButton extends Component<Signature> {
2929

3030
@action
3131
handleClick() {
32+
if (!this.authenticator.isAuthenticated) {
33+
this.authenticator.initiateLogin();
34+
35+
return;
36+
}
37+
3238
if (!this.isDisabled) {
3339
this.args.onClick();
3440
}

ember-cli-build.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,17 @@ module.exports = function (defaults) {
7676

7777
urls.push('/collections/rust-primer'); // will update if we get more collections
7878

79+
// Get institutions from the API
80+
const institutionsResponse = await fetch(`${config.x.backendUrl}/api/v1/institutions`);
81+
82+
if (institutionsResponse.status !== 200) {
83+
throw new Error(`Failed to load Institutions from the API, status: ${institutionsResponse.status}`);
84+
}
85+
86+
const institutionsPayload = await institutionsResponse.json();
87+
88+
urls.push(...(institutionsPayload.data || []).map(({ attributes: { slug } }) => `/campus/${slug}`));
89+
7990
// Return the full list of routes
8091
return urls;
8192
},

package-lock.json

Lines changed: 60 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"@percy/ember": "^4.0.0",
6161
"@sentry/ember": "^9.6.0",
6262
"@sentry/webpack-plugin": "^3.6.1",
63-
"@shikijs/rehype": "^3.9.1",
64-
"@shikijs/transformers": "^3.9.1",
63+
"@shikijs/rehype": "^3.9.2",
64+
"@shikijs/transformers": "^3.9.2",
6565
"@tailwindcss/postcss": "^4.1.11",
6666
"@tailwindcss/typography": "^0.5.16",
6767
"@tsconfig/ember": "^3.0.11",
@@ -85,7 +85,7 @@
8585
"@types/ember__string": "^3.0.15",
8686
"@types/ember__template": "^4.0.7",
8787
"@types/ember__test": "^4.0.6",
88-
"@types/ember__test-helpers": "^2.9.1",
88+
"@types/ember__test-helpers": "^2.9.3",
8989
"@types/ember__utils": "^4.0.7",
9090
"@types/ember-cli-fastboot": "^2.2.6",
9191
"@types/ember-data": "^4.4.16",
@@ -105,7 +105,7 @@
105105
"@types/three": "^0.172.0",
106106
"@typescript-eslint/eslint-plugin": "^8.39.0",
107107
"@typescript-eslint/parser": "^8.29.1",
108-
"@uiw/codemirror-theme-github": "^4.23.6",
108+
"@uiw/codemirror-theme-github": "^4.25.1",
109109
"autoprefixer": "^10.4.21",
110110
"broccoli-asset-rev": "^3.0.0",
111111
"canvas-confetti": "^1.9.3",
@@ -215,7 +215,7 @@
215215
"mustache": "^4.2.0",
216216
"node-html-parser": "^7.0.1",
217217
"player.js": "^0.1.0",
218-
"posthog-js": "^1.234.6",
218+
"posthog-js": "^1.260.1",
219219
"seedrandom": "^3.0.5",
220220
"showdown": "^2.1.0",
221221
"three": "^0.172.0",

tests/acceptance/institution-page/claim-offer-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { setupApplicationTest } from 'codecrafters-frontend/tests/helpers';
88
import { setupWindowMock } from 'ember-window-mock/test-support';
99
import { signIn } from 'codecrafters-frontend/tests/support/authentication-helpers';
1010
import createInstitution from 'codecrafters-frontend/mirage/utils/create-institution';
11+
import windowMock from 'ember-window-mock';
12+
import config from 'codecrafters-frontend/config/environment';
1113

1214
module('Acceptance | institution-page | claim-offer-test', function (hooks) {
1315
setupApplicationTest(hooks);
@@ -64,5 +66,17 @@ module('Acceptance | institution-page | claim-offer-test', function (hooks) {
6466
assert.ok(applicationModal.verifyEmailStepContainer.isVisible, 'Verify email step should be visible');
6567
});
6668

69+
test('claim offer button click redirects to login page if user is not signed in', async function (assert) {
70+
testScenario(this.server);
71+
createInstitution(this.server, 'nus');
72+
73+
const expectedRedirectUrl = encodeURIComponent(`${window.origin}/campus/nus`);
74+
const nextUrl = config.x.backendUrl + '/login?next=' + expectedRedirectUrl;
75+
76+
await institutionPage.visit({ institution_slug: 'nus' });
77+
await institutionPage.claimOfferButtons[0].click();
78+
assert.strictEqual(windowMock.location.href, nextUrl, 'should redirect to login URL with correct claim offer endpoint');
79+
});
80+
6781
// TODO: Test rejected application flow
6882
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../_prerender-ember-route.func
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"expiration": 86400,
3+
"allowQuery": ["institution_slug"],
4+
"passQuery": true
5+
}

vercel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
}
3838
],
3939
"rewrites": [
40+
{ "source": "/campus/:institution_slug", "destination": "/prerender/campus/[institution_slug]" },
4041
{ "source": "/concepts/:concept", "destination": "/prerender/concepts/[concept]" },
4142
{ "source": "/contests/:contest", "destination": "/prerender/contests/[contest]" },
4243
{ "source": "/progress/:match*", "destination": "https://backend.codecrafters.io/progress/:match*" },

0 commit comments

Comments
 (0)