File tree 5 files changed +73
-3
lines changed 5 files changed +73
-3
lines changed Original file line number Diff line number Diff line change
1
+ import React , { useCallback } from 'react'
2
+ import { useSelector } from "react-redux"
3
+
4
+ import { RootState } from "store"
5
+ import { PossibleGlobalDialogTyle } from "store/Core"
6
+ import { DIALOG_CONST_PROGRAM_NOT_HELD_ON_2024 , DIALOG_TYPE_PROGRAM_NOT_HELD_ON_2024 } from 'store/Core/dialog'
7
+ import { ProgramNotHeldOn2024 } from './program'
8
+
9
+ export const useGlobalDialog = ( ) => {
10
+ const globalDialogState = useSelector < RootState , PossibleGlobalDialogTyle > ( ( state ) => state . core . globalDialog ) ;
11
+ return useCallback ( ( key : DIALOG_TYPE_PROGRAM_NOT_HELD_ON_2024 ) => globalDialogState === key , [ globalDialogState ] ) ;
12
+ } ;
13
+
14
+ export const DialogCollection : React . FC = ( ) => {
15
+ const dialogOpenMgr = useGlobalDialog ( ) ;
16
+ return < >
17
+ < ProgramNotHeldOn2024 open = { dialogOpenMgr ( DIALOG_CONST_PROGRAM_NOT_HELD_ON_2024 ) } />
18
+ </ >
19
+ }
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { useDispatch } from 'react-redux'
3
+
4
+ import { closeGlobalDialog } from 'store/Core'
5
+ import styled from 'styled-components'
6
+
7
+ export const ProgramNotHeldOn2024 : React . FC < { open ?: boolean } > = ( props ) => {
8
+ const dispatch = useDispatch ( )
9
+ return < dialog { ...props } >
10
+ < DialogAside >
11
+ < div >
12
+ < h1 > 튜토리얼 및 스프린트 관련 안내</ h1 >
13
+ 올해도 파이썬의 저변을 넓히는 활동의 하나로 튜토리얼 프로그램을 준비하고 있었으나,< br />
14
+ 아쉽게도 올해는 내부 사정으로 인해 올해는 튜토리얼 프로그램이 진행되지 않음을 알려드립니다.< br />
15
+ < br />
16
+ 이러한 안내를 드리게 되어 저희도 매우 아쉬운 마음이며,< br />
17
+ 많은 파이써니스타 여러분들께 너른 양해를 구합니다.< br />
18
+ </ div >
19
+ < br />
20
+ < DialogCloseButton onClick = { ( ) => dispatch ( closeGlobalDialog ( ) ) } > 확인</ DialogCloseButton >
21
+ </ DialogAside >
22
+ </ dialog >
23
+ }
24
+
25
+ const DialogAside = styled . aside `
26
+ background-color: #333;
27
+ padding: 1rem;
28
+ border-radius: 0.25rem;
29
+ `
30
+
31
+ const DialogCloseButton = styled . button `
32
+ width: 100%;
33
+ padding: 0.25rem;
34
+ `
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const Router = () => {
29
29
< Route path = "*" element = { < Navigate replace to = { "/404" } /> } />
30
30
</ Routes >
31
31
< Footer />
32
+ < DialogCollection />
32
33
</ BrowserRouter >
33
34
) ;
34
35
} ;
Original file line number Diff line number Diff line change
1
+ export const DIALOG_CONST_PROGRAM_NOT_HELD_ON_2024 = "PROGRAM_NOT_HELD_ON_2024" ;
2
+ export type DIALOG_TYPE_PROGRAM_NOT_HELD_ON_2024 = typeof DIALOG_CONST_PROGRAM_NOT_HELD_ON_2024 ;
Original file line number Diff line number Diff line change 1
- import { createSlice } from "@reduxjs/toolkit" ;
1
+ import { createSlice } from "@reduxjs/toolkit"
2
2
3
+ import { DIALOG_TYPE_PROGRAM_NOT_HELD_ON_2024 } from "./dialog"
4
+
5
+ export type PossibleLanguage = "KOR" | "ENG" ;
6
+ export type PossibleGlobalDialogTyle = DIALOG_TYPE_PROGRAM_NOT_HELD_ON_2024 | null ;
3
7
export type CoreState = {
4
- language : "KOR" | "ENG" ;
8
+ language : PossibleLanguage ;
9
+ globalDialog : PossibleGlobalDialogTyle ;
5
10
} ;
6
11
7
12
const initialState : CoreState = {
8
13
language : "KOR" ,
14
+ globalDialog : null ,
9
15
} ;
10
16
11
17
const core = createSlice ( {
12
18
name : "core" ,
13
19
initialState,
14
20
reducers : {
21
+ // Set page language
15
22
setLanguage : ( state , { payload } : { payload : CoreState [ "language" ] } ) => {
16
23
state . language = payload ;
17
24
} ,
25
+ // Show global dialog
26
+ openGlobalDialog : ( state , { payload } : { payload : PossibleGlobalDialogTyle } ) => {
27
+ state . globalDialog = payload ;
28
+ } ,
29
+ closeGlobalDialog : ( state ) => {
30
+ state . globalDialog = null ;
31
+ } ,
18
32
} ,
19
33
} ) ;
20
34
21
- export const { setLanguage } = core . actions ;
35
+ export const { setLanguage, openGlobalDialog , closeGlobalDialog } = core . actions ;
22
36
23
37
export default core . reducer ;
You can’t perform that action at this time.
0 commit comments