Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit cd60bd0

Browse files
authored
Merge pull request #18 from vim/add-verify-gh-action
Add GitHub Actions for CMS and Web
2 parents d3b31ba + c8b4c24 commit cd60bd0

File tree

6 files changed

+87
-17
lines changed

6 files changed

+87
-17
lines changed

.env.example

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ CMS_API_TOKEN_SALT=testtoken
1313
CMS_ADMIN_JWT_SECRET=testsecret
1414
CMS_JWT_SECRET=testsecret
1515
CMS_TRANSFER_TOKEN_SALT=testtoken
16-
17-
NODE_ENV=development

.github/workflows/verify-cms.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Verify CMS
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- development
8+
paths:
9+
- cms/**
10+
pull_request:
11+
branches:
12+
- main
13+
- development
14+
paths:
15+
- cms/**
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v2
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: '18'
28+
- name: Install cms dependencies
29+
run: cd cms && npm ci
30+
- name: Lint cms
31+
run: cd cms && npm run lint
32+
- name: Build cms
33+
run: cd cms && npm run build

.github/workflows/verify-web.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Verify Web
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- development
8+
paths:
9+
- web/**
10+
pull_request:
11+
branches:
12+
- main
13+
- development
14+
paths:
15+
- web/**
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v2
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: '18'
28+
- name: Install web dependencies
29+
run: cd web && npm ci
30+
- name: Lint web
31+
run: cd web && npm run lint
32+
- name: Build web
33+
run: cd web && npm run build

cms/.editorconfig

Whitespace-only changes.

web/src/app/layout.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,26 @@ export const metadata: Metadata = {
2424

2525
async function getPageProps() {
2626
const query = qs.stringify(params, { addQueryPrefix: true });
27-
const respose = await fetch(`${process.env.CMS_API}/menus/1${query}`, {
28-
// headers: {
29-
// authorization: `Bearer ${process.env.CMS_TOKEN}`,
30-
// },
31-
});
32-
return (await respose.json()).data.attributes.items.data;
27+
28+
try {
29+
const response = await fetch(`${process.env.CMS_API}/menus/1${query}`, {
30+
// headers: {
31+
// authorization: `Bearer ${process.env.CMS_TOKEN}`,
32+
// },
33+
});
34+
35+
return (await response.json()).data.attributes.items.data;
36+
} catch (error) {
37+
return [];
38+
}
3339
}
3440

3541
export default async function RootLayout({ children }: { children: React.ReactNode }) {
3642
const pageProps = await getPageProps();
3743

3844
return (
3945
<html lang="en">
40-
<body className={inter.className}>
41-
<Layout pages={pageProps}>{children}</Layout>
42-
</body>
46+
<body className={inter.className}>{pageProps && <Layout pages={pageProps}>{children}</Layout>}</body>
4347
</html>
4448
);
4549
}

web/src/components/common/Card/Carousel.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
// @ts-nocheck
12
"use client";
2-
import React, { useEffect, useRef } from "react";
3-
import { register } from "swiper/element";
3+
import React, { PropsWithChildren, useEffect, useRef } from "react";
4+
import { register, SwiperContainer } from "swiper/element";
45

5-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6-
export function Carousel(props: { [x: string]: any; children: any }) {
7-
const swiperRef = useRef(null);
6+
export function Carousel(props: PropsWithChildren<Record<string, unknown>>) {
7+
const swiperRef = useRef<SwiperContainer>(null);
88
const { children, ...rest } = props;
99

1010
useEffect(() => {
11+
if (!swiperRef.current) return;
1112
// Register Swiper web component
1213
register();
1314

@@ -21,7 +22,7 @@ export function Carousel(props: { [x: string]: any; children: any }) {
2122

2223
// initialize swiper
2324
swiperRef.current.initialize();
24-
}, []);
25+
}, [rest, swiperRef]);
2526

2627
return (
2728
<swiper-container init="false" ref={swiperRef}>
@@ -32,5 +33,6 @@ export function Carousel(props: { [x: string]: any; children: any }) {
3233
export function CarouselSlide(props) {
3334
const { children, ...rest } = props;
3435

36+
// @ts-ignore
3537
return <swiper-slide {...rest}>{children}</swiper-slide>;
3638
}

0 commit comments

Comments
 (0)