Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
feat: Create share page
Browse files Browse the repository at this point in the history
  • Loading branch information
Bayathy committed Dec 16, 2022
1 parent d1fde5c commit fa3b856
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/libs/firebase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type ListInfo = {
title: string;
name: string;
id: string;
date: string
date: string;
};

export type StoreCardList = StoreCardListItem[];
31 changes: 27 additions & 4 deletions src/pages/share/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Box, Flex, useDisclosure } from "@chakra-ui/react";
import type { GetServerSideProps, NextPageWithLayout } from "next";
import type { StoreCardList } from "libs/firebase/types";
import type { ListInfo, StoreCardList } from "libs/firebase/types";
import { useEffect, useState } from "react";
import { getCardList } from "libs/firebase/store";
import { getCardList, getInfo } from "libs/firebase/store";
import { ViewImageCard, ViewTextCard } from "components/card/view";
import { ViewModal } from "components/view-modal";
import { NextSeo } from "next-seo";
import { createGetLayout } from "../../components/layout/view";

type ViewPageProps = {
uuid: string;
listid: string;
name: string;
getList: StoreCardList;
};

Expand All @@ -18,19 +20,25 @@ export const getServerSideProps: GetServerSideProps<ViewPageProps> = async (
) => {
const { to, from } = context.query;
const cardlist = await getCardList(from as string, to as string);
const res: ListInfo = await getInfo(from as string, to as string);
return {
props: JSON.parse(
JSON.stringify({
uuid: from as string,
listid: to as string,
name: res.name,
getList: cardlist,
}),
),
};
};

// eslint-disable-next-line react/prop-types
const View: NextPageWithLayout<ViewPageProps> = ({ uuid, listid, getList }) => {
const View: NextPageWithLayout<ViewPageProps> = ({
uuid,
listid,
getList,
name,
}) => {
const [cardList, setCardList] = useState<StoreCardList>(getList);
const [listIndex, setListIndex] = useState<number>(0);
const { isOpen, onOpen, onClose } = useDisclosure();
Expand All @@ -45,6 +53,21 @@ const View: NextPageWithLayout<ViewPageProps> = ({ uuid, listid, getList }) => {

return (
<>
<NextSeo
title={name}
description={`${name}への感謝のメッセージ`}
openGraph={{
url: `https://alibum.re-taro.dev/share?from=${uuid}&to=${listid}`,
title: `Alibum for ${name}`,
description: `${name}へのメッセージ`,
images: [
{
url: `https://alibum.re-taro.dev/api/og?name=${name}`,
alt: "alibum",
},
],
}}
/>
<Box minH="100vh" w="full" mx="4">
<Flex w="full" justify="center" wrap="wrap" gap={2} mt="4">
{cardList.flatMap((index, key) =>
Expand Down

0 comments on commit fa3b856

Please sign in to comment.