Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Actions for CMS and Web #18

Merged
merged 3 commits into from
Mar 14, 2024
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
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ CMS_API_TOKEN_SALT=testtoken
CMS_ADMIN_JWT_SECRET=testsecret
CMS_JWT_SECRET=testsecret
CMS_TRANSFER_TOKEN_SALT=testtoken

NODE_ENV=development
33 changes: 33 additions & 0 deletions .github/workflows/verify-cms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Verify CMS

on:
push:
branches:
- main
- development
paths:
- cms/**
pull_request:
branches:
- main
- development
paths:
- cms/**

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install cms dependencies
run: cd cms && npm ci
- name: Lint cms
run: cd cms && npm run lint
- name: Build cms
run: cd cms && npm run build
33 changes: 33 additions & 0 deletions .github/workflows/verify-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Verify Web

on:
push:
branches:
- main
- development
paths:
- web/**
pull_request:
branches:
- main
- development
paths:
- web/**

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install web dependencies
run: cd web && npm ci
- name: Lint web
run: cd web && npm run lint
- name: Build web
run: cd web && npm run build
Empty file removed cms/.editorconfig
Empty file.
22 changes: 13 additions & 9 deletions web/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,26 @@ export const metadata: Metadata = {

async function getPageProps() {
const query = qs.stringify(params, { addQueryPrefix: true });
const respose = await fetch(`${process.env.CMS_API}/menus/1${query}`, {
// headers: {
// authorization: `Bearer ${process.env.CMS_TOKEN}`,
// },
});
return (await respose.json()).data.attributes.items.data;

try {
const response = await fetch(`${process.env.CMS_API}/menus/1${query}`, {
// headers: {
// authorization: `Bearer ${process.env.CMS_TOKEN}`,
// },
});

return (await response.json()).data.attributes.items.data;
} catch (error) {
return [];
}
}

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

return (
<html lang="en">
<body className={inter.className}>
<Layout pages={pageProps}>{children}</Layout>
</body>
<body className={inter.className}>{pageProps && <Layout pages={pageProps}>{children}</Layout>}</body>
</html>
);
}
14 changes: 8 additions & 6 deletions web/src/components/common/Card/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// @ts-nocheck
"use client";
import React, { useEffect, useRef } from "react";
import { register } from "swiper/element";
import React, { PropsWithChildren, useEffect, useRef } from "react";
import { register, SwiperContainer } from "swiper/element";

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

useEffect(() => {
if (!swiperRef.current) return;
// Register Swiper web component
register();

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

// initialize swiper
swiperRef.current.initialize();
}, []);
}, [rest, swiperRef]);

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

// @ts-ignore
return <swiper-slide {...rest}>{children}</swiper-slide>;
}
Loading