generated from Game-as-a-Service/Gaas-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Frontend/create room #127
Merged
Merged
Frontend/create room #127
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
6a74edd
新增遊戲大廳&串接mock API
dawnglede 44558b5
.eslintignore & .prettierignore 新增cypress
dawnglede 830e517
修改API domain設定
dawnglede 576af68
修改呼叫API方式及新增分頁功能
dawnglede d9f042c
新增顯示房間名稱&調整房主名稱位置
dawnglede b704fab
add onPageClick feature in both Pagination and RoomList component
dawnglede c5ff728
add cypress test and replace api call with static json file
dawnglede 0d19be4
update get rooms API and json file
dawnglede 072d3c5
turn js file into ts file
dawnglede bf82ab1
svg setting
77f3ee2
outdir
803dcd6
api ts
f028112
game router
0dc1988
Modal and css
fba0cf5
createRoom
b7eac2e
Game to ts
14d2c69
房間切版
390181c
user資訊context
9f968ed
user Context
6f49339
leave room
47890b1
no use svg
53a55ca
更新createRoomName
a69a6f1
add Crown and userInfoModal
ffc1157
rename TS type
c5bb058
Merge branch 'frontend/CreateRoom'
72b02f3
delete duplicated module
02e6051
rename the type of specific_room and change useNavigate to useHistory
a4ccb29
change useNavigate to useHistory
edef902
Merge branch 'frontend/CreateRoom'
10d598e
編排調整
a447af8
Merge branch 'main' of https://github.com/Game-as-a-Service/citadels-…
1fbd589
刪除預設帳號
a07123b
刪除預設帳號
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
build | ||
node_modules | ||
Cypress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2020": true | ||
"browser": true, | ||
"es2020": true | ||
}, | ||
"extends": [ | ||
"plugin:react/recommended", | ||
"standard", | ||
"prettier", | ||
"plugin:prettier/recommended" | ||
"plugin:react/recommended", | ||
"standard", | ||
"prettier", | ||
"plugin:prettier/recommended", | ||
"plugin:cypress/recommended" | ||
], | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": 11, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react", | ||
"prettier" | ||
], | ||
"plugins": ["react", "prettier"], | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
} | ||
}, | ||
"rules": { | ||
"react/react-in-jsx-scope": "off", | ||
"no-case-declarations": "off", | ||
"no-extend-native": "off", | ||
"no-prototype-builtins": "off", | ||
"no-useless-escape": "off", | ||
"space-before-function-paren": ["error", {"anonymous": "always", "named": "never", "asyncArrow": "always"}], | ||
"no-multi-spaces": ["error", { "ignoreEOLComments": true }], | ||
"prefer-promise-reject-errors": ["error", {"allowEmptyReject": true}], | ||
"prettier/prettier": [ "warn", {"endOfLine": "auto"}], | ||
"no-unused-vars": "off" | ||
"react/react-in-jsx-scope": "off", | ||
"no-case-declarations": "off", | ||
"no-extend-native": "off", | ||
"no-prototype-builtins": "off", | ||
"no-useless-escape": "off", | ||
"space-before-function-paren": [ | ||
"error", | ||
{ "anonymous": "always", "named": "never", "asyncArrow": "always" } | ||
], | ||
"no-multi-spaces": ["error", { "ignoreEOLComments": true }], | ||
"prefer-promise-reject-errors": ["error", { "allowEmptyReject": true }], | ||
"prettier/prettier": ["warn", { "endOfLine": "auto" }], | ||
"no-unused-vars": "off" | ||
}, | ||
"globals": { | ||
"PropTypes": "readonly", | ||
"ReactDom": "readonly", | ||
"React": "readonly" | ||
"PropTypes": "readonly", | ||
"ReactDom": "readonly", | ||
"React": "readonly" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ postcss.config.js | |
.vscode | ||
.eslintrc.json | ||
.eslintignore | ||
cypress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// eslint-disable-next-line no-undef | ||
describe('My First Test', () => { | ||
// eslint-disable-next-line no-undef | ||
it('Visits the Kitchen Sink', () => { | ||
// eslint-disable-next-line no-undef | ||
cy.visit('http://localhost:3001/') | ||
describe('Main Page Test', () => { | ||
it('Display game lobby', () => { | ||
cy.viewport(1920, 1080) | ||
cy.intercept('GET', '**/games', { | ||
success: true, | ||
fixture: 'roomList.json' | ||
}).as('getRooms') | ||
cy.visit('http://localhost:3001/rooms') | ||
cy.get('.room-list') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ | ||
"searchTime": "2023-07-04T20:29:54.001Z", | ||
"totalRooms": 13, | ||
"status": "OK", | ||
"msg": "", | ||
"rooms": [ | ||
{ | ||
"roomId": "sxsxs111", | ||
"gameName": "一起玩富饒之城", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "陳XX", | ||
"holderId": "player1", | ||
"totalPlayers": 3, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "陳XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player3", "playerName": "陳XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs222", | ||
"gameName": "一起玩玩玩玩富饒之城", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "王XX", | ||
"holderId": "player1", | ||
"totalPlayers": 5, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "王XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player3", "playerName": "陳XX" }, | ||
{ "playerId": "player4", "playerName": "葉XX" }, | ||
{ "playerId": "player5", "playerName": "林XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs333", | ||
"gameName": "一起玩 citadels-game", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "黃XX", | ||
"holderId": "player1", | ||
"totalPlayers": 1, | ||
"users": [{ "playerId": "player1", "playerName": "黃XX" }] | ||
}, | ||
{ | ||
"roomId": "sxsxs444", | ||
"gameName": "一起玩 $#*&(%%", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "王XX", | ||
"holderId": "player1", | ||
"totalPlayers": 7, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "王XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player3", "playerName": "陳XX" }, | ||
{ "playerId": "player4", "playerName": "葉XX" }, | ||
{ "playerId": "player5", "playerName": "林XX" }, | ||
{ "playerId": "player6", "playerName": "王XX" }, | ||
{ "playerId": "player7", "playerName": "謝XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs555", | ||
"gameName": "一緒にお城ゲームをする城", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "王XX", | ||
"holderId": "player1", | ||
"totalPlayers": 5, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "王XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player3", "playerName": "陳XX" }, | ||
{ "playerId": "player4", "playerName": "葉XX" }, | ||
{ "playerId": "player5", "playerName": "林XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs666", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "黃XX", | ||
"holderId": "player1", | ||
"totalPlayers": 4, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "黃XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player3", "playerName": "陳XX" }, | ||
{ "playerId": "player4", "playerName": "葉XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs777", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "葉XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "葉XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs888", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "張XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "張XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs999", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "吳XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "吳XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs010", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "黃XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "黃XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs011", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "黃XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "黃XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs012", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "黃XX", | ||
"holderId": "player1", | ||
"totalPlayers": 3, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "黃XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
}, | ||
{ | ||
"roomId": "sxsxs013", | ||
"gameName": "一起玩富饒之城1234", | ||
"createTime": "2023-07-04T19:29:54.001Z", | ||
"status": "OPEN", | ||
"holderName": "洪XX", | ||
"holderId": "player1", | ||
"totalPlayers": 2, | ||
"users": [ | ||
{ "playerId": "player1", "playerName": "洪XX" }, | ||
{ "playerId": "player2", "playerName": "黃XX" } | ||
] | ||
} | ||
] | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import axiosInstance from '../common/axiosInstance' | ||
|
||
const url = | ||
process.env.NODE_ENV === 'development' | ||
? 'https://001f08b9-acb7-4c3a-a54f-a9254b7e8e55.mock.pstmn.io' | ||
: '' | ||
const axios = axiosInstance(url) | ||
|
||
export type RoomList = { | ||
totalRooms: number | ||
status: string | ||
msg: string | ||
rooms: Array<RoomInfo> | ||
} | ||
|
||
type RoomInfo = { | ||
roomId: string | ||
gameName: string | ||
createTime: string | ||
status: string | ||
holderName: string | ||
holderId: string | ||
totalPlayers: number | ||
users: Array<player> | ||
} | ||
|
||
type player = { | ||
playerId: string | ||
playerName: string | ||
} | ||
|
||
export const getRoomList = () => { | ||
return axios.get<RoomList>('/rooms') | ||
} | ||
|
||
type CreateRoom = { | ||
createTime: string | ||
status: string | ||
msg: string | ||
rooms: Record<string, create_room> | ||
} | ||
|
||
type create_room = { | ||
roomId: string | ||
roomName: string | ||
holderId: string | ||
holderName: string | ||
users: Array<{ | ||
userId: string | ||
userName: string | ||
userImage: string | ||
}> | ||
status: string | ||
totalUsers: number | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 這邊的create_room跟底下的specific_room,建議名稱可以再重新想一下,重複名稱容易造成混淆 |
||
export const createRoom = (payload: Object) => { | ||
return axios.post<CreateRoom>('/api/citadels/room', payload) | ||
} | ||
|
||
type SpecificRoom = { | ||
searchTime: string | ||
status: string | ||
msg: string | ||
rooms: Record<string, specific_room> | ||
} | ||
|
||
type specific_room = { | ||
roomId: string | ||
roomName: string | ||
createTime: string | ||
status: string | ||
holderName: string | ||
holderId: string | ||
totalUsers: number | ||
users: Array<{ | ||
userId: string | ||
userName: string | ||
userImage: string | ||
}> | ||
} | ||
|
||
export const getSpecificRoom = (payload: String) => { | ||
return axios.get<SpecificRoom>(`/api/citadels/rooms/${payload}`) | ||
} | ||
|
||
export const leaveRoom = (payload: Object, roomId: string) => { | ||
return axios.post(`/rooms/${roomId}:leave`, payload) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有注意到這裡跟types.ts裡的內容是重複的,感覺可以直接import進來就好~