UNPKG

phx-react

Version:

PHX REACT

327 lines (319 loc) • 8.42 kB
import { TIEU_HOC_CODE } from '../../constant'; import { AWAIT_COLLECT_TICKET_CODE, AWAIT_CONFIRM_TICKET_CODE, BORROWED_TICKET_CODE, IN_BOOKSHELF_STATE_CODE, IN_WAREHOUSE_STATE_CODE, STATUS_BOOK, } from './constants'; export const getListBookStateQuery = ` query getListBookStateQuery($schoolId: Int!) { library_state( where: {deleted_at: {_is_null: true}, school_id: {_eq: $schoolId}} ) { id code } } `; export const getQrPrefixCodeQuery = ` query getQrPrefixCodeQuery($id: Int!) { library_warehouse(where: {id: {_eq: $id}}) { qr_code_prefix tem_name } } `; export const getBookScanReturnQueryV2 = ` query getBookScanReturnQueryV2( $code: String! $school_id: Int! $warehouseId: Int! $currentSchoolYearId: Int! ) { library_dang_ki_ca_biet( where: { deleted_at: {_is_null: true} code: {_eq: $code} school_id: {_eq: $school_id} warehouse_id: {_eq: $warehouseId} library_book_copy: { deleted_at: {_is_null: true}, library_book: { deleted_at: {_is_null: true} } } } ) { id pre_state code library_book_copy { library_book_images(where: {deleted_at: {_is_null: true}}) { url } library_book { title } } state_id library_borrow_books(where: {return_date:{_is_null: true} library_borrow_ticket:{library_ticket_state:{code:{_eq: "${BORROWED_TICKET_CODE}"}}} deleted_at: {_is_null: true}}) { id library_borrow_ticket { id library_borrow_books(where: {deleted_at: {_is_null: true}}) { return_date } actual_borrow_date expect_return_date user { full_name user_roles(where: {deleted_at: {_is_null: true}}) { role { role_code name } } profile_staff { user_code } profile_student { user_code } profile_teacher { user_code } classroom_students( where: { deleted_at: {_is_null: true} classroom: {school_year_id: {_eq: $currentSchoolYearId}} } ) { classroom { name } } } } } } } `; export const queryGetPrefixCode = ` query queryGetPrefixCode($id: Int!) { library_warehouse(where: {id: {_eq: $id}}) { qr_code_prefix } } `; export const getWarehouseIdByEducationalLevelCodeQuery = ` query getWarehouseIdByEducationalLevelCodeQuery( $educationalLevelCode: String! $schoolId: Int! ) { library_warehouse_educational_level( where: {educational_level: {school_id: {_eq: $schoolId} code: {_eq: $educationalLevelCode}}} ) { warehouse_id } } `; export const searchBookBorrowQuery = ` query searchBookBorrowQuery( $school_id: Int! $warehouseId: Int! $code: String! ) { library_dang_ki_ca_biet( where: { code: {_eq: $code} warehouse_id: {_eq: $warehouseId} school_id: {_eq: $school_id} deleted_at: {_is_null: true} library_book_copy: { deleted_at: {_is_null: true} library_book: {deleted_at: {_is_null: true}} } } ) { id code state_id library_state { name code } library_book_copy { id library_book_images(where: {deleted_at: {_is_null: true}}) { url } library_book { title } } } } `; export const searchBookForModalBorrowQuery = function (schoolId, warehouseId) { return { enable: true, keyResult: 'library_book_copy', query: ` query searchBookForModalBorrowQuery { library_book_copy(where: { deleted_at: {_is_null: true}, warehouse_id: {_eq: ${warehouseId}}, school_id: {_eq: ${schoolId}} library_book: { _or:[ {title: { _ilike: "%@value%" }} {title_unaccent: { _ilike: "%@value%" }} ] deleted_at: {_is_null: true}, is_active: {_eq: ${STATUS_BOOK.ACTIVE}} } } ) { library_book { title } library_book_images(where: {deleted_at: {_is_null: true}}) { url } library_dang_ki_ca_biets(where: { deleted_at: {_is_null: true}, library_state: { code:{_in: [ ${IN_WAREHOUSE_STATE_CODE}, ${IN_BOOKSHELF_STATE_CODE} ]} } }) { id code state_id } } } `, }; }; export const getDataSelectQuery = (educationalLevelCode) => { const classroomConditional = educationalLevelCode === TIEU_HOC_CODE ? `grade: {educational_level: {code: {_eq: ${TIEU_HOC_CODE}}}}` : `grade: {educational_level: {code: {_neq: ${TIEU_HOC_CODE}}}}`; return ` query getDataSelectQuery($school_id: Int!, $school_year_id: Int!, $educationalLevelCode: String!) { library_book_borrower( where: {deleted_at: {_is_null: true}, school_id: {_eq: $school_id}} ) { id name code default } classroom( where: { deleted_at: {_is_null: true} code: {_is_null: false} school_id: {_eq: $school_id} ${classroomConditional} school_year_id:{_eq: $school_year_id} } ) { id name } library_warehouse_educational_level( where: {educational_level: {code: {_eq: $educationalLevelCode}}} ) { warehouse_id library_warehouse { qr_code_prefix tem_name } } ticketStates: library_ticket_state( where: {deleted_at: {_is_null: true}, school_id: {_eq: $school_id}} ) { code id } } `; }; export const searchUserBorrow = function (schoolId, currentSchoolYearId, filterProfile) { return { enable: true, keyResult: 'users_search', query: ` query searchUserQuery { users_search( limit: 20 args: { q: "%@value%" } where: { school_id: { _eq: ${schoolId} } deleted_at: { _is_null: true } user_roles: { is_active: { _eq: true } deleted_at: { _is_null: true } role: { deleted_at: { _is_null: true } } } ${filterProfile} } ) { id full_name user_roles ( where:{ user: { school_id: {_eq: ${schoolId}} } role:{ school_id: {_eq: ${schoolId}} deleted_at: {_is_null: true} } is_active: {_eq: true} deleted_at: {_is_null: true} } ) { role { name role_code } } profile_staff { user_code } profile_student { user_code } profile_teacher { user_code } library_borrow_tickets( where: { cancel_date: { _is_null: true } deleted_at: { _is_null: true } library_ticket_state:{ code:{_in: [ ${BORROWED_TICKET_CODE}, ${AWAIT_COLLECT_TICKET_CODE}, ${AWAIT_CONFIRM_TICKET_CODE} ]} } } ) { id } classroom_students( where: { deleted_at: { _is_null: true } classroom: { school_year_id: { _eq: ${currentSchoolYearId} } deleted_at: { _is_null: true } } } ) { classroom { name grade { name } } } } } `, }; }; //# sourceMappingURL=query.js.map